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