ClpNode.hpp
Go to the documentation of this file.
1 /* $Id: ClpNode.hpp 1525 2010-02-26 17:27:59Z mjs $ */
2 // Copyright (C) 2008, International Business Machines
3 // Corporation and others. All Rights Reserved.
4 #ifndef ClpNode_H
5 #define ClpNode_H
6 
7 #include "CoinPragma.hpp"
8 
9 // This implements all stuff for Clp fathom
14 class ClpFactorization;
15 class ClpDualRowSteepest;
16 class ClpNodeStuff;
17 class ClpNode {
18 
19 public:
27  void applyNode(ClpSimplex * model, int doBoundsEtc );
29  void chooseVariable(ClpSimplex * model, ClpNodeStuff * info);
31  int fixOnReducedCosts(ClpSimplex * model);
33  void createArrays(ClpSimplex * model);
35  void cleanUpForCrunch();
37 
40  inline double objectiveValue() const {
42  return objectiveValue_;
43  }
45  inline void setObjectiveValue(double value) {
46  objectiveValue_ = value;
47  }
49  inline const double * primalSolution() const {
50  return primalSolution_;
51  }
53  inline const double * dualSolution() const {
54  return dualSolution_;
55  }
57  inline double branchingValue() const {
58  return branchingValue_;
59  }
61  inline double sumInfeasibilities() const {
62  return sumInfeasibilities_;
63  }
65  inline int numberInfeasibilities() const {
67  }
69  inline int depth() const {
70  return depth_;
71  }
73  inline double estimatedSolution() const {
74  return estimatedSolution_;
75  }
77  int way() const;
79  bool fathomed() const;
81  void changeState();
83  inline int sequence() const {
84  return sequence_;
85  }
87  inline bool oddArraysExist() const {
88  return lower_ != NULL;
89  }
91  inline const unsigned char * statusArray() const {
92  return status_;
93  }
95 
99  ClpNode();
101  ClpNode (ClpSimplex * model, const ClpNodeStuff * stuff, int depth);
103  void gutsOfConstructor(ClpSimplex * model, const ClpNodeStuff * stuff,
104  int arraysExist, int depth);
106  virtual ~ClpNode();
108 
112  ClpNode(const ClpNode&);
114  ClpNode& operator=(const ClpNode&);
116 
117 protected:
118 // For state of branch
119  typedef struct {
120  unsigned int firstBranch: 1; // nonzero if first branch on variable is up
121  unsigned int branch: 2; // 0 means do first branch next, 1 second, 2 finished
122  unsigned int spare: 29;
123  } branchState;
126  double branchingValue_;
139  unsigned char * status_;
141  double * primalSolution_;
143  double * dualSolution_;
145  int * lower_;
147  int * upper_;
151  int * fixed_;
159  int depth_;
163  int flags_;
173 };
175 
176 public:
180  ClpNodeStuff();
182  virtual ~ClpNodeStuff();
184 
188  ClpNodeStuff(const ClpNodeStuff&);
192  void zap(int type);
194 
195 
199  void fillPseudoCosts(const double * down, const double * up,
200  const int * priority,
201  const int * numberDown, const int * numberUp,
202  const int * numberDownInfeasible, const int * numberUpInfeasible,
203  int number);
205  void update(int way, int sequence, double change, bool feasible);
207  int maximumNodes() const;
209  int maximumSpace() const;
211 
212 public:
215  double integerTolerance_;
220  double smallChange_;
222  double * downPseudo_;
224  double * upPseudo_;
226  int * priority_;
228  int * numberDown_;
230  int * numberUp_;
236  double * saveCosts_;
242  int * whichRow_;
246  int nBound_;
265  int nDepth_;
267  int nNodes_;
275 };
277 
278 public:
281  int index(double value) const;
284  int addValue(double value) ;
286  inline int numberEntries() const {
287  return numberHash_;
288  }
290 
294  ClpHashValue();
296  ClpHashValue(ClpSimplex * model);
298  virtual ~ClpHashValue();
300 
304  ClpHashValue(const ClpHashValue&);
308 private:
312  int hash(double value) const;
314  void resize(bool increaseMax);
316 
317 protected:
321  // for hashing
323  typedef struct {
324  double value;
325  int index, next;
326  } CoinHashLink;
328  mutable CoinHashLink *hash_;
332  int maxHash_;
336 };
337 #endif
int lastUsed_
Last used space.
Definition: ClpNode.hpp:334
int flags_
Flags - 1 duals scaled.
Definition: ClpNode.hpp:163
unsigned char * status_
Status vector.
Definition: ClpNode.hpp:139
double * upPseudo_
Up pseudo costs.
Definition: ClpNode.hpp:224
virtual ~ClpNodeStuff()
Destructor.
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...
int * lower_
Integer lower bounds (only used in fathomMany)
Definition: ClpNode.hpp:145
double objectiveValue() const
Objective value.
Definition: ClpNode.hpp:41
double * dualSolution_
Dual solution.
Definition: ClpNode.hpp:143
void changeState()
Change state of variable i.e. go other way.
int * numberDown_
Number of times down.
Definition: ClpNode.hpp:228
int index(double value) const
Return index or -1 if not found.
double branchingValue_
Initial value of integer variable.
Definition: ClpNode.hpp:127
int maximumFixed_
Maximum number fixed by reduced cost.
Definition: ClpNode.hpp:165
int numberInfeasibilities_
Number of infeasibilities.
Definition: ClpNode.hpp:157
ClpNode & operator=(const ClpNode &)
Operator =.
int numberEntries() const
Number of different entries.
Definition: ClpNode.hpp:286
ClpHashValue & operator=(const ClpHashValue &)
=
const unsigned char * statusArray() const
Status array.
Definition: ClpNode.hpp:91
void resize(bool increaseMax)
Resizes.
int maxHash_
Maximum number of entries in hash table i.e. size.
Definition: ClpNode.hpp:332
int stateOfSearch_
State of search from CbcModel.
Definition: ClpNode.hpp:263
double estimatedSolution_
Estimated solution value.
Definition: ClpNode.hpp:133
int nDepth_
Number deep.
Definition: ClpNode.hpp:265
ClpNodeStuff & operator=(const ClpNodeStuff &)
Operator =.
ClpNodeStuff()
Default constructor.
double integerIncrement_
Integer increment.
Definition: ClpNode.hpp:218
double * saveCosts_
Copy of costs (local)
Definition: ClpNode.hpp:236
int hash(double value) const
returns hash
int * whichRow_
Which rows in large model.
Definition: ClpNode.hpp:242
int * upper_
Integer upper bounds (only used in fathomMany)
Definition: ClpNode.hpp:147
bool fathomed() const
Return true if branch exhausted.
Dual Row Pivot Steepest Edge Algorithm Class.
int maximumSpace() const
Return maximum space for nodes.
int * numberDownInfeasible_
Number of times down infeasible.
Definition: ClpNode.hpp:232
virtual ~ClpNode()
Destructor.
int nNodes_
Number nodes returned (-1 if fathom aborted)
Definition: ClpNode.hpp:267
int numberNodesExplored_
Number of nodes explored.
Definition: ClpNode.hpp:269
int numberHash_
Number of entries in hash table.
Definition: ClpNode.hpp:330
void zap(int type)
Zaps stuff 1 - arrays, 2 ints, 3 both.
int depth() const
Relative depth.
Definition: ClpNode.hpp:69
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.
void gutsOfConstructor(ClpSimplex *model, const ClpNodeStuff *stuff, int arraysExist, int depth)
Does work of constructor (partly so gdb will work)
int * fixed_
Variables fixed by reduced costs (at end of branch) 0x10000000 added if fixed to UB.
Definition: ClpNode.hpp:151
double branchingValue() const
Initial value of integer variable.
Definition: ClpNode.hpp:57
branchState branchState_
State of branch.
Definition: ClpNode.hpp:153
int solverOptions_
Options to pass to solver 1 - create external reduced costs for columns 2 - create external reduced c...
Definition: ClpNode.hpp:257
double objectiveValue_
Value of objective.
Definition: ClpNode.hpp:129
int way() const
Way for integer variable -1 down , +1 up.
int sequence_
Sequence number of integer variable (-1 if none)
Definition: ClpNode.hpp:155
int sequence() const
Sequence number of integer variable (-1 if none)
Definition: ClpNode.hpp:83
void setObjectiveValue(double value)
Set objective value.
Definition: ClpNode.hpp:45
ClpSimplex * large_
Large model if crunched.
Definition: ClpNode.hpp:240
double sumInfeasibilities() const
Sum infeasibilities.
Definition: ClpNode.hpp:61
int numberIterations_
Number of iterations.
Definition: ClpNode.hpp:271
double * primalSolution_
Primal solution.
Definition: ClpNode.hpp:141
int maximumNodes_
Maximum number of nodes to do.
Definition: ClpNode.hpp:259
ClpHashValue()
Default constructor.
int saveOptions_
Save of specialOptions_ (local)
Definition: ClpNode.hpp:248
int fixOnReducedCosts(ClpSimplex *model)
Fix on reduced costs.
This solves LPs using the simplex method.
Definition: ClpSimplex.hpp:49
double estimatedSolution() const
Estimated solution value.
Definition: ClpNode.hpp:73
int numberFixed_
Number fixed by reduced cost.
Definition: ClpNode.hpp:161
int maximumColumns_
Maximum columns so far.
Definition: ClpNode.hpp:169
void update(int way, int sequence, double change, bool feasible)
Update pseudo costs.
int * whichColumn_
Which columns in large model.
Definition: ClpNode.hpp:244
void cleanUpForCrunch()
Clean up as crunch is different model.
double integerTolerance_
Integer tolerance.
Definition: ClpNode.hpp:216
double * downPseudo_
Down pseudo costs.
Definition: ClpNode.hpp:222
virtual ~ClpHashValue()
Destructor.
int depth_
Relative depth.
Definition: ClpNode.hpp:159
int * numberUpInfeasible_
Number of times up infeasible.
Definition: ClpNode.hpp:234
int maximumIntegers_
Maximum Integers so far.
Definition: ClpNode.hpp:171
double smallChange_
Small chnage in branch.
Definition: ClpNode.hpp:220
ClpNode()
Default constructor.
int * pivotVariables_
Pivot variables for factorization.
Definition: ClpNode.hpp:149
ClpFactorization * factorization_
Factorization.
Definition: ClpNode.hpp:135
int numberInfeasibilities() const
Number infeasibilities.
Definition: ClpNode.hpp:65
double sumInfeasibilities_
Sum of infeasibilities.
Definition: ClpNode.hpp:131
CoinHashLink * hash_
Hash table.
Definition: ClpNode.hpp:328
ClpNode ** nodeInfo_
Array of ClpNodes.
Definition: ClpNode.hpp:238
int * numberUp_
Number of times up.
Definition: ClpNode.hpp:230
int addValue(double value)
Add value to list and return index.
int nBound_
Number bounds in large model.
Definition: ClpNode.hpp:246
void createArrays(ClpSimplex *model)
Create odd arrays.
int numberBeforeTrust_
Number before trust from CbcModel.
Definition: ClpNode.hpp:261
int * priority_
Priority.
Definition: ClpNode.hpp:226
ClpDualRowSteepest * weights_
Steepest edge weights.
Definition: ClpNode.hpp:137
This just implements CoinFactorization when an ClpMatrixBase object is passed.
void chooseVariable(ClpSimplex *model, ClpNodeStuff *info)
Choose a new variable.
const double * dualSolution() const
Dual solution.
Definition: ClpNode.hpp:53
int maximumRows_
Maximum rows so far.
Definition: ClpNode.hpp:167
bool oddArraysExist() const
If odd arrays exist.
Definition: ClpNode.hpp:87
const double * primalSolution() const
Primal solution.
Definition: ClpNode.hpp:49
int presolveType_
Type of presolve - 0 none, 1 crunch.
Definition: ClpNode.hpp:273
int maximumNodes() const
Return maximum number of nodes.