Ignore:
Timestamp:
Feb 26, 2010 12:27:59 PM (10 years ago)
Author:
mjs
Message:

Formatted .cpp, .hpp, .c, .h files with "astyle -A4 -p". This matches the formatting used in the grand CBC reorganization.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Clp/src/ClpNode.hpp

    r1502 r1525  
    1818
    1919public:
    20     /**@name Useful methods */
    21     //@{
    22     /** Applies node to model
    23         0 - just tree bounds
    24         1 - tree bounds and basis etc
    25         2 - saved bounds and basis etc
    26     */
    27     void applyNode(ClpSimplex * model, int doBoundsEtc );
    28     /// Choose a new variable
    29     void chooseVariable(ClpSimplex * model, ClpNodeStuff * info);
    30     /// Fix on reduced costs
    31     int fixOnReducedCosts(ClpSimplex * model);
    32     /// Create odd arrays
    33     void createArrays(ClpSimplex * model);
    34     /// Clean up as crunch is different model
    35     void cleanUpForCrunch();
    36     //@}
    37 
    38     /**@name Gets and sets */
    39     //@{
    40     /// Objective value
    41     inline double objectiveValue() const {
    42         return objectiveValue_;
    43     }
    44     /// Set objective value
    45     inline void setObjectiveValue(double value) {
    46         objectiveValue_ = value;
    47     }
    48     /// Primal solution
    49     inline const double * primalSolution() const {
    50         return primalSolution_;
    51     }
    52     /// Dual solution
    53     inline const double * dualSolution() const {
    54         return dualSolution_;
    55     }
    56     /// Initial value of integer variable
    57     inline double branchingValue() const {
    58         return branchingValue_;
    59     }
    60     /// Sum infeasibilities
    61     inline double sumInfeasibilities() const {
    62         return sumInfeasibilities_;
    63     }
    64     /// Number infeasibilities
    65     inline int numberInfeasibilities() const {
    66         return numberInfeasibilities_;
    67     }
    68     /// Relative depth
    69     inline int depth() const {
    70         return depth_;
    71     }
    72     /// Estimated solution value
    73     inline double estimatedSolution() const {
    74         return estimatedSolution_;
    75     }
    76     /** Way for integer variable -1 down , +1 up */
    77     int way() const;
    78     /// Return true if branch exhausted
    79     bool fathomed() const;
    80     /// Change state of variable i.e. go other way
    81     void changeState();
    82     /// Sequence number of integer variable (-1 if none)
    83     inline int sequence() const {
    84         return sequence_;
    85     }
    86     /// If odd arrays exist
    87     inline bool oddArraysExist() const {
    88         return lower_ != NULL;
    89     }
    90     /// Status array
    91     inline const unsigned char * statusArray() const {
    92         return status_;
    93     }
    94     //@}
    95 
    96     /**@name Constructors, destructor */
    97     //@{
    98     /** Default constructor. */
    99     ClpNode();
    100     /// Constructor from model
    101     ClpNode (ClpSimplex * model, const ClpNodeStuff * stuff, int depth);
    102     /// Does work of constructor (partly so gdb will work)
    103     void gutsOfConstructor(ClpSimplex * model, const ClpNodeStuff * stuff,
    104                            int arraysExist, int depth);
    105     /** Destructor */
    106     virtual ~ClpNode();
    107     //@}
    108 
    109     /**@name Copy methods (at present illegal - will abort) */
    110     //@{
    111     /** The copy constructor. */
    112     ClpNode(const ClpNode&);
    113     /// Operator =
    114     ClpNode& operator=(const ClpNode&);
    115     //@}
     20     /**@name Useful methods */
     21     //@{
     22     /** Applies node to model
     23         0 - just tree bounds
     24         1 - tree bounds and basis etc
     25         2 - saved bounds and basis etc
     26     */
     27     void applyNode(ClpSimplex * model, int doBoundsEtc );
     28     /// Choose a new variable
     29     void chooseVariable(ClpSimplex * model, ClpNodeStuff * info);
     30     /// Fix on reduced costs
     31     int fixOnReducedCosts(ClpSimplex * model);
     32     /// Create odd arrays
     33     void createArrays(ClpSimplex * model);
     34     /// Clean up as crunch is different model
     35     void cleanUpForCrunch();
     36     //@}
     37
     38     /**@name Gets and sets */
     39     //@{
     40     /// Objective value
     41     inline double objectiveValue() const {
     42          return objectiveValue_;
     43     }
     44     /// Set objective value
     45     inline void setObjectiveValue(double value) {
     46          objectiveValue_ = value;
     47     }
     48     /// Primal solution
     49     inline const double * primalSolution() const {
     50          return primalSolution_;
     51     }
     52     /// Dual solution
     53     inline const double * dualSolution() const {
     54          return dualSolution_;
     55     }
     56     /// Initial value of integer variable
     57     inline double branchingValue() const {
     58          return branchingValue_;
     59     }
     60     /// Sum infeasibilities
     61     inline double sumInfeasibilities() const {
     62          return sumInfeasibilities_;
     63     }
     64     /// Number infeasibilities
     65     inline int numberInfeasibilities() const {
     66          return numberInfeasibilities_;
     67     }
     68     /// Relative depth
     69     inline int depth() const {
     70          return depth_;
     71     }
     72     /// Estimated solution value
     73     inline double estimatedSolution() const {
     74          return estimatedSolution_;
     75     }
     76     /** Way for integer variable -1 down , +1 up */
     77     int way() const;
     78     /// Return true if branch exhausted
     79     bool fathomed() const;
     80     /// Change state of variable i.e. go other way
     81     void changeState();
     82     /// Sequence number of integer variable (-1 if none)
     83     inline int sequence() const {
     84          return sequence_;
     85     }
     86     /// If odd arrays exist
     87     inline bool oddArraysExist() const {
     88          return lower_ != NULL;
     89     }
     90     /// Status array
     91     inline const unsigned char * statusArray() const {
     92          return status_;
     93     }
     94     //@}
     95
     96     /**@name Constructors, destructor */
     97     //@{
     98     /** Default constructor. */
     99     ClpNode();
     100     /// Constructor from model
     101     ClpNode (ClpSimplex * model, const ClpNodeStuff * stuff, int depth);
     102     /// Does work of constructor (partly so gdb will work)
     103     void gutsOfConstructor(ClpSimplex * model, const ClpNodeStuff * stuff,
     104                            int arraysExist, int depth);
     105     /** Destructor */
     106     virtual ~ClpNode();
     107     //@}
     108
     109     /**@name Copy methods (at present illegal - will abort) */
     110     //@{
     111     /** The copy constructor. */
     112     ClpNode(const ClpNode&);
     113     /// Operator =
     114     ClpNode& operator=(const ClpNode&);
     115     //@}
    116116
    117117protected:
    118118// 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;
    124     /**@name Data */
    125     //@{
    126     /// Initial value of integer variable
    127     double branchingValue_;
    128     /// Value of objective
    129     double objectiveValue_;
    130     /// Sum of infeasibilities
    131     double sumInfeasibilities_;
    132     /// Estimated solution value
    133     double estimatedSolution_;
    134     /// Factorization
    135     ClpFactorization * factorization_;
    136     /// Steepest edge weights
    137     ClpDualRowSteepest * weights_;
    138     /// Status vector
    139     unsigned char * status_;
    140     /// Primal solution
    141     double * primalSolution_;
    142     /// Dual solution
    143     double * dualSolution_;
    144     /// Integer lower bounds (only used in fathomMany)
    145     int * lower_;
    146     /// Integer upper bounds (only used in fathomMany)
    147     int * upper_;
    148     /// Pivot variables for factorization
    149     int * pivotVariables_;
    150     /// Variables fixed by reduced costs (at end of branch) 0x10000000 added if fixed to UB
    151     int * fixed_;
    152     /// State of branch
    153     branchState branchState_;
    154     /// Sequence number of integer variable (-1 if none)
    155     int sequence_;
    156     /// Number of infeasibilities
    157     int numberInfeasibilities_;
    158     /// Relative depth
    159     int depth_;
    160     /// Number fixed by reduced cost
    161     int numberFixed_;
    162     /// Flags - 1 duals scaled
    163     int flags_;
    164     /// Maximum number fixed by reduced cost
    165     int maximumFixed_;
    166     /// Maximum rows so far
    167     int maximumRows_;
    168     /// Maximum columns so far
    169     int maximumColumns_;
    170     /// Maximum Integers so far
    171     int maximumIntegers_;
    172     //@}
     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;
     124     /**@name Data */
     125     //@{
     126     /// Initial value of integer variable
     127     double branchingValue_;
     128     /// Value of objective
     129     double objectiveValue_;
     130     /// Sum of infeasibilities
     131     double sumInfeasibilities_;
     132     /// Estimated solution value
     133     double estimatedSolution_;
     134     /// Factorization
     135     ClpFactorization * factorization_;
     136     /// Steepest edge weights
     137     ClpDualRowSteepest * weights_;
     138     /// Status vector
     139     unsigned char * status_;
     140     /// Primal solution
     141     double * primalSolution_;
     142     /// Dual solution
     143     double * dualSolution_;
     144     /// Integer lower bounds (only used in fathomMany)
     145     int * lower_;
     146     /// Integer upper bounds (only used in fathomMany)
     147     int * upper_;
     148     /// Pivot variables for factorization
     149     int * pivotVariables_;
     150     /// Variables fixed by reduced costs (at end of branch) 0x10000000 added if fixed to UB
     151     int * fixed_;
     152     /// State of branch
     153     branchState branchState_;
     154     /// Sequence number of integer variable (-1 if none)
     155     int sequence_;
     156     /// Number of infeasibilities
     157     int numberInfeasibilities_;
     158     /// Relative depth
     159     int depth_;
     160     /// Number fixed by reduced cost
     161     int numberFixed_;
     162     /// Flags - 1 duals scaled
     163     int flags_;
     164     /// Maximum number fixed by reduced cost
     165     int maximumFixed_;
     166     /// Maximum rows so far
     167     int maximumRows_;
     168     /// Maximum columns so far
     169     int maximumColumns_;
     170     /// Maximum Integers so far
     171     int maximumIntegers_;
     172     //@}
    173173};
    174174class ClpNodeStuff {
    175175
    176176public:
    177     /**@name Constructors, destructor */
    178     //@{
    179     /** Default constructor. */
    180     ClpNodeStuff();
    181     /** Destructor */
    182     virtual ~ClpNodeStuff();
    183     //@}
    184 
    185     /**@name Copy methods (only copies ints etc, nulls arrays) */
    186     //@{
    187     /** The copy constructor. */
    188     ClpNodeStuff(const ClpNodeStuff&);
    189     /// Operator =
    190     ClpNodeStuff& operator=(const ClpNodeStuff&);
    191     /// Zaps stuff 1 - arrays, 2 ints, 3 both
    192     void zap(int type);
    193     //@}
    194 
    195 
    196     /**@name Fill methods */
    197     //@{
    198     /** Fill with pseudocosts */
    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);
    204     /// Update pseudo costs
    205     void update(int way, int sequence, double change, bool feasible);
    206     /// Return maximum number of nodes
    207     int maximumNodes() const;
    208     /// Return maximum space for nodes
    209     int maximumSpace() const;
    210     //@}
     177     /**@name Constructors, destructor */
     178     //@{
     179     /** Default constructor. */
     180     ClpNodeStuff();
     181     /** Destructor */
     182     virtual ~ClpNodeStuff();
     183     //@}
     184
     185     /**@name Copy methods (only copies ints etc, nulls arrays) */
     186     //@{
     187     /** The copy constructor. */
     188     ClpNodeStuff(const ClpNodeStuff&);
     189     /// Operator =
     190     ClpNodeStuff& operator=(const ClpNodeStuff&);
     191     /// Zaps stuff 1 - arrays, 2 ints, 3 both
     192     void zap(int type);
     193     //@}
     194
     195
     196     /**@name Fill methods */
     197     //@{
     198     /** Fill with pseudocosts */
     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);
     204     /// Update pseudo costs
     205     void update(int way, int sequence, double change, bool feasible);
     206     /// Return maximum number of nodes
     207     int maximumNodes() const;
     208     /// Return maximum space for nodes
     209     int maximumSpace() const;
     210     //@}
    211211
    212212public:
    213     /**@name Data */
    214     //@{
    215     /// Integer tolerance
    216     double integerTolerance_;
    217     /// Integer increment
    218     double integerIncrement_;
    219     /// Small chnage in branch
    220     double smallChange_;
    221     /// Down pseudo costs
    222     double * downPseudo_;
    223     /// Up pseudo costs
    224     double * upPseudo_;
    225     /// Priority
    226     int * priority_;
    227     /// Number of times down
    228     int * numberDown_;
    229     /// Number of times up
    230     int * numberUp_;
    231     /// Number of times down infeasible
    232     int * numberDownInfeasible_;
    233     /// Number of times up infeasible
    234     int * numberUpInfeasible_;
    235     /// Copy of costs (local)
    236     double * saveCosts_;
    237     /// Array of ClpNodes
    238     ClpNode ** nodeInfo_;
    239     /// Large model if crunched
    240     ClpSimplex * large_;
    241     /// Which rows in large model
    242     int * whichRow_;
    243     /// Which columns in large model
    244     int * whichColumn_;
    245     /// Number bounds in large model
    246     int nBound_;
    247     /// Save of specialOptions_ (local)
    248     int saveOptions_;
    249     /** Options to pass to solver
    250         1 - create external reduced costs for columns
    251         2 - create external reduced costs for rows
    252         4 - create external row activity (columns always done)
    253         Above only done if feasible
    254         32 - just create up to nDepth_+1 nodes
    255         65536 - set if activated
    256     */
    257     int solverOptions_;
    258     /// Maximum number of nodes to do
    259     int maximumNodes_;
    260     /// Number before trust from CbcModel
    261     int numberBeforeTrust_;
    262     /// State of search from CbcModel
    263     int stateOfSearch_;
    264     /// Number deep
    265     int nDepth_;
    266     /// Number nodes returned (-1 if fathom aborted)
    267     int nNodes_;
    268     /// Number of nodes explored
    269     int numberNodesExplored_;
    270     /// Number of iterations
    271     int numberIterations_;
    272     /// Type of presolve - 0 none, 1 crunch
    273     int presolveType_;
    274     //@}
     213     /**@name Data */
     214     //@{
     215     /// Integer tolerance
     216     double integerTolerance_;
     217     /// Integer increment
     218     double integerIncrement_;
     219     /// Small chnage in branch
     220     double smallChange_;
     221     /// Down pseudo costs
     222     double * downPseudo_;
     223     /// Up pseudo costs
     224     double * upPseudo_;
     225     /// Priority
     226     int * priority_;
     227     /// Number of times down
     228     int * numberDown_;
     229     /// Number of times up
     230     int * numberUp_;
     231     /// Number of times down infeasible
     232     int * numberDownInfeasible_;
     233     /// Number of times up infeasible
     234     int * numberUpInfeasible_;
     235     /// Copy of costs (local)
     236     double * saveCosts_;
     237     /// Array of ClpNodes
     238     ClpNode ** nodeInfo_;
     239     /// Large model if crunched
     240     ClpSimplex * large_;
     241     /// Which rows in large model
     242     int * whichRow_;
     243     /// Which columns in large model
     244     int * whichColumn_;
     245     /// Number bounds in large model
     246     int nBound_;
     247     /// Save of specialOptions_ (local)
     248     int saveOptions_;
     249     /** Options to pass to solver
     250         1 - create external reduced costs for columns
     251         2 - create external reduced costs for rows
     252         4 - create external row activity (columns always done)
     253         Above only done if feasible
     254         32 - just create up to nDepth_+1 nodes
     255         65536 - set if activated
     256     */
     257     int solverOptions_;
     258     /// Maximum number of nodes to do
     259     int maximumNodes_;
     260     /// Number before trust from CbcModel
     261     int numberBeforeTrust_;
     262     /// State of search from CbcModel
     263     int stateOfSearch_;
     264     /// Number deep
     265     int nDepth_;
     266     /// Number nodes returned (-1 if fathom aborted)
     267     int nNodes_;
     268     /// Number of nodes explored
     269     int numberNodesExplored_;
     270     /// Number of iterations
     271     int numberIterations_;
     272     /// Type of presolve - 0 none, 1 crunch
     273     int presolveType_;
     274     //@}
    275275};
    276276class ClpHashValue {
    277277
    278278public:
    279     /**@name Useful methods */
    280     //@{
    281     /// Return index or -1 if not found
    282     int index(double value) const;
    283     /// Add value to list and return index
    284     int addValue(double value) ;
    285     /// Number of different entries
    286     inline int numberEntries() const {
    287         return numberHash_;
    288     }
    289     //@}
    290 
    291     /**@name Constructors, destructor */
    292     //@{
    293     /** Default constructor. */
    294     ClpHashValue();
    295     /** Useful constructor. */
    296     ClpHashValue(ClpSimplex * model);
    297     /** Destructor */
    298     virtual ~ClpHashValue();
    299     //@}
    300 
    301     /**@name Copy method */
    302     //@{
    303     /** The copy constructor. */
    304     ClpHashValue(const ClpHashValue&);
    305     /// =
    306     ClpHashValue& operator=(const ClpHashValue&);
    307     //@}
     279     /**@name Useful methods */
     280     //@{
     281     /// Return index or -1 if not found
     282     int index(double value) const;
     283     /// Add value to list and return index
     284     int addValue(double value) ;
     285     /// Number of different entries
     286     inline int numberEntries() const {
     287          return numberHash_;
     288     }
     289     //@}
     290
     291     /**@name Constructors, destructor */
     292     //@{
     293     /** Default constructor. */
     294     ClpHashValue();
     295     /** Useful constructor. */
     296     ClpHashValue(ClpSimplex * model);
     297     /** Destructor */
     298     virtual ~ClpHashValue();
     299     //@}
     300
     301     /**@name Copy method */
     302     //@{
     303     /** The copy constructor. */
     304     ClpHashValue(const ClpHashValue&);
     305     /// =
     306     ClpHashValue& operator=(const ClpHashValue&);
     307     //@}
    308308private:
    309     /**@name private stuff */
    310     //@{
    311     /** returns hash */
    312     int hash(double value) const;
    313     /// Resizes
    314     void resize(bool increaseMax);
    315     //@}
     309     /**@name private stuff */
     310     //@{
     311     /** returns hash */
     312     int hash(double value) const;
     313     /// Resizes
     314     void resize(bool increaseMax);
     315     //@}
    316316
    317317protected:
    318     /**@name Data members
    319        The data members are protected to allow access for derived classes. */
    320     //@{
    321     /// Data
    322     // for hashing
    323     typedef struct {
    324         double value;
    325         int index, next;
    326     } CoinHashLink;
    327     /// Hash table
    328     mutable CoinHashLink *hash_;
    329     /// Number of entries in hash table
    330     int numberHash_;
    331     /// Maximum number of entries in hash table i.e. size
    332     int maxHash_;
    333     /// Last used space
    334     int lastUsed_;
    335     //@}
     318     /**@name Data members
     319        The data members are protected to allow access for derived classes. */
     320     //@{
     321     /// Data
     322     // for hashing
     323     typedef struct {
     324          double value;
     325          int index, next;
     326     } CoinHashLink;
     327     /// Hash table
     328     mutable CoinHashLink *hash_;
     329     /// Number of entries in hash table
     330     int numberHash_;
     331     /// Maximum number of entries in hash table i.e. size
     332     int maxHash_;
     333     /// Last used space
     334     int lastUsed_;
     335     //@}
    336336};
    337337#endif
Note: See TracChangeset for help on using the changeset viewer.