1 | // Copyright (C) 2002, International Business Machines |
---|
2 | // Corporation and others. All Rights Reserved. |
---|
3 | #ifndef ClpPrimalcolumnPivot_H |
---|
4 | #define ClpPrimalcolumnPivot_H |
---|
5 | |
---|
6 | class ClpSimplex; |
---|
7 | class CoinIndexedVector; |
---|
8 | |
---|
9 | //############################################################################# |
---|
10 | |
---|
11 | /** Primal Column Pivot Abstract Base Class |
---|
12 | |
---|
13 | Abstract Base Class for describing an interface to an algorithm |
---|
14 | to choose column pivot in primal simplex algorithm. For some algorithms |
---|
15 | e.g. Dantzig choice then some functions may be null. For Dantzig |
---|
16 | the only one of any importance is pivotColumn. |
---|
17 | |
---|
18 | If you wish to inherit from this look at ClpPrimalColumnDantzig.cpp |
---|
19 | as that is simplest version. |
---|
20 | */ |
---|
21 | |
---|
22 | class ClpPrimalColumnPivot { |
---|
23 | |
---|
24 | public: |
---|
25 | |
---|
26 | ///@name Algorithmic methods |
---|
27 | //@{ |
---|
28 | |
---|
29 | /** Returns pivot column, -1 if none |
---|
30 | |
---|
31 | Normally updates reduced costs using result of last iteration |
---|
32 | before selecting incoming column. |
---|
33 | |
---|
34 | The Packed CoinIndexedVector updates has cost updates - for normal LP |
---|
35 | that is just +-weight where a feasibility changed. It also has |
---|
36 | reduced cost from last iteration in pivot row |
---|
37 | |
---|
38 | Inside pivotColumn the pivotRow_ and reduced cost from last iteration |
---|
39 | are also used. |
---|
40 | |
---|
41 | So in the simplest case i.e. feasible we compute the row of the |
---|
42 | tableau corresponding to last pivot and add a multiple of this |
---|
43 | to current reduced costs. |
---|
44 | |
---|
45 | We can use other arrays to help updates |
---|
46 | */ |
---|
47 | virtual int pivotColumn(CoinIndexedVector * updates, |
---|
48 | CoinIndexedVector * spareRow1, |
---|
49 | CoinIndexedVector * spareRow2, |
---|
50 | CoinIndexedVector * spareColumn1, |
---|
51 | CoinIndexedVector * spareColumn2) = 0; |
---|
52 | |
---|
53 | /// Updates weights - part 1 (may be empty) |
---|
54 | virtual void updateWeights(CoinIndexedVector * input); |
---|
55 | |
---|
56 | /** Saves any weights round factorization as pivot rows may change |
---|
57 | Will be empty unless steepest edge (will save model) |
---|
58 | May also recompute infeasibility stuff |
---|
59 | 1) before factorization |
---|
60 | 2) after good factorization (if weights empty may initialize) |
---|
61 | 3) after something happened but no factorization |
---|
62 | (e.g. check for infeasible) |
---|
63 | 4) as 2 but restore weights from previous snapshot |
---|
64 | 5) forces some initialization e.g. weights |
---|
65 | Also sets model |
---|
66 | */ |
---|
67 | virtual void saveWeights(ClpSimplex * model,int mode)=0; |
---|
68 | /** Signals pivot row choice: |
---|
69 | -2 (default) - use normal pivot row choice |
---|
70 | -1 to numberRows-1 - use this (will be checked) |
---|
71 | way should be -1 to go to lower bound, +1 to upper bound |
---|
72 | */ |
---|
73 | virtual int pivotRow(double & way) |
---|
74 | {way=0;return -2;} |
---|
75 | /// Gets rid of all arrays (may be empty) |
---|
76 | virtual void clearArrays(); |
---|
77 | /// Returns true if would not find any column |
---|
78 | virtual bool looksOptimal() const |
---|
79 | { return looksOptimal_;} |
---|
80 | /// Sets optimality flag (for advanced use) |
---|
81 | virtual void setLooksOptimal(bool flag) |
---|
82 | { looksOptimal_ = flag;} |
---|
83 | //@} |
---|
84 | |
---|
85 | |
---|
86 | ///@name Constructors and destructors |
---|
87 | //@{ |
---|
88 | /// Default Constructor |
---|
89 | ClpPrimalColumnPivot(); |
---|
90 | |
---|
91 | /// Copy constructor |
---|
92 | ClpPrimalColumnPivot(const ClpPrimalColumnPivot &); |
---|
93 | |
---|
94 | /// Assignment operator |
---|
95 | ClpPrimalColumnPivot & operator=(const ClpPrimalColumnPivot& rhs); |
---|
96 | |
---|
97 | /// Destructor |
---|
98 | virtual ~ClpPrimalColumnPivot (); |
---|
99 | |
---|
100 | /// Clone |
---|
101 | virtual ClpPrimalColumnPivot * clone(bool copyData = true) const = 0; |
---|
102 | |
---|
103 | //@} |
---|
104 | |
---|
105 | ///@name Other |
---|
106 | //@{ |
---|
107 | /// Returns model |
---|
108 | inline ClpSimplex * model() |
---|
109 | { return model_;} |
---|
110 | |
---|
111 | /// Returns type (above 63 is extra information) |
---|
112 | inline int type() |
---|
113 | { return type_;} |
---|
114 | |
---|
115 | /** Returns number of extra columns for sprint algorithm - 0 means off. |
---|
116 | Also number of iterations before recompute |
---|
117 | */ |
---|
118 | virtual int numberSprintColumns(int & numberIterations) const; |
---|
119 | /// Switch off sprint idea |
---|
120 | virtual void switchOffSprint(); |
---|
121 | /// Called when maximum pivots changes |
---|
122 | virtual void maximumPivotsChanged() {} |
---|
123 | |
---|
124 | //@} |
---|
125 | |
---|
126 | //--------------------------------------------------------------------------- |
---|
127 | |
---|
128 | protected: |
---|
129 | ///@name Protected member data |
---|
130 | //@{ |
---|
131 | /// Pointer to model |
---|
132 | ClpSimplex * model_; |
---|
133 | /// Type of column pivot algorithm |
---|
134 | int type_; |
---|
135 | /// Says if looks optimal (normally computed) |
---|
136 | bool looksOptimal_; |
---|
137 | //@} |
---|
138 | }; |
---|
139 | |
---|
140 | #endif |
---|