00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #if defined(_MSC_VER)
00013
00014 # pragma warning(disable:4786)
00015 #endif
00016 #include <string>
00017 #include <cassert>
00018 #include <cfloat>
00019 #include "OsiSolverInterface.hpp"
00020 #include "CoinWarmStartBasis.hpp"
00021 #include "CbcModel.hpp"
00022 #include "BonCbcNode.hpp"
00023 #include "BonOsiTMINLPInterface.hpp"
00024 #include "BonIpoptWarmStart.hpp"
00025 #include "BonOsiTMINLPInterface.hpp"
00026
00027 using namespace std;
00028
00029
00030 namespace Bonmin
00031 {
00032
00033 BonCbcFullNodeInfo::BonCbcFullNodeInfo()
00034 :
00035 CbcFullNodeInfo(),
00036 sequenceOfInfeasiblesSize_(0),
00037 sequenceOfUnsolvedSize_(0)
00038 {}
00039
00040 BonCbcFullNodeInfo::BonCbcFullNodeInfo(CbcModel * model,
00041 int numberRowsAtContinuous) :
00042 CbcFullNodeInfo(model, numberRowsAtContinuous),
00043 sequenceOfInfeasiblesSize_(0),
00044 sequenceOfUnsolvedSize_(0)
00045 {}
00046
00047
00048 BonCbcFullNodeInfo::BonCbcFullNodeInfo ( const BonCbcFullNodeInfo &other):
00049 CbcFullNodeInfo(other),
00050 sequenceOfInfeasiblesSize_(other.sequenceOfInfeasiblesSize_),
00051 sequenceOfUnsolvedSize_(other.sequenceOfUnsolvedSize_)
00052
00053 {}
00054
00055
00056 void
00057 BonCbcFullNodeInfo::allBranchesGone()
00058 {
00059 IpoptWarmStart * ipws = dynamic_cast<IpoptWarmStart *>(basis_);
00060 if (ipws)
00061 ipws->flushPoint();
00062 }
00063
00064 BonCbcFullNodeInfo::~BonCbcFullNodeInfo()
00065 {}
00066
00067 CbcNodeInfo *
00068 BonCbcFullNodeInfo::clone() const
00069 {
00070 return new BonCbcFullNodeInfo(*this);
00071 }
00072
00073 void
00074 BonCbcFullNodeInfo::registerOptions(Ipopt::SmartPtr<Bonmin::RegisteredOptions> roptions)
00075 {
00076
00077
00078 roptions->SetRegisteringCategory("Options for non-convex problems", RegisteredOptions::BonminCategory);
00079 roptions->AddLowerBoundedIntegerOption("max_consecutive_infeasible",
00080 "Number of consecutive infeasible subproblems before aborting a"
00081 " branch.",
00082 0,0,
00083 "Will continue exploring a branch of the tree until \"max_consecutive_infeasible\""
00084 "consecutive problems are infeasibles by the NLP sub-solver.");
00085
00086 roptions->SetRegisteringCategory("Nlp solution robustness", RegisteredOptions::BonminCategory);
00087 roptions->AddLowerBoundedIntegerOption
00088 ("max_consecutive_failures",
00089 "(temporarily removed) Number $n$ of consecutive unsolved problems before aborting a branch of the tree.",
00090 0,10,
00091 "When $n > 0$, continue exploring a branch of the tree until $n$ "
00092 "consecutive problems in the branch are unsolved (we call unsolved a problem for which Ipopt can not "
00093 "guarantee optimality within the specified tolerances).");
00094
00095 }
00096
00097
00098
00099
00100
00101 BonCbcPartialNodeInfo::BonCbcPartialNodeInfo ()
00102 : CbcPartialNodeInfo(),
00103 sequenceOfInfeasiblesSize_(0),
00104 sequenceOfUnsolvedSize_(0)
00105 {}
00106
00107 BonCbcPartialNodeInfo::BonCbcPartialNodeInfo (CbcModel * model,CbcNodeInfo *parent, CbcNode *owner,
00108 int numberChangedBounds,
00109 const int *variables,
00110 const double *boundChanges,
00111 const CoinWarmStartDiff *basisDiff)
00112 : CbcPartialNodeInfo(parent,owner,numberChangedBounds,variables,
00113 boundChanges,basisDiff),
00114 sequenceOfInfeasiblesSize_(0),
00115 sequenceOfUnsolvedSize_(0)
00116 {
00117 BonCbcPartialNodeInfo * nlpParent = dynamic_cast<BonCbcPartialNodeInfo *> (parent);
00118 int numberInfeasible = 0;
00119 int numberUnsolved = 0;
00120 if (nlpParent)
00121 {
00122 numberInfeasible = nlpParent->getSequenceOfInfeasiblesSize();
00123 numberUnsolved = nlpParent->getSequenceOfUnsolvedSize();
00124
00125
00126
00127
00128 }
00129 else {
00130 BonCbcFullNodeInfo * nlpRoot = dynamic_cast<BonCbcFullNodeInfo *> (parent);
00131 if (nlpRoot) {
00132 numberInfeasible = nlpRoot->getSequenceOfInfeasiblesSize();
00133 numberUnsolved = nlpRoot->getSequenceOfUnsolvedSize();
00134 }
00135 }
00136 if (model->solver()->isAbandoned() ||
00137 model->solver()->isIterationLimitReached())
00138 sequenceOfUnsolvedSize_ = numberUnsolved + 1;
00139
00140 if (model->solver()->isProvenPrimalInfeasible())
00141 sequenceOfInfeasiblesSize_ = numberInfeasible + 1;
00142 }
00143
00144 BonCbcPartialNodeInfo::BonCbcPartialNodeInfo (const BonCbcPartialNodeInfo & rhs)
00145
00146 : CbcPartialNodeInfo(rhs),
00147 sequenceOfInfeasiblesSize_(rhs.sequenceOfInfeasiblesSize_),
00148 sequenceOfUnsolvedSize_(rhs.sequenceOfUnsolvedSize_)
00149
00150 {}
00151
00152 CbcNodeInfo *
00153 BonCbcPartialNodeInfo::clone() const
00154 {
00155 return (new BonCbcPartialNodeInfo(*this));
00156 }
00157
00158 void
00159 BonCbcPartialNodeInfo::allBranchesGone()
00160 {
00161 IpoptWarmStartDiff * ipws = dynamic_cast<IpoptWarmStartDiff *>(basisDiff_);
00162 if (ipws)
00163 ipws->flushPoint();
00164 }
00165
00166 BonCbcPartialNodeInfo::~BonCbcPartialNodeInfo ()
00167 {}
00168 }