Ignore:
Timestamp:
Dec 3, 2009 3:48:32 PM (10 years ago)
Author:
EdwinStraver
Message:

Combined CbcGeneralDepth?, CbcGeneralBranchingObject? and CbcOneGeneralBranchingObject?

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/sandbox/Cbc/src/CbcGeneralDepth.hpp

    r1293 r1346  
    44
    55#include "CbcGeneral.hpp"
     6#include "CbcBranchBase.hpp"
     7#include "CbcSubProblem.hpp"
    68
    79#ifdef COIN_HAS_CLP
     
    8890    mutable ClpNodeStuff * nodeInfo_;
    8991};
     92/** Branching object for general objects
     93
     94 */
     95class CbcNode;
     96class CbcGeneralBranchingObject : public CbcBranchingObject {
     97
     98public:
     99
     100    // Default Constructor
     101    CbcGeneralBranchingObject ();
     102
     103    // Useful constructor
     104    CbcGeneralBranchingObject (CbcModel * model);
     105
     106    // Copy constructor
     107    CbcGeneralBranchingObject ( const CbcGeneralBranchingObject &);
     108
     109    // Assignment operator
     110    CbcGeneralBranchingObject & operator=( const CbcGeneralBranchingObject& rhs);
     111
     112    /// Clone
     113    virtual CbcBranchingObject * clone() const;
     114
     115    // Destructor
     116    virtual ~CbcGeneralBranchingObject ();
     117
     118    using CbcBranchingObject::branch ;
     119    /// Does next branch and updates state
     120    virtual double branch();
     121    /** Double checks in case node can change its mind!
     122        Can change objective etc */
     123    virtual void checkIsCutoff(double cutoff);
     124
     125    using CbcBranchingObject::print ;
     126    /** \brief Print something about branch - only if log level high
     127    */
     128    virtual void print();
     129    /// Fill in current objective etc
     130    void state(double & objectiveValue, double & sumInfeasibilities,
     131               int & numberUnsatisfied, int which) const;
     132    /// Set CbcNode
     133    inline void setNode(CbcNode * node) {
     134        node_ = node;
     135    }
     136    /** Return the type (an integer identifier) of \c this */
     137    virtual int type() const {
     138        return 108;
     139    }
     140
     141    /** Compare the original object of \c this with the original object of \c
     142        brObj. Assumes that there is an ordering of the original objects.
     143        This method should be invoked only if \c this and brObj are of the same
     144        type.
     145        Return negative/0/positive depending on whether \c this is
     146        smaller/same/larger than the argument.
     147    */
     148    virtual int compareOriginalObject(const CbcBranchingObject* brObj) const;
     149
     150    /** Compare the \c this with \c brObj. \c this and \c brObj must be os the
     151        same type and must have the same original object, but they may have
     152        different feasible regions.
     153        Return the appropriate CbcRangeCompare value (first argument being the
     154        sub/superset if that's the case). In case of overlap (and if \c
     155        replaceIfOverlap is true) replace the current branching object with one
     156        whose feasible region is the overlap.
     157     */
     158    virtual CbcRangeCompare compareBranchingObject
     159    (const CbcBranchingObject* brObj, const bool replaceIfOverlap = false);
     160    /// Number of subproblems
     161    inline int numberSubProblems() const {
     162        return numberSubProblems_;
     163    }
     164    /// Decrement number left and return number
     165    inline int decrementNumberLeft() {
     166        numberSubLeft_--;
     167        return numberSubLeft_;
     168    }
     169    /// Which node we want to use
     170    inline int whichNode() const {
     171        return whichNode_;
     172    }
     173    /// Set which node we want to use
     174    inline void setWhichNode(int value) {
     175        whichNode_ = value;
     176    }
     177    // Sub problem
     178    const CbcSubProblem * subProblem(int which) const {
     179        return subProblems_ + which;
     180    }
     181
     182public:
     183    /// data
     184    // Sub problems
     185    CbcSubProblem * subProblems_;
     186    /// Node
     187    CbcNode * node_;
     188    /// Number of subproblems
     189    int numberSubProblems_;
     190    /// Number of subproblems left
     191    int numberSubLeft_;
     192    /// Which node we want to use (-1 for default)
     193    int whichNode_;
     194    /// Number of rows
     195    int numberRows_;
     196};
     197/** Branching object for general objects - just one
     198
     199 */
     200class CbcOneGeneralBranchingObject : public CbcBranchingObject {
     201
     202public:
     203
     204    // Default Constructor
     205    CbcOneGeneralBranchingObject ();
     206
     207    // Useful constructor
     208    CbcOneGeneralBranchingObject (CbcModel * model,
     209                                  CbcGeneralBranchingObject * object,
     210                                  int whichOne);
     211
     212    // Copy constructor
     213    CbcOneGeneralBranchingObject ( const CbcOneGeneralBranchingObject &);
     214
     215    // Assignment operator
     216    CbcOneGeneralBranchingObject & operator=( const CbcOneGeneralBranchingObject& rhs);
     217
     218    /// Clone
     219    virtual CbcBranchingObject * clone() const;
     220
     221    // Destructor
     222    virtual ~CbcOneGeneralBranchingObject ();
     223
     224    using CbcBranchingObject::branch ;
     225    /// Does next branch and updates state
     226    virtual double branch();
     227    /** Double checks in case node can change its mind!
     228        Can change objective etc */
     229    virtual void checkIsCutoff(double cutoff);
     230
     231    using CbcBranchingObject::print ;
     232    /** \brief Print something about branch - only if log level high
     233    */
     234    virtual void print();
     235    /** Return the type (an integer identifier) of \c this */
     236    virtual int type() const {
     237        return 110;
     238    }
     239
     240    /** Compare the original object of \c this with the original object of \c
     241        brObj. Assumes that there is an ordering of the original objects.
     242        This method should be invoked only if \c this and brObj are of the same
     243        type.
     244        Return negative/0/positive depending on whether \c this is
     245        smaller/same/larger than the argument.
     246    */
     247    virtual int compareOriginalObject(const CbcBranchingObject* brObj) const;
     248
     249    /** Compare the \c this with \c brObj. \c this and \c brObj must be os the
     250        same type and must have the same original object, but they may have
     251        different feasible regions.
     252        Return the appropriate CbcRangeCompare value (first argument being the
     253        sub/superset if that's the case). In case of overlap (and if \c
     254        replaceIfOverlap is true) replace the current branching object with one
     255        whose feasible region is the overlap.
     256     */
     257    virtual CbcRangeCompare compareBranchingObject
     258    (const CbcBranchingObject* brObj, const bool replaceIfOverlap = false);
     259
     260public:
     261    /// data
     262    /// Object
     263    CbcGeneralBranchingObject * object_;
     264    /// Which one
     265    int whichOne_;
     266};
    90267#endif //COIN_HAS_CLP
    91268#endif
Note: See TracChangeset for help on using the changeset viewer.