Ignore:
Timestamp:
Dec 30, 2010 12:45:15 PM (9 years ago)
Author:
forrest
Message:

add some heuristic variants

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Cbc/src/CbcHeuristicGreedy.hpp

    r1432 r1564  
    186186};
    187187
     188/** Greedy heuristic for SOS and L rows (and positive elements)
     189 */
     190
     191class CbcHeuristicGreedySOS : public CbcHeuristic {
     192public:
     193
     194    // Default Constructor
     195    CbcHeuristicGreedySOS ();
     196
     197    /* Constructor with model - assumed before cuts
     198       Initial version does not do Lps
     199    */
     200    CbcHeuristicGreedySOS (CbcModel & model);
     201
     202    // Copy constructor
     203    CbcHeuristicGreedySOS ( const CbcHeuristicGreedySOS &);
     204
     205    // Destructor
     206    ~CbcHeuristicGreedySOS ();
     207
     208    /// Clone
     209    virtual CbcHeuristic * clone() const;
     210    /// Assignment operator
     211    CbcHeuristicGreedySOS & operator=(const CbcHeuristicGreedySOS& rhs);
     212    /// Create C++ lines to get to current state
     213    virtual void generateCpp( FILE * fp) ;
     214
     215    /// update model (This is needed if cliques update matrix etc)
     216    virtual void setModel(CbcModel * model);
     217
     218    using CbcHeuristic::solution ;
     219    /** returns 0 if no solution, 1 if valid solution.
     220        Sets solution values if good, sets objective value (only if good)
     221        We leave all variables which are at one at this node of the
     222        tree to that value and will
     223        initially set all others to zero.  We then sort all variables in order of their cost
     224        divided by the number of entries in rows which are not yet covered.  We randomize that
     225        value a bit so that ties will be broken in different ways on different runs of the heuristic.
     226        We then choose the best one and set it to one and repeat the exercise.
     227
     228    */
     229    virtual int solution(double & objectiveValue,
     230                         double * newSolution);
     231    /// Validate model i.e. sets when_ to 0 if necessary (may be NULL)
     232    virtual void validate() ;
     233    /// Resets stuff if model changes
     234    virtual void resetModel(CbcModel * model);
     235    /* Algorithm
     236       Bits
     237       1 bit - use current model, otherwise original
     238       2 - use current solution as starting point, otherwise pure greedy
     239       4 - use duals to modify greedy
     240       8 - use duals on GUB/SOS in special way
     241    */
     242    inline int algorithm() const {
     243        return algorithm_;
     244    }
     245    inline void setAlgorithm(int value) {
     246        algorithm_ = value;
     247    }
     248    // Only do this many times
     249    inline int numberTimes() const {
     250        return numberTimes_;
     251    }
     252    inline void setNumberTimes(int value) {
     253        numberTimes_ = value;
     254    }
     255
     256protected:
     257    /// Guts of constructor from a CbcModel
     258    void gutsOfConstructor(CbcModel * model);
     259    // Data
     260
     261    // Original RHS - if -1.0 then SOS otherwise <= value
     262    double * originalRhs_;
     263    // Original matrix by column
     264    CoinPackedMatrix matrix_;
     265    // original number of rows
     266    int originalNumberRows_;
     267    /* Algorithm
     268    */
     269    int algorithm_;
     270    /// Do this many times
     271    int numberTimes_;
     272
     273};
     274
    188275
    189276#endif
Note: See TracChangeset for help on using the changeset viewer.