1 | // Copyright (C) 2002, International Business Machines |
---|
2 | // Corporation and others. All Rights Reserved. |
---|
3 | #ifndef ClpPrimalColumnSteepest_H |
---|
4 | #define ClpPrimalColumnSteepest_H |
---|
5 | |
---|
6 | #include "ClpPrimalColumnPivot.hpp" |
---|
7 | |
---|
8 | //############################################################################# |
---|
9 | |
---|
10 | |
---|
11 | /** Primal Column Pivot Steepest Edge Algorithm Class |
---|
12 | |
---|
13 | See Forrest-Goldfarb paper for algorithm |
---|
14 | |
---|
15 | */ |
---|
16 | |
---|
17 | class CoinIndexedVector; |
---|
18 | |
---|
19 | class ClpPrimalColumnSteepest : public ClpPrimalColumnPivot { |
---|
20 | |
---|
21 | public: |
---|
22 | |
---|
23 | ///@name Algorithmic methods |
---|
24 | //@{ |
---|
25 | |
---|
26 | /** Returns pivot column, -1 if none. |
---|
27 | updateArray has cost updates (also use pivotRow_ from last iteration) |
---|
28 | */ |
---|
29 | virtual int pivotColumn(CoinIndexedVector * updates, |
---|
30 | CoinIndexedVector * spareRow1, |
---|
31 | CoinIndexedVector * spareRow2, |
---|
32 | CoinIndexedVector * spareColumn1, |
---|
33 | CoinIndexedVector * spareColumn2); |
---|
34 | |
---|
35 | /// Updates weights - part 1 - also checks accuracy |
---|
36 | virtual void updateWeights(CoinIndexedVector * input); |
---|
37 | |
---|
38 | /// Checks accuracy - just for debug |
---|
39 | void checkAccuracy(int sequence,double relativeTolerance, |
---|
40 | CoinIndexedVector * rowArray1, |
---|
41 | CoinIndexedVector * rowArray2); |
---|
42 | |
---|
43 | /// Initialize weights |
---|
44 | void initializeWeights(); |
---|
45 | |
---|
46 | /// Save weights |
---|
47 | virtual void saveWeights(ClpSimplex * model,int mode); |
---|
48 | /// Gets rid of last update |
---|
49 | virtual void unrollWeights(); |
---|
50 | /// Gets rid of all arrays |
---|
51 | virtual void clearArrays(); |
---|
52 | //@} |
---|
53 | |
---|
54 | /**@name gets and sets */ |
---|
55 | //@{ |
---|
56 | /// Mode |
---|
57 | inline int mode() const |
---|
58 | { return mode_;}; |
---|
59 | //@} |
---|
60 | |
---|
61 | |
---|
62 | ///@name Constructors and destructors |
---|
63 | //@{ |
---|
64 | /// Default Constructor |
---|
65 | ClpPrimalColumnSteepest(int mode=0); |
---|
66 | |
---|
67 | /// Copy constructor |
---|
68 | ClpPrimalColumnSteepest(const ClpPrimalColumnSteepest &); |
---|
69 | |
---|
70 | /// Assignment operator |
---|
71 | ClpPrimalColumnSteepest & operator=(const ClpPrimalColumnSteepest& rhs); |
---|
72 | |
---|
73 | /// Destructor |
---|
74 | virtual ~ClpPrimalColumnSteepest (); |
---|
75 | |
---|
76 | /// Clone |
---|
77 | virtual ClpPrimalColumnPivot * clone(bool copyData = true) const; |
---|
78 | |
---|
79 | //@} |
---|
80 | |
---|
81 | ///@name Private functions to deal with devex |
---|
82 | /** reference would be faster using ClpSimplex's status_, |
---|
83 | but I prefer to keep modularity. |
---|
84 | */ |
---|
85 | inline bool reference(int i) const { |
---|
86 | return (reference_[i>>5]>>(i&31))!=0; |
---|
87 | } |
---|
88 | inline void setReference(int i,bool trueFalse) { |
---|
89 | unsigned int & value = reference_[i>>5]; |
---|
90 | int bit = i&31; |
---|
91 | if (trueFalse) |
---|
92 | value |= (1<<bit); |
---|
93 | else |
---|
94 | value &= ~(1<<bit); |
---|
95 | } |
---|
96 | //@} |
---|
97 | //--------------------------------------------------------------------------- |
---|
98 | |
---|
99 | private: |
---|
100 | ///@name Private member data |
---|
101 | /** Status |
---|
102 | 0) Normal |
---|
103 | -1) Needs initialization |
---|
104 | 1) Weights are stored by sequence number |
---|
105 | */ |
---|
106 | int state_; |
---|
107 | /// If 0 then we are using exact devex, 1 then full |
---|
108 | int mode_; |
---|
109 | /// weight array |
---|
110 | double * weights_; |
---|
111 | /// square of infeasibility array (just for infeasible columns) |
---|
112 | CoinIndexedVector * infeasible_; |
---|
113 | /// alternate weight array (so we can unroll) |
---|
114 | CoinIndexedVector * alternateWeights_; |
---|
115 | /// save weight array (so we can use checkpoint) |
---|
116 | double * savedWeights_; |
---|
117 | // This is pivot row (or pivot sequence round re-factorization) |
---|
118 | int pivotSequence_; |
---|
119 | // This is saved pivot sequence |
---|
120 | int savedPivotSequence_; |
---|
121 | // This is saved outgoing variable |
---|
122 | int savedSequenceOut_; |
---|
123 | // Array for exact devex to say what is in reference framework |
---|
124 | unsigned int * reference_; |
---|
125 | // Update weight |
---|
126 | double devex_; |
---|
127 | //@} |
---|
128 | }; |
---|
129 | |
---|
130 | #endif |
---|