Clp trunk
ClpNode.hpp
Go to the documentation of this file.
00001 /* $Id$ */
00002 // Copyright (C) 2008, International Business Machines
00003 // Corporation and others.  All Rights Reserved.
00004 // This code is licensed under the terms of the Eclipse Public License (EPL).
00005 
00006 #ifndef ClpNode_H
00007 #define ClpNode_H
00008 
00009 #include "CoinPragma.hpp"
00010 
00011 // This implements all stuff for Clp fathom
00016 class ClpFactorization;
00017 class ClpDualRowSteepest;
00018 class ClpNodeStuff;
00019 class ClpNode {
00020 
00021 public:
00029      void applyNode(ClpSimplex * model, int doBoundsEtc );
00031      void chooseVariable(ClpSimplex * model, ClpNodeStuff * info);
00033      int fixOnReducedCosts(ClpSimplex * model);
00035      void createArrays(ClpSimplex * model);
00037      void cleanUpForCrunch();
00039 
00042 
00043      inline double objectiveValue() const {
00044           return objectiveValue_;
00045      }
00047      inline void setObjectiveValue(double value) {
00048           objectiveValue_ = value;
00049      }
00051      inline const double * primalSolution() const {
00052           return primalSolution_;
00053      }
00055      inline const double * dualSolution() const {
00056           return dualSolution_;
00057      }
00059      inline double branchingValue() const {
00060           return branchingValue_;
00061      }
00063      inline double sumInfeasibilities() const {
00064           return sumInfeasibilities_;
00065      }
00067      inline int numberInfeasibilities() const {
00068           return numberInfeasibilities_;
00069      }
00071      inline int depth() const {
00072           return depth_;
00073      }
00075      inline double estimatedSolution() const {
00076           return estimatedSolution_;
00077      }
00079      int way() const;
00081      bool fathomed() const;
00083      void changeState();
00085      inline int sequence() const {
00086           return sequence_;
00087      }
00089      inline bool oddArraysExist() const {
00090           return lower_ != NULL;
00091      }
00093      inline const unsigned char * statusArray() const {
00094           return status_;
00095      }
00097 
00101      ClpNode();
00103      ClpNode (ClpSimplex * model, const ClpNodeStuff * stuff, int depth);
00105      void gutsOfConstructor(ClpSimplex * model, const ClpNodeStuff * stuff,
00106                             int arraysExist, int depth);
00108      virtual ~ClpNode();
00110 
00114      ClpNode(const ClpNode&);
00116      ClpNode& operator=(const ClpNode&);
00118 
00119 protected:
00120 // For state of branch
00121      typedef struct {
00122           unsigned int firstBranch: 1; //  nonzero if first branch on variable is up
00123           unsigned int branch: 2; //  0 means do first branch next, 1 second, 2 finished
00124           unsigned int spare: 29;
00125      } branchState;
00128 
00129      double branchingValue_;
00131      double objectiveValue_;
00133      double sumInfeasibilities_;
00135      double estimatedSolution_;
00137      ClpFactorization * factorization_;
00139      ClpDualRowSteepest * weights_;
00141      unsigned char * status_;
00143      double * primalSolution_;
00145      double * dualSolution_;
00147      int * lower_;
00149      int * upper_;
00151      int * pivotVariables_;
00153      int * fixed_;
00155      branchState branchState_;
00157      int sequence_;
00159      int numberInfeasibilities_;
00161      int depth_;
00163      int numberFixed_;
00165      int flags_;
00167      int maximumFixed_;
00169      int maximumRows_;
00171      int maximumColumns_;
00173      int maximumIntegers_;
00175 };
00176 class ClpNodeStuff {
00177 
00178 public:
00182      ClpNodeStuff();
00184      virtual ~ClpNodeStuff();
00186 
00190      ClpNodeStuff(const ClpNodeStuff&);
00192      ClpNodeStuff& operator=(const ClpNodeStuff&);
00194      void zap(int type);
00196 
00197 
00201      void fillPseudoCosts(const double * down, const double * up,
00202                           const int * priority,
00203                           const int * numberDown, const int * numberUp,
00204                           const int * numberDownInfeasible, const int * numberUpInfeasible,
00205                           int number);
00207      void update(int way, int sequence, double change, bool feasible);
00209      int maximumNodes() const;
00211      int maximumSpace() const;
00213 
00214 public:
00217 
00218      double integerTolerance_;
00220      double integerIncrement_;
00222      double smallChange_;
00224      double * downPseudo_;
00226      double * upPseudo_;
00228      int * priority_;
00230      int * numberDown_;
00232      int * numberUp_;
00234      int * numberDownInfeasible_;
00236      int * numberUpInfeasible_;
00238      double * saveCosts_;
00240      ClpNode ** nodeInfo_;
00242      ClpSimplex * large_;
00244      int * whichRow_;
00246      int * whichColumn_;
00248      int nBound_;
00250      int saveOptions_;
00259      int solverOptions_;
00261      int maximumNodes_;
00263      int numberBeforeTrust_;
00265      int stateOfSearch_;
00267      int nDepth_;
00269      int nNodes_;
00271      int numberNodesExplored_;
00273      int numberIterations_;
00275      int presolveType_;
00277 };
00278 class ClpHashValue {
00279 
00280 public:
00283 
00284      int index(double value) const;
00286      int addValue(double value) ;
00288      inline int numberEntries() const {
00289           return numberHash_;
00290      }
00292 
00296      ClpHashValue();
00298      ClpHashValue(ClpSimplex * model);
00300      virtual ~ClpHashValue();
00302 
00306      ClpHashValue(const ClpHashValue&);
00308      ClpHashValue& operator=(const ClpHashValue&);
00310 private:
00314      int hash(double value) const;
00316      void resize(bool increaseMax);
00318 
00319 protected:
00323 
00324      // for hashing
00325      typedef struct {
00326           double value;
00327           int index, next;
00328      } CoinHashLink;
00330      mutable CoinHashLink *hash_;
00332      int numberHash_;
00334      int maxHash_;
00336      int lastUsed_;
00338 };
00339 #endif
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines