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 | //@} |
---|
51 | |
---|
52 | /**@name gets and sets */ |
---|
53 | //@{ |
---|
54 | /// Mode |
---|
55 | inline int mode() const |
---|
56 | { return mode_;}; |
---|
57 | //@} |
---|
58 | |
---|
59 | |
---|
60 | ///@name Constructors and destructors |
---|
61 | //@{ |
---|
62 | /// Default Constructor |
---|
63 | ClpPrimalColumnSteepest(int mode=0); |
---|
64 | |
---|
65 | /// Copy constructor |
---|
66 | ClpPrimalColumnSteepest(const ClpPrimalColumnSteepest &); |
---|
67 | |
---|
68 | /// Assignment operator |
---|
69 | ClpPrimalColumnSteepest & operator=(const ClpPrimalColumnSteepest& rhs); |
---|
70 | |
---|
71 | /// Destructor |
---|
72 | virtual ~ClpPrimalColumnSteepest (); |
---|
73 | |
---|
74 | /// Clone |
---|
75 | virtual ClpPrimalColumnPivot * clone(bool copyData = true) const; |
---|
76 | |
---|
77 | //@} |
---|
78 | |
---|
79 | ///@name Private functions to deal with devex |
---|
80 | /** reference would be faster using ClpSimplex's status_, |
---|
81 | but I prefer to keep modularity. |
---|
82 | */ |
---|
83 | inline bool reference(int i) const { |
---|
84 | return (reference_[i>>5]>>(i&31))!=0; |
---|
85 | } |
---|
86 | inline void setReference(int i,bool trueFalse) { |
---|
87 | unsigned int & value = reference_[i>>5]; |
---|
88 | int bit = i&31; |
---|
89 | if (trueFalse) |
---|
90 | value |= (1<<bit); |
---|
91 | else |
---|
92 | value &= ~(1<<bit); |
---|
93 | } |
---|
94 | //@} |
---|
95 | //--------------------------------------------------------------------------- |
---|
96 | |
---|
97 | private: |
---|
98 | ///@name Private member data |
---|
99 | /** Status |
---|
100 | 0) Normal |
---|
101 | -1) Needs initialization |
---|
102 | 1) Weights are stored by sequence number |
---|
103 | */ |
---|
104 | int state_; |
---|
105 | /// If 0 then we are using exact devex, 1 then full |
---|
106 | int mode_; |
---|
107 | /// weight array |
---|
108 | double * weights_; |
---|
109 | /// square of infeasibility array (just for infeasible columns) |
---|
110 | CoinIndexedVector * infeasible_; |
---|
111 | /// alternate weight array (so we can unroll) |
---|
112 | CoinIndexedVector * alternateWeights_; |
---|
113 | /// save weight array (so we can use checkpoint) |
---|
114 | double * savedWeights_; |
---|
115 | // This is pivot row (or pivot sequence round re-factorization) |
---|
116 | int pivotSequence_; |
---|
117 | // This is saved pivot sequence |
---|
118 | int savedPivotSequence_; |
---|
119 | // This is saved outgoing variable |
---|
120 | int savedSequenceOut_; |
---|
121 | // Array for exact devex to say what is in reference framework |
---|
122 | unsigned int * reference_; |
---|
123 | // Update weight |
---|
124 | double devex_; |
---|
125 | //@} |
---|
126 | }; |
---|
127 | |
---|
128 | #endif |
---|