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 CoinIndexedVector updates has cost updates - for normal LP |
---|
35 | that is just +-weight where a feasibility changed. |
---|
36 | |
---|
37 | Inside pivotColumn the pivotRow_ and reduced cost from last iteration |
---|
38 | are also used. |
---|
39 | |
---|
40 | So in the simplest case i.e. feasible we compute the row of the |
---|
41 | tableau corresponding to last pivot and add a multiple of this |
---|
42 | to current reduced costs. |
---|
43 | |
---|
44 | We can use other arrays to help updates |
---|
45 | */ |
---|
46 | virtual int pivotColumn(CoinIndexedVector * updates, |
---|
47 | CoinIndexedVector * spareRow1, |
---|
48 | CoinIndexedVector * spareRow2, |
---|
49 | CoinIndexedVector * spareColumn1, |
---|
50 | CoinIndexedVector * spareColumn2) = 0; |
---|
51 | |
---|
52 | /// Updates weights - part 1 (may be empty) |
---|
53 | virtual void updateWeights(CoinIndexedVector * input); |
---|
54 | |
---|
55 | /** Saves any weights round factorization as pivot rows may change |
---|
56 | Will be empty unless steepest edge (will save model) |
---|
57 | May also recompute infeasibility stuff |
---|
58 | 1) before factorization |
---|
59 | 2) after good factorization (if weights empty may initialize) |
---|
60 | 3) after something happened but no factorization |
---|
61 | (e.g. check for infeasible) |
---|
62 | 4) as 2 but restore weights from previous snapshot |
---|
63 | 5) forces some initialization e.g. weights |
---|
64 | Also sets model |
---|
65 | */ |
---|
66 | virtual void saveWeights(ClpSimplex * model,int mode)=0; |
---|
67 | /** Signals pivot row choice: |
---|
68 | -2 (default) - use normal pivot row choice |
---|
69 | -1 to numberRows-1 - use this (will be checked) |
---|
70 | way should be -1 to go to lower bound, +1 to upper bound |
---|
71 | */ |
---|
72 | virtual int pivotRow(double & way) |
---|
73 | {way=0;return -2;}; |
---|
74 | /// Gets rid of all arrays (may be empty) |
---|
75 | virtual void clearArrays(); |
---|
76 | /// Returns true if would not find any column |
---|
77 | virtual bool looksOptimal() const |
---|
78 | { return false;}; |
---|
79 | //@} |
---|
80 | |
---|
81 | |
---|
82 | ///@name Constructors and destructors |
---|
83 | //@{ |
---|
84 | /// Default Constructor |
---|
85 | ClpPrimalColumnPivot(); |
---|
86 | |
---|
87 | /// Copy constructor |
---|
88 | ClpPrimalColumnPivot(const ClpPrimalColumnPivot &); |
---|
89 | |
---|
90 | /// Assignment operator |
---|
91 | ClpPrimalColumnPivot & operator=(const ClpPrimalColumnPivot& rhs); |
---|
92 | |
---|
93 | /// Destructor |
---|
94 | virtual ~ClpPrimalColumnPivot (); |
---|
95 | |
---|
96 | /// Clone |
---|
97 | virtual ClpPrimalColumnPivot * clone(bool copyData = true) const = 0; |
---|
98 | |
---|
99 | //@} |
---|
100 | |
---|
101 | ///@name Other |
---|
102 | //@{ |
---|
103 | /// Returns model |
---|
104 | inline ClpSimplex * model() |
---|
105 | { return model_;}; |
---|
106 | |
---|
107 | /// Returns type (above 63 is extra information) |
---|
108 | inline int type() |
---|
109 | { return type_;}; |
---|
110 | |
---|
111 | //@} |
---|
112 | |
---|
113 | //--------------------------------------------------------------------------- |
---|
114 | |
---|
115 | protected: |
---|
116 | ///@name Protected member data |
---|
117 | //@{ |
---|
118 | /// Pointer to model |
---|
119 | ClpSimplex * model_; |
---|
120 | /// Type of column pivot algorithm |
---|
121 | int type_; |
---|
122 | //@} |
---|
123 | }; |
---|
124 | |
---|
125 | #endif |
---|