1 | // Copyright (C) 2006, International Business Machines |
---|
2 | // Corporation and others. All Rights Reserved. |
---|
3 | #ifndef CbcBranchLotsizeSimple_H |
---|
4 | #define CbcBranchLotsizeSimple_H |
---|
5 | |
---|
6 | #include "CbcBranchBase.hpp" |
---|
7 | |
---|
8 | /** LotsizeSimple class |
---|
9 | This is just the lotsize class restricted to points not ranges |
---|
10 | and with debug etc taken out |
---|
11 | */ |
---|
12 | |
---|
13 | |
---|
14 | class CbcLotsizeSimple : public CbcObject { |
---|
15 | |
---|
16 | public: |
---|
17 | |
---|
18 | // Default Constructor |
---|
19 | CbcLotsizeSimple (); |
---|
20 | |
---|
21 | /* Useful constructor - passed model index. |
---|
22 | Also passed valid values |
---|
23 | */ |
---|
24 | CbcLotsizeSimple (CbcModel * model, int iColumn, |
---|
25 | int numberPoints, const double * points); |
---|
26 | |
---|
27 | // Copy constructor |
---|
28 | CbcLotsizeSimple ( const CbcLotsizeSimple & rhs); |
---|
29 | |
---|
30 | /// Clone |
---|
31 | virtual CbcObject * clone() const; |
---|
32 | |
---|
33 | // Assignment operator |
---|
34 | CbcLotsizeSimple & operator=( const CbcLotsizeSimple& rhs); |
---|
35 | |
---|
36 | // Destructor |
---|
37 | ~CbcLotsizeSimple (); |
---|
38 | |
---|
39 | /// Infeasibility - large is 0.5 |
---|
40 | virtual double infeasibility(int & preferredWay) const; |
---|
41 | |
---|
42 | /** Set bounds to contain the current solution. |
---|
43 | |
---|
44 | More precisely, for the variable associated with this object, take the |
---|
45 | value given in the current solution, force it within the current bounds |
---|
46 | if required, then set the bounds to fix the variable at the integer |
---|
47 | nearest the solution value. |
---|
48 | */ |
---|
49 | virtual void feasibleRegion(); |
---|
50 | |
---|
51 | /// Creates a branching object |
---|
52 | virtual CbcBranchingObject * createBranch(int way) ; |
---|
53 | |
---|
54 | /// Model column number |
---|
55 | inline int modelSequence() const |
---|
56 | {return columnNumber_;}; |
---|
57 | |
---|
58 | /** Column number if single column object -1 otherwise, |
---|
59 | so returns >= 0 |
---|
60 | Used by heuristics |
---|
61 | */ |
---|
62 | virtual int columnNumber() const |
---|
63 | {return columnNumber_;}; |
---|
64 | /// Original bounds |
---|
65 | inline double originalLowerBound() const |
---|
66 | { return bound_[0];}; |
---|
67 | inline double originalUpperBound() const |
---|
68 | { return bound_[numberRanges_-1];}; |
---|
69 | /// Number of points |
---|
70 | inline int numberRanges() const |
---|
71 | { return numberRanges_;}; |
---|
72 | /// Ranges |
---|
73 | inline double * bound() const |
---|
74 | { return bound_;}; |
---|
75 | |
---|
76 | /** Finds range of interest so value is feasible in range range_ or infeasible |
---|
77 | between bound_[range_] and bound_[range_+1]. Returns true if feasible. |
---|
78 | */ |
---|
79 | bool findRange(double value) const; |
---|
80 | |
---|
81 | /** Returns floor and ceiling |
---|
82 | */ |
---|
83 | virtual void floorCeiling(double & floorLotsizeSimple, double & ceilingLotsizeSimple, double value, |
---|
84 | double tolerance) const; |
---|
85 | /// Simple function to return a solution value strictly feasible |
---|
86 | double cleanValue() const; |
---|
87 | protected: |
---|
88 | /// data |
---|
89 | |
---|
90 | /// Column number in model |
---|
91 | int columnNumber_; |
---|
92 | /// Number of points |
---|
93 | int numberRanges_; |
---|
94 | // largest gap (used for normalizing infeasibility reporting) |
---|
95 | double largestGap_; |
---|
96 | /// Ranges |
---|
97 | double * bound_; |
---|
98 | /// Current range |
---|
99 | mutable int range_; |
---|
100 | }; |
---|
101 | |
---|
102 | |
---|
103 | /** LotsizeSimple branching object |
---|
104 | |
---|
105 | This object can specify a two-way branch on an integer variable. For each |
---|
106 | arm of the branch, the upper and lower bounds on the variable can be |
---|
107 | independently specified. |
---|
108 | |
---|
109 | Variable_ holds the index of the integer variable in the integerVariable_ |
---|
110 | array of the model. |
---|
111 | */ |
---|
112 | |
---|
113 | class CbcLotsizeSimpleBranchingObject : public CbcBranchingObject { |
---|
114 | |
---|
115 | public: |
---|
116 | |
---|
117 | /// Default constructor |
---|
118 | CbcLotsizeSimpleBranchingObject (); |
---|
119 | |
---|
120 | /** Create a lotsize floor/ceiling branch object |
---|
121 | |
---|
122 | Specifies a simple two-way branch. Let \p value = x*. One arm of the |
---|
123 | branch will be is lb <= x <= valid range below(x*), the other valid range above(x*) <= x <= ub. |
---|
124 | Specify way = -1 to set the object state to perform the down arm first, |
---|
125 | way = 1 for the up arm. |
---|
126 | */ |
---|
127 | CbcLotsizeSimpleBranchingObject (CbcModel *model, int variable, |
---|
128 | int way , double value,const CbcLotsizeSimple * lotsize) ; |
---|
129 | |
---|
130 | /// Copy constructor |
---|
131 | CbcLotsizeSimpleBranchingObject ( const CbcLotsizeSimpleBranchingObject &); |
---|
132 | |
---|
133 | /// Assignment operator |
---|
134 | CbcLotsizeSimpleBranchingObject & operator= (const CbcLotsizeSimpleBranchingObject& rhs); |
---|
135 | |
---|
136 | /// Clone |
---|
137 | virtual CbcBranchingObject * clone() const; |
---|
138 | |
---|
139 | /// Destructor |
---|
140 | virtual ~CbcLotsizeSimpleBranchingObject (); |
---|
141 | |
---|
142 | /** \brief Sets the bounds for the variable according to the current arm |
---|
143 | of the branch and advances the object state to the next arm. |
---|
144 | */ |
---|
145 | virtual double branch(bool normalBranch=false); |
---|
146 | |
---|
147 | protected: |
---|
148 | /// Lower [0] and upper [1] bounds for the down arm (way_ = -1) |
---|
149 | double down_[2]; |
---|
150 | /// Lower [0] and upper [1] bounds for the up arm (way_ = 1) |
---|
151 | double up_[2]; |
---|
152 | }; |
---|
153 | |
---|
154 | |
---|
155 | #endif |
---|