Clp  1.16.11
ClpNode.hpp
Go to the documentation of this file.
1 /* $Id: ClpNode.hpp 1910 2013-01-27 02:00:13Z stefan $ */
2 // Copyright (C) 2008, International Business Machines
3 // Corporation and others. All Rights Reserved.
4 // This code is licensed under the terms of the Eclipse Public License (EPL).
5 
6 #ifndef ClpNode_H
7 #define ClpNode_H
8 
9 #include "CoinPragma.hpp"
10 
11 // This implements all stuff for Clp fathom
16 class ClpFactorization;
17 class ClpDualRowSteepest;
18 class ClpNodeStuff;
19 class ClpNode {
20 
21 public:
29  void applyNode(ClpSimplex * model, int doBoundsEtc );
31  void chooseVariable(ClpSimplex * model, ClpNodeStuff * info);
35  void createArrays(ClpSimplex * model);
39 
42  inline double objectiveValue() const {
44  return objectiveValue_;
45  }
47  inline void setObjectiveValue(double value) {
48  objectiveValue_ = value;
49  }
51  inline const double * primalSolution() const {
52  return primalSolution_;
53  }
55  inline const double * dualSolution() const {
56  return dualSolution_;
57  }
59  inline double branchingValue() const {
60  return branchingValue_;
61  }
63  inline double sumInfeasibilities() const {
64  return sumInfeasibilities_;
65  }
67  inline int numberInfeasibilities() const {
69  }
71  inline int depth() const {
72  return depth_;
73  }
75  inline double estimatedSolution() const {
76  return estimatedSolution_;
77  }
79  int way() const;
81  bool fathomed() const;
83  void changeState();
85  inline int sequence() const {
86  return sequence_;
87  }
89  inline bool oddArraysExist() const {
90  return lower_ != NULL;
91  }
93  inline const unsigned char * statusArray() const {
94  return status_;
95  }
97 
103  ClpNode (ClpSimplex * model, const ClpNodeStuff * stuff, int depth);
105  void gutsOfConstructor(ClpSimplex * model, const ClpNodeStuff * stuff,
106  int arraysExist, int depth);
108  virtual ~ClpNode();
110 
114  ClpNode(const ClpNode&);
118 
119 protected:
120 // For state of branch
121  typedef struct {
122  unsigned int firstBranch: 1; // nonzero if first branch on variable is up
123  unsigned int branch: 2; // 0 means do first branch next, 1 second, 2 finished
124  unsigned int spare: 29;
125  } branchState;
128  double branchingValue_;
141  unsigned char * status_;
143  double * primalSolution_;
145  double * dualSolution_;
147  int * lower_;
149  int * upper_;
153  int * fixed_;
161  int depth_;
165  int flags_;
175 };
177 
178 public:
184  virtual ~ClpNodeStuff();
186 
194  void zap(int type);
196 
197 
201  void fillPseudoCosts(const double * down, const double * up,
202  const int * priority,
203  const int * numberDown, const int * numberUp,
204  const int * numberDownInfeasible, const int * numberUpInfeasible,
205  int number);
207  void update(int way, int sequence, double change, bool feasible);
209  int maximumNodes() const;
211  int maximumSpace() const;
213 
214 public:
217  double integerTolerance_;
222  double smallChange_;
224  double * downPseudo_;
226  double * upPseudo_;
228  int * priority_;
230  int * numberDown_;
232  int * numberUp_;
238  double * saveCosts_;
244  int * whichRow_;
247 #ifndef NO_FATHOM_PRINT
248  CoinMessageHandler * handler_;
250 #endif
251  int nBound_;
271  int nDepth_;
273  int nNodes_;
280 #ifndef NO_FATHOM_PRINT
281  int startingDepth_;
285 #endif
286 
287 };
289 
290 public:
293  int index(double value) const;
296  int addValue(double value) ;
298  inline int numberEntries() const {
299  return numberHash_;
300  }
302 
310  virtual ~ClpHashValue();
312 
320 private:
324  int hash(double value) const;
326  void resize(bool increaseMax);
328 
329 protected:
333  // for hashing
335  typedef struct {
336  double value;
337  int index, next;
338  } CoinHashLink;
340  mutable CoinHashLink *hash_;
344  int maxHash_;
348 };
349 #endif
ClpSimplex
This solves LPs using the simplex method.
Definition: ClpSimplex.hpp:70
ClpNode::objectiveValue_
double objectiveValue_
Value of objective.
Definition: ClpNode.hpp:131
ClpFactorization
This just implements CoinFactorization when an ClpMatrixBase object is passed.
Definition: ClpFactorization.hpp:39
ClpNode::estimatedSolution_
double estimatedSolution_
Estimated solution value.
Definition: ClpNode.hpp:135
ClpNode::dualSolution
const double * dualSolution() const
Dual solution.
Definition: ClpNode.hpp:55
ClpNodeStuff::~ClpNodeStuff
virtual ~ClpNodeStuff()
Destructor.
ClpNodeStuff::startingDepth_
int startingDepth_
Depth passed in.
Definition: ClpNode.hpp:282
ClpNodeStuff::operator=
ClpNodeStuff & operator=(const ClpNodeStuff &)
Operator =.
ClpNodeStuff::nodeCalled_
int nodeCalled_
Node at which called.
Definition: ClpNode.hpp:284
ClpNodeStuff::whichRow_
int * whichRow_
Which rows in large model.
Definition: ClpNode.hpp:244
ClpNode::createArrays
void createArrays(ClpSimplex *model)
Create odd arrays.
ClpNodeStuff::saveCosts_
double * saveCosts_
Copy of costs (local)
Definition: ClpNode.hpp:238
ClpNode::sumInfeasibilities
double sumInfeasibilities() const
Sum infeasibilities.
Definition: ClpNode.hpp:63
ClpNode::numberInfeasibilities_
int numberInfeasibilities_
Number of infeasibilities.
Definition: ClpNode.hpp:159
ClpNodeStuff::update
void update(int way, int sequence, double change, bool feasible)
Update pseudo costs.
ClpNodeStuff::handler_
CoinMessageHandler * handler_
Cbc's message handler.
Definition: ClpNode.hpp:249
ClpNode::maximumColumns_
int maximumColumns_
Maximum columns so far.
Definition: ClpNode.hpp:171
ClpNode::primalSolution_
double * primalSolution_
Primal solution.
Definition: ClpNode.hpp:143
ClpNode::maximumFixed_
int maximumFixed_
Maximum number fixed by reduced cost.
Definition: ClpNode.hpp:167
ClpNode::way
int way() const
Way for integer variable -1 down , +1 up.
ClpNodeStuff::maximumNodes
int maximumNodes() const
Return maximum number of nodes.
ClpNodeStuff::nBound_
int nBound_
Number bounds in large model.
Definition: ClpNode.hpp:252
ClpNode::status_
unsigned char * status_
Status vector.
Definition: ClpNode.hpp:141
ClpNode::changeState
void changeState()
Change state of variable i.e. go other way.
ClpNode::depth_
int depth_
Relative depth.
Definition: ClpNode.hpp:161
ClpNodeStuff::solverOptions_
int solverOptions_
Options to pass to solver 1 - create external reduced costs for columns 2 - create external reduced c...
Definition: ClpNode.hpp:263
ClpDualRowSteepest
Dual Row Pivot Steepest Edge Algorithm Class.
Definition: ClpDualRowSteepest.hpp:21
ClpNodeStuff::upPseudo_
double * upPseudo_
Up pseudo costs.
Definition: ClpNode.hpp:226
ClpHashValue::ClpHashValue
ClpHashValue(const ClpHashValue &)
The copy constructor.
ClpHashValue::numberHash_
int numberHash_
Number of entries in hash table.
Definition: ClpNode.hpp:342
ClpNodeStuff::fillPseudoCosts
void fillPseudoCosts(const double *down, const double *up, const int *priority, const int *numberDown, const int *numberUp, const int *numberDownInfeasible, const int *numberUpInfeasible, int number)
Fill with pseudocosts.
ClpNode::dualSolution_
double * dualSolution_
Dual solution.
Definition: ClpNode.hpp:145
ClpNode::ClpNode
ClpNode()
Default constructor.
ClpNodeStuff::nDepth_
int nDepth_
Number deep.
Definition: ClpNode.hpp:271
ClpNode::ClpNode
ClpNode(const ClpNode &)
The copy constructor.
ClpNode::statusArray
const unsigned char * statusArray() const
Status array.
Definition: ClpNode.hpp:93
ClpNode::factorization_
ClpFactorization * factorization_
Factorization.
Definition: ClpNode.hpp:137
ClpNode::cleanUpForCrunch
void cleanUpForCrunch()
Clean up as crunch is different model.
ClpNodeStuff::stateOfSearch_
int stateOfSearch_
State of search from CbcModel.
Definition: ClpNode.hpp:269
ClpNodeStuff::integerIncrement_
double integerIncrement_
Integer increment.
Definition: ClpNode.hpp:220
ClpNode::branchingValue_
double branchingValue_
Initial value of integer variable.
Definition: ClpNode.hpp:129
ClpHashValue::ClpHashValue
ClpHashValue(ClpSimplex *model)
Useful constructor.
ClpNode::setObjectiveValue
void setObjectiveValue(double value)
Set objective value.
Definition: ClpNode.hpp:47
ClpNode::maximumRows_
int maximumRows_
Maximum rows so far.
Definition: ClpNode.hpp:169
ClpNodeStuff::numberUp_
int * numberUp_
Number of times up.
Definition: ClpNode.hpp:232
ClpNode::depth
int depth() const
Relative depth.
Definition: ClpNode.hpp:71
ClpHashValue::~ClpHashValue
virtual ~ClpHashValue()
Destructor.
ClpNode::branchState::firstBranch
unsigned int firstBranch
Definition: ClpNode.hpp:122
ClpNode::~ClpNode
virtual ~ClpNode()
Destructor.
ClpNode::maximumIntegers_
int maximumIntegers_
Maximum Integers so far.
Definition: ClpNode.hpp:173
ClpNode::fathomed
bool fathomed() const
Return true if branch exhausted.
ClpNode::upper_
int * upper_
Integer upper bounds (only used in fathomMany)
Definition: ClpNode.hpp:149
ClpHashValue
Definition: ClpNode.hpp:288
ClpHashValue::addValue
int addValue(double value)
Add value to list and return index.
ClpNodeStuff::whichColumn_
int * whichColumn_
Which columns in large model.
Definition: ClpNode.hpp:246
ClpNode::chooseVariable
void chooseVariable(ClpSimplex *model, ClpNodeStuff *info)
Choose a new variable.
ClpNode::branchingValue
double branchingValue() const
Initial value of integer variable.
Definition: ClpNode.hpp:59
ClpNode::numberFixed_
int numberFixed_
Number fixed by reduced cost.
Definition: ClpNode.hpp:163
ClpNodeStuff::numberDownInfeasible_
int * numberDownInfeasible_
Number of times down infeasible.
Definition: ClpNode.hpp:234
ClpNodeStuff::ClpNodeStuff
ClpNodeStuff()
Default constructor.
ClpNode::branchState_
branchState branchState_
State of branch.
Definition: ClpNode.hpp:155
ClpNodeStuff
Definition: ClpNode.hpp:176
ClpNodeStuff::downPseudo_
double * downPseudo_
Down pseudo costs.
Definition: ClpNode.hpp:224
ClpNodeStuff::numberIterations_
int numberIterations_
Number of iterations.
Definition: ClpNode.hpp:277
ClpNode::branchState::branch
unsigned int branch
Definition: ClpNode.hpp:123
ClpNode::sequence
int sequence() const
Sequence number of integer variable (-1 if none)
Definition: ClpNode.hpp:85
ClpNodeStuff::smallChange_
double smallChange_
Small change in branch.
Definition: ClpNode.hpp:222
ClpNodeStuff::integerTolerance_
double integerTolerance_
Integer tolerance.
Definition: ClpNode.hpp:218
ClpNode::sumInfeasibilities_
double sumInfeasibilities_
Sum of infeasibilities.
Definition: ClpNode.hpp:133
ClpNode::weights_
ClpDualRowSteepest * weights_
Steepest edge weights.
Definition: ClpNode.hpp:139
ClpHashValue::hash_
CoinHashLink * hash_
Hash table.
Definition: ClpNode.hpp:340
ClpNode::oddArraysExist
bool oddArraysExist() const
If odd arrays exist.
Definition: ClpNode.hpp:89
ClpNode::pivotVariables_
int * pivotVariables_
Pivot variables for factorization.
Definition: ClpNode.hpp:151
ClpNode::objectiveValue
double objectiveValue() const
Objective value.
Definition: ClpNode.hpp:43
ClpNodeStuff::numberUpInfeasible_
int * numberUpInfeasible_
Number of times up infeasible.
Definition: ClpNode.hpp:236
ClpNodeStuff::numberNodesExplored_
int numberNodesExplored_
Number of nodes explored.
Definition: ClpNode.hpp:275
ClpNodeStuff::maximumNodes_
int maximumNodes_
Maximum number of nodes to do.
Definition: ClpNode.hpp:265
ClpNodeStuff::presolveType_
int presolveType_
Type of presolve - 0 none, 1 crunch.
Definition: ClpNode.hpp:279
ClpNodeStuff::nNodes_
int nNodes_
Number nodes returned (-1 if fathom aborted)
Definition: ClpNode.hpp:273
ClpNodeStuff::zap
void zap(int type)
Zaps stuff 1 - arrays, 2 ints, 3 both.
ClpNode::fixed_
int * fixed_
Variables fixed by reduced costs (at end of branch) 0x10000000 added if fixed to UB.
Definition: ClpNode.hpp:153
ClpNode::flags_
int flags_
Flags - 1 duals scaled.
Definition: ClpNode.hpp:165
ClpNode::lower_
int * lower_
Integer lower bounds (only used in fathomMany)
Definition: ClpNode.hpp:147
ClpHashValue::ClpHashValue
ClpHashValue()
Default constructor.
ClpNode::gutsOfConstructor
void gutsOfConstructor(ClpSimplex *model, const ClpNodeStuff *stuff, int arraysExist, int depth)
Does work of constructor (partly so gdb will work)
ClpNode::fixOnReducedCosts
int fixOnReducedCosts(ClpSimplex *model)
Fix on reduced costs.
ClpNode::branchState
Definition: ClpNode.hpp:121
ClpNodeStuff::nodeInfo_
ClpNode ** nodeInfo_
Array of ClpNodes.
Definition: ClpNode.hpp:240
ClpNode::numberInfeasibilities
int numberInfeasibilities() const
Number infeasibilities.
Definition: ClpNode.hpp:67
ClpNode::branchState::spare
unsigned int spare
Definition: ClpNode.hpp:124
ClpNode::ClpNode
ClpNode(ClpSimplex *model, const ClpNodeStuff *stuff, int depth)
Constructor from model.
ClpNode::estimatedSolution
double estimatedSolution() const
Estimated solution value.
Definition: ClpNode.hpp:75
ClpHashValue::maxHash_
int maxHash_
Maximum number of entries in hash table i.e. size.
Definition: ClpNode.hpp:344
ClpNode::sequence_
int sequence_
Sequence number of integer variable (-1 if none)
Definition: ClpNode.hpp:157
ClpNodeStuff::numberDown_
int * numberDown_
Number of times down.
Definition: ClpNode.hpp:230
ClpNodeStuff::ClpNodeStuff
ClpNodeStuff(const ClpNodeStuff &)
The copy constructor.
ClpHashValue::numberEntries
int numberEntries() const
Number of different entries.
Definition: ClpNode.hpp:298
ClpNode
Definition: ClpNode.hpp:19
ClpHashValue::operator=
ClpHashValue & operator=(const ClpHashValue &)
=
ClpNodeStuff::priority_
int * priority_
Priority.
Definition: ClpNode.hpp:228
ClpNode::primalSolution
const double * primalSolution() const
Primal solution.
Definition: ClpNode.hpp:51
ClpNodeStuff::saveOptions_
int saveOptions_
Save of specialOptions_ (local)
Definition: ClpNode.hpp:254
ClpNodeStuff::maximumSpace
int maximumSpace() const
Return maximum space for nodes.
ClpNodeStuff::large_
ClpSimplex * large_
Large model if crunched.
Definition: ClpNode.hpp:242
ClpHashValue::lastUsed_
int lastUsed_
Last used space.
Definition: ClpNode.hpp:346
ClpNode::operator=
ClpNode & operator=(const ClpNode &)
Operator =.
ClpHashValue::index
int index(double value) const
Return index or -1 if not found.
ClpNode::applyNode
void applyNode(ClpSimplex *model, int doBoundsEtc)
Applies node to model 0 - just tree bounds 1 - tree bounds and basis etc 2 - saved bounds and basis e...
ClpNodeStuff::numberBeforeTrust_
int numberBeforeTrust_
Number before trust from CbcModel.
Definition: ClpNode.hpp:267