source: branches/sandbox/Cbc/src/CbcSOS.hpp @ 1293

Last change on this file since 1293 was 1293, checked in by EdwinStraver, 10 years ago
File size: 4.3 KB
Line 
1// Edwin 11/9/2009-- carved out of CbcBranchActual
2#ifndef CbcSOS_H
3#define CbcSOS_H
4
5/** Define Special Ordered Sets of type 1 and 2.  These do not have to be
6    integer - so do not appear in lists of integers.
7
8    which_ points directly to columns of matrix
9*/
10
11
12class CbcSOS : public CbcObject {
13
14public:
15
16    // Default Constructor
17    CbcSOS ();
18
19    /** Useful constructor - which are indices
20        and  weights are also given.  If null then 0,1,2..
21        type is SOS type
22    */
23    CbcSOS (CbcModel * model, int numberMembers,
24            const int * which, const double * weights, int identifier,
25            int type = 1);
26
27    // Copy constructor
28    CbcSOS ( const CbcSOS &);
29
30    /// Clone
31    virtual CbcObject * clone() const;
32
33    // Assignment operator
34    CbcSOS & operator=( const CbcSOS& rhs);
35
36    // Destructor
37    virtual ~CbcSOS ();
38
39    /// Infeasibility - large is 0.5
40    virtual double infeasibility(const OsiBranchingInformation * info,
41                                 int &preferredWay) const;
42
43    using CbcObject::feasibleRegion ;
44    /// This looks at solution and sets bounds to contain solution
45    virtual void feasibleRegion();
46
47    /// Creates a branching object
48    virtual CbcBranchingObject * createCbcBranch(OsiSolverInterface * solver, const OsiBranchingInformation * info, int way) ;
49
50
51
52    /** Pass in information on branch just done and create CbcObjectUpdateData instance.
53        If object does not need data then backward pointer will be NULL.
54        Assumes can get information from solver */
55    virtual CbcObjectUpdateData createUpdateInformation(const OsiSolverInterface * solver,
56            const CbcNode * node,
57            const CbcBranchingObject * branchingObject);
58    /// Update object by CbcObjectUpdateData
59    virtual void updateInformation(const CbcObjectUpdateData & data) ;
60    using CbcObject::solverBranch ;
61    /** Create an OsiSolverBranch object
62
63        This returns NULL if branch not represented by bound changes
64    */
65    virtual OsiSolverBranch * solverBranch() const;
66    /// Redoes data when sequence numbers change
67    virtual void redoSequenceEtc(CbcModel * model, int numberColumns, const int * originalColumns);
68
69    /// Construct an OsiSOS object
70    OsiSOS * osiObject(const OsiSolverInterface * solver) const;
71    /// Number of members
72    inline int numberMembers() const {
73        return numberMembers_;
74    }
75
76    /// Members (indices in range 0 ... numberColumns-1)
77    inline const int * members() const {
78        return members_;
79    }
80
81    /// SOS type
82    inline int sosType() const {
83        return sosType_;
84    }
85    /// Down number times
86    inline int numberTimesDown() const {
87        return numberTimesDown_;
88    }
89    /// Up number times
90    inline int numberTimesUp() const {
91        return numberTimesUp_;
92    }
93
94    /** Array of weights */
95    inline const double * weights() const {
96        return weights_;
97    }
98
99    /// Set number of members
100    inline void setNumberMembers(int n) {
101        numberMembers_ = n;
102    }
103
104    /// Members (indices in range 0 ... numberColumns-1)
105    inline int * mutableMembers() const {
106        return members_;
107    }
108
109    /** Array of weights */
110    inline double * mutableWeights() const {
111        return weights_;
112    }
113
114    /** \brief Return true if object can take part in normal heuristics
115    */
116    virtual bool canDoHeuristics() const {
117        return (sosType_ == 1 && integerValued_);
118    }
119    /// Set whether set is integer valued or not
120    inline void setIntegerValued(bool yesNo) {
121        integerValued_ = yesNo;
122    }
123private:
124    /// data
125
126    /// Members (indices in range 0 ... numberColumns-1)
127    int * members_;
128    /// Weights
129    double * weights_;
130    /// Current pseudo-shadow price estimate down
131    mutable double shadowEstimateDown_;
132    /// Current pseudo-shadow price estimate up
133    mutable double shadowEstimateUp_;
134    /// Down pseudo ratio
135    double downDynamicPseudoRatio_;
136    /// Up pseudo ratio
137    double upDynamicPseudoRatio_;
138    /// Number of times we have gone down
139    int numberTimesDown_;
140    /// Number of times we have gone up
141    int numberTimesUp_;
142    /// Number of members
143    int numberMembers_;
144    /// SOS type
145    int sosType_;
146    /// Whether integer valued
147    bool integerValued_;
148};
149#endif
Note: See TracBrowser for help on using the repository browser.