BonCbcNode.cpp
Go to the documentation of this file.
1 // (C) Copyright International Business Machines Corporation and Carnegie Mellon University 2006
2 // All Rights Reserved.
3 // This code is published under the Eclipse Public License.
4 //
5 // Authors :
6 // John J. Forrest, International Business Machines Corporation
7 // P. Bonami, Carnegie Mellon University,
8 //
9 // Date : 03/15/2006
10 
11 
12 #include <string>
13 #include <cassert>
14 #include <cfloat>
15 #include "CoinPragma.hpp"
16 #include "OsiSolverInterface.hpp"
17 #include "CoinWarmStartBasis.hpp"
18 #include "CbcModel.hpp"
19 #include "BonCbcNode.hpp"
21 #include "BonIpoptWarmStart.hpp"
23 
24 using namespace std;
25 
26 
27 namespace Bonmin
28 {
29 //Default constructor
30  BonCbcFullNodeInfo::BonCbcFullNodeInfo()
31  :
32  CbcFullNodeInfo(),
33  sequenceOfInfeasiblesSize_(0),
34  sequenceOfUnsolvedSize_(0)
35  {}
36 
38  int numberRowsAtContinuous) :
39  CbcFullNodeInfo(model, numberRowsAtContinuous),
40  sequenceOfInfeasiblesSize_(0),
41  sequenceOfUnsolvedSize_(0)
42  {}
43 
44 // Copy constructor
46  CbcFullNodeInfo(other),
47  sequenceOfInfeasiblesSize_(other.sequenceOfInfeasiblesSize_),
48  sequenceOfUnsolvedSize_(other.sequenceOfUnsolvedSize_)
49 
50  {}
51 
52 
53  void
55  {
56  IpoptWarmStart * ipws = dynamic_cast<IpoptWarmStart *>(basis_);
57  if (ipws)
58  ipws->flushPoint();
59  }
60 
62 {}
63 
64  CbcNodeInfo *
66  {
67  return new BonCbcFullNodeInfo(*this);
68  }
69 
70  void
72  {
73 
74 
75  roptions->SetRegisteringCategory("Nonconvex problems", RegisteredOptions::BonminCategory);
76  roptions->AddLowerBoundedIntegerOption("max_consecutive_infeasible",
77  "Number of consecutive infeasible subproblems before aborting a"
78  " branch.",
79  0,0,
80  "Will continue exploring a branch of the tree until \"max_consecutive_infeasible\""
81  "consecutive problems are locally infeasible by the NLP sub-solver.");
82  roptions->setOptionExtraInfo("max_consecutive_infeasible",8);
83 
84  roptions->SetRegisteringCategory("NLP solution robustness", RegisteredOptions::BonminCategory);
85  roptions->AddLowerBoundedIntegerOption
86  ("max_consecutive_failures",
87  "(temporarily removed) Number $n$ of consecutive unsolved problems before aborting a branch of the tree.",
88  0,10,
89  "When $n > 0$, continue exploring a branch of the tree until $n$ "
90  "consecutive problems in the branch are unsolved (we call unsolved a problem for which Ipopt can not "
91  "guarantee optimality within the specified tolerances).");
92  roptions->setOptionExtraInfo("max_consecutive_failures",8);
93 
94  }
95 
96 
97  /****************************************************************************************************/
98 
99 // Default constructor
101  : CbcPartialNodeInfo(),
102  sequenceOfInfeasiblesSize_(0),
103  sequenceOfUnsolvedSize_(0)
104  {}
105 // Constructor from current state
106  BonCbcPartialNodeInfo::BonCbcPartialNodeInfo (CbcModel * model,CbcNodeInfo *parent, CbcNode *owner,
107  int numberChangedBounds,
108  const int *variables,
109  const double *boundChanges,
110  const CoinWarmStartDiff *basisDiff)
111  : CbcPartialNodeInfo(parent,owner,numberChangedBounds,variables,
112  boundChanges,basisDiff),
113  sequenceOfInfeasiblesSize_(0),
114  sequenceOfUnsolvedSize_(0)
115  {
116  BonCbcPartialNodeInfo * nlpParent = dynamic_cast<BonCbcPartialNodeInfo *> (parent);
117  int numberInfeasible = 0;
118  int numberUnsolved = 0;
119  if (nlpParent)//father is not root
120  {
121  numberInfeasible = nlpParent->getSequenceOfInfeasiblesSize();
122  numberUnsolved = nlpParent->getSequenceOfUnsolvedSize();
123 // if(!nlpParent->numberBranchesLeft_){
124 // IpoptWarmStartDiff * ipws = dynamic_cast<IpoptWarmStartDiff *>(nlpParent->basisDiff_);
125 // ipws->flushPoint();
126 // }
127  }
128  else {
129  BonCbcFullNodeInfo * nlpRoot = dynamic_cast<BonCbcFullNodeInfo *> (parent);
130  if (nlpRoot) {
131  numberInfeasible = nlpRoot->getSequenceOfInfeasiblesSize();
132  numberUnsolved = nlpRoot->getSequenceOfUnsolvedSize();
133  }
134  }
135  if (model->solver()->isAbandoned() ||
136  model->solver()->isIterationLimitReached())
137  sequenceOfUnsolvedSize_ = numberUnsolved + 1;
138 
139  if (model->solver()->isProvenPrimalInfeasible())
140  sequenceOfInfeasiblesSize_ = numberInfeasible + 1;
141  }
142 
144 
145  : CbcPartialNodeInfo(rhs),
146  sequenceOfInfeasiblesSize_(rhs.sequenceOfInfeasiblesSize_),
147  sequenceOfUnsolvedSize_(rhs.sequenceOfUnsolvedSize_)
148 
149 {}
150 
151  CbcNodeInfo *
153  {
154  return (new BonCbcPartialNodeInfo(*this));
155  }
156 
157  void
159  {
160  IpoptWarmStartDiff * ipws = dynamic_cast<IpoptWarmStartDiff *>(basisDiff_);
161  if (ipws)
162  ipws->flushPoint();
163  }
164 
166 {}
167 }
int getSequenceOfUnsolvedSize()
Number of consecutive unsolved parents only recorded if node is infeasible.
Definition: BonCbcNode.hpp:117
static void registerOptions(Ipopt::SmartPtr< Bonmin::RegisteredOptions > roptions)
Register all the options for class instance.
Definition: BonCbcNode.cpp:71
int sequenceOfInfeasiblesSize_
Number of consecutive infeasible parents only recorded if node is infeasible.
Definition: BonCbcNode.hpp:124
Class for storing warm start informations for Ipopt.
Holds information for recreating a subproblem by incremental change from the parent for...
Definition: BonCbcNode.hpp:85
int getSequenceOfInfeasiblesSize()
Number of consecutive infeasible parents only recorded if node is infeasible.
Definition: BonCbcNode.hpp:53
virtual void allBranchesGone()
Method called when all direct sons have been explored to flush useless warm start information...
Definition: BonCbcNode.cpp:54
int sequenceOfUnsolvedSize_
Number of consecutive unsolved parents only recorded if node is infeasible.
Definition: BonCbcNode.hpp:126
int getSequenceOfInfeasiblesSize()
Number of consecutive infeasible parents only recorded if node is infeasible.
Definition: BonCbcNode.hpp:112
virtual void allBranchesGone()
Method called when all direct sons have been explored to flush useless warm start information...
Definition: BonCbcNode.cpp:158
int getSequenceOfUnsolvedSize()
Number of consecutive unsolved parents only recorded if node is infeasible.
Definition: BonCbcNode.hpp:58
Diff class for IpoptWarmStart.
virtual CbcNodeInfo * clone() const
Clone.
Definition: BonCbcNode.cpp:152
Holds information for recreating a subproblem by incremental change from the parent for Bonmin...
Definition: BonCbcNode.hpp:28
virtual CbcNodeInfo * clone() const
Clone.
Definition: BonCbcNode.cpp:65
void flushPoint()
flush the starting point