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