/home/coin/SVN-release/OS-2.4.2/Bonmin/src/Interfaces/BonAuxInfos.cpp

Go to the documentation of this file.
00001 // (C) Copyright International Business Machines Corporation 2007
00002 // All Rights Reserved.
00003 // This code is published under the Common Public License.
00004 //
00005 // Authors :
00006 // Pierre Bonami, International Business Machines Corporation
00007 //
00008 // Date : 04/23/2007
00009 
00010 #include "BonminConfig.h"
00011 #include "BonAuxInfos.hpp"
00012 #include "CoinHelperFunctions.hpp"
00013 #include "CoinFinite.hpp"
00014 
00015 namespace Bonmin
00016 {
00018   AuxInfo::AuxInfo(int type):
00019       OsiBabSolver(type),
00020       infeasibleNode_(false),
00021       objValue_ (COIN_DBL_MAX),
00022       nlpSolution_(NULL),
00023       numcols_(0),
00024       hasNlpSolution_(false),
00025       bestSolution2_(make_referenced(std::vector<double>())),
00026       bestObj2_(make_referenced(COIN_DBL_MAX))
00027   {}
00028 
00030   AuxInfo::AuxInfo(const OsiBabSolver &other):
00031       OsiBabSolver(other),
00032       infeasibleNode_(false),
00033       objValue_ (COIN_DBL_MAX),
00034       nlpSolution_(NULL),
00035       numcols_(0),
00036       hasNlpSolution_(false),
00037       bestSolution2_(make_referenced(std::vector<double>())),
00038       bestObj2_(make_referenced(COIN_DBL_MAX))
00039   {}
00040 
00042   AuxInfo::AuxInfo(const AuxInfo &other):
00043       OsiBabSolver(other),
00044       infeasibleNode_(other.infeasibleNode_),
00045       objValue_ (other.objValue_),
00046       nlpSolution_(NULL),
00047       numcols_(other.numcols_),
00048       hasNlpSolution_(other.hasNlpSolution_),
00049       bestSolution2_(other.bestSolution2_),
00050       bestObj2_(other.bestObj2_)
00051   {
00052     if (other.nlpSolution_!=NULL) {
00053       assert(numcols_ > 0);
00054       nlpSolution_ = new double[numcols_ + 1];
00055       CoinCopyN(other.nlpSolution_, numcols_+1, nlpSolution_);
00056     }
00057   }
00058 
00060   AuxInfo::~AuxInfo()
00061   {
00062     if (nlpSolution_ != NULL)
00063       delete [] nlpSolution_;
00064   }
00065 
00067   OsiAuxInfo *
00068   AuxInfo::clone() const
00069   {
00070     return new AuxInfo(*this);
00071   }
00072 
00073   double AuxInfo::nlpObjValue ()
00074   {return hasNlpSolution_ ? objValue_ : COIN_DBL_MAX;}
00075 
00077   void
00078   AuxInfo::setNlpSolution(const double * sol, int numcols, double objValue)
00079   {
00080     if (numcols_ < numcols) {
00081       delete [] nlpSolution_;
00082       nlpSolution_ = NULL;
00083     }
00084     if (nlpSolution_ == NULL) {
00085       nlpSolution_ = new double[numcols + 1];
00086       numcols_ = numcols;
00087     }
00088     CoinCopyN(sol,  numcols, nlpSolution_);
00089     nlpSolution_[numcols] = objValue;
00090     objValue_ = objValue;
00091   }
00092 
00093 }/* end namespace Bonmin*/
00094 

Generated on Wed Nov 30 03:03:55 2011 by  doxygen 1.4.7