1 | //Edwin 11/17/2009 - carved out of CbcBranchLotsize |
---|
2 | #ifndef CbcLotsize_H |
---|
3 | #define CbcLotsize_H |
---|
4 | |
---|
5 | #include "CbcBranchBase.hpp" |
---|
6 | /** Lotsize class */ |
---|
7 | |
---|
8 | |
---|
9 | class CbcLotsize : public CbcObject { |
---|
10 | |
---|
11 | public: |
---|
12 | |
---|
13 | // Default Constructor |
---|
14 | CbcLotsize (); |
---|
15 | |
---|
16 | /* Useful constructor - passed model index. |
---|
17 | Also passed valid values - if range then pairs |
---|
18 | */ |
---|
19 | CbcLotsize (CbcModel * model, int iColumn, |
---|
20 | int numberPoints, const double * points, bool range = false); |
---|
21 | |
---|
22 | // Copy constructor |
---|
23 | CbcLotsize ( const CbcLotsize &); |
---|
24 | |
---|
25 | /// Clone |
---|
26 | virtual CbcObject * clone() const; |
---|
27 | |
---|
28 | // Assignment operator |
---|
29 | CbcLotsize & operator=( const CbcLotsize& rhs); |
---|
30 | |
---|
31 | // Destructor |
---|
32 | ~CbcLotsize (); |
---|
33 | |
---|
34 | /// Infeasibility - large is 0.5 |
---|
35 | virtual double infeasibility(const OsiBranchingInformation * info, |
---|
36 | int &preferredWay) const; |
---|
37 | |
---|
38 | using CbcObject::feasibleRegion ; |
---|
39 | /** Set bounds to contain the current solution. |
---|
40 | |
---|
41 | More precisely, for the variable associated with this object, take the |
---|
42 | value given in the current solution, force it within the current bounds |
---|
43 | if required, then set the bounds to fix the variable at the integer |
---|
44 | nearest the solution value. |
---|
45 | */ |
---|
46 | virtual void feasibleRegion(); |
---|
47 | |
---|
48 | /// Creates a branching object |
---|
49 | virtual CbcBranchingObject * createCbcBranch(OsiSolverInterface * solver, const OsiBranchingInformation * info, int way) ; |
---|
50 | |
---|
51 | /** \brief Given a valid solution (with reduced costs, etc.), |
---|
52 | return a branching object which would give a new feasible |
---|
53 | point in the good direction. |
---|
54 | |
---|
55 | The preferred branching object will force the variable to be +/-1 from |
---|
56 | its current value, depending on the reduced cost and objective sense. If |
---|
57 | movement in the direction which improves the objective is impossible due |
---|
58 | to bounds on the variable, the branching object will move in the other |
---|
59 | direction. If no movement is possible, the method returns NULL. |
---|
60 | |
---|
61 | Only the bounds on this variable are considered when determining if the new |
---|
62 | point is feasible. |
---|
63 | */ |
---|
64 | virtual CbcBranchingObject * preferredNewFeasible() const; |
---|
65 | |
---|
66 | /** \brief Given a valid solution (with reduced costs, etc.), |
---|
67 | return a branching object which would give a new feasible |
---|
68 | point in a bad direction. |
---|
69 | |
---|
70 | As for preferredNewFeasible(), but the preferred branching object will |
---|
71 | force movement in a direction that degrades the objective. |
---|
72 | */ |
---|
73 | virtual CbcBranchingObject * notPreferredNewFeasible() const ; |
---|
74 | |
---|
75 | /** Reset original upper and lower bound values from the solver. |
---|
76 | |
---|
77 | Handy for updating bounds held in this object after bounds held in the |
---|
78 | solver have been tightened. |
---|
79 | */ |
---|
80 | virtual void resetBounds(const OsiSolverInterface * solver); |
---|
81 | |
---|
82 | /** Finds range of interest so value is feasible in range range_ or infeasible |
---|
83 | between hi[range_] and lo[range_+1]. Returns true if feasible. |
---|
84 | */ |
---|
85 | bool findRange(double value) const; |
---|
86 | |
---|
87 | /** Returns floor and ceiling |
---|
88 | */ |
---|
89 | virtual void floorCeiling(double & floorLotsize, double & ceilingLotsize, double value, |
---|
90 | double tolerance) const; |
---|
91 | |
---|
92 | /// Model column number |
---|
93 | inline int modelSequence() const { |
---|
94 | return columnNumber_; |
---|
95 | } |
---|
96 | /// Set model column number |
---|
97 | inline void setModelSequence(int value) { |
---|
98 | columnNumber_ = value; |
---|
99 | } |
---|
100 | |
---|
101 | /** Column number if single column object -1 otherwise, |
---|
102 | so returns >= 0 |
---|
103 | Used by heuristics |
---|
104 | */ |
---|
105 | virtual int columnNumber() const; |
---|
106 | /// Original bounds |
---|
107 | inline double originalLowerBound() const { |
---|
108 | return bound_[0]; |
---|
109 | } |
---|
110 | inline double originalUpperBound() const { |
---|
111 | return bound_[rangeType_*numberRanges_-1]; |
---|
112 | } |
---|
113 | /// Type - 1 points, 2 ranges |
---|
114 | inline int rangeType() const { |
---|
115 | return rangeType_; |
---|
116 | } |
---|
117 | /// Number of points |
---|
118 | inline int numberRanges() const { |
---|
119 | return numberRanges_; |
---|
120 | } |
---|
121 | /// Ranges |
---|
122 | inline double * bound() const { |
---|
123 | return bound_; |
---|
124 | } |
---|
125 | /** \brief Return true if object can take part in normal heuristics |
---|
126 | */ |
---|
127 | virtual bool canDoHeuristics() const { |
---|
128 | return false; |
---|
129 | } |
---|
130 | |
---|
131 | private: |
---|
132 | /// Just for debug (CBC_PRINT defined in CbcBranchLotsize.cpp) |
---|
133 | void printLotsize(double value, bool condition, int type) const; |
---|
134 | |
---|
135 | private: |
---|
136 | /// data |
---|
137 | |
---|
138 | /// Column number in model |
---|
139 | int columnNumber_; |
---|
140 | /// Type - 1 points, 2 ranges |
---|
141 | int rangeType_; |
---|
142 | /// Number of points |
---|
143 | int numberRanges_; |
---|
144 | // largest gap |
---|
145 | double largestGap_; |
---|
146 | /// Ranges |
---|
147 | double * bound_; |
---|
148 | /// Current range |
---|
149 | mutable int range_; |
---|
150 | }; |
---|
151 | |
---|
152 | #endif |
---|