1 | // Copyright (C) 2002, International Business Machines |
---|
2 | // Corporation and others. All Rights Reserved. |
---|
3 | #ifndef ClpDualRowSteepest_H |
---|
4 | #define ClpDualRowSteepest_H |
---|
5 | |
---|
6 | #include "ClpDualRowPivot.hpp" |
---|
7 | class CoinIndexedVector; |
---|
8 | |
---|
9 | |
---|
10 | //############################################################################# |
---|
11 | |
---|
12 | /** Dual Row Pivot Steepest Edge Algorithm Class |
---|
13 | |
---|
14 | See Forrest-Goldfarb paper for algorithm |
---|
15 | |
---|
16 | */ |
---|
17 | |
---|
18 | class ClpDualRowSteepest : public ClpDualRowPivot { |
---|
19 | |
---|
20 | public: |
---|
21 | |
---|
22 | ///@name Algorithmic methods |
---|
23 | //@{ |
---|
24 | |
---|
25 | /// Returns pivot row, -1 if none |
---|
26 | virtual int pivotRow(); |
---|
27 | |
---|
28 | /** Updates weights and returns pivot alpha. |
---|
29 | Also does FT update */ |
---|
30 | virtual double updateWeights(CoinIndexedVector * input, |
---|
31 | CoinIndexedVector * spare, |
---|
32 | CoinIndexedVector * spare2, |
---|
33 | CoinIndexedVector * updatedColumn); |
---|
34 | |
---|
35 | /** Updates primal solution (and maybe list of candidates) |
---|
36 | Uses input vector which it deletes |
---|
37 | Computes change in objective function |
---|
38 | */ |
---|
39 | virtual void updatePrimalSolution(CoinIndexedVector * input, |
---|
40 | double theta, |
---|
41 | double & changeInObjective); |
---|
42 | |
---|
43 | /** Saves any weights round factorization as pivot rows may change |
---|
44 | Save model |
---|
45 | May also recompute infeasibility stuff |
---|
46 | 1) before factorization |
---|
47 | 2) after good factorization (if weights empty may initialize) |
---|
48 | 3) after something happened but no factorization |
---|
49 | (e.g. check for infeasible) |
---|
50 | 4) as 2 but restore weights from previous snapshot |
---|
51 | 5) for strong branching - initialize (uninitialized) , infeasibilities |
---|
52 | */ |
---|
53 | virtual void saveWeights(ClpSimplex * model, int mode); |
---|
54 | /// Gets rid of last update |
---|
55 | virtual void unrollWeights(); |
---|
56 | /// Gets rid of all arrays |
---|
57 | virtual void clearArrays(); |
---|
58 | /// Returns true if would not find any row |
---|
59 | virtual bool looksOptimal() const; |
---|
60 | /// Called when maximum pivots changes |
---|
61 | virtual void maximumPivotsChanged(); |
---|
62 | //@} |
---|
63 | |
---|
64 | /** enums for persistence |
---|
65 | */ |
---|
66 | enum Persistence { |
---|
67 | normal = 0x00, // create (if necessary) and destroy |
---|
68 | keep = 0x01 // create (if necessary) and leave |
---|
69 | }; |
---|
70 | |
---|
71 | ///@name Constructors and destructors |
---|
72 | //@{ |
---|
73 | /** Default Constructor |
---|
74 | 0 is uninitialized, 1 full, 2 is partial uninitialized, |
---|
75 | 3 starts as 2 but may switch to 1. |
---|
76 | By partial is meant that the weights are updated as normal |
---|
77 | but only part of the infeasible basic variables are scanned. |
---|
78 | This can be faster on very easy problems. |
---|
79 | */ |
---|
80 | ClpDualRowSteepest(int mode=3); |
---|
81 | |
---|
82 | /// Copy constructor |
---|
83 | ClpDualRowSteepest(const ClpDualRowSteepest &); |
---|
84 | |
---|
85 | /// Assignment operator |
---|
86 | ClpDualRowSteepest & operator=(const ClpDualRowSteepest& rhs); |
---|
87 | |
---|
88 | /// Fill most values |
---|
89 | void fill(const ClpDualRowSteepest& rhs); |
---|
90 | |
---|
91 | /// Destructor |
---|
92 | virtual ~ClpDualRowSteepest (); |
---|
93 | |
---|
94 | /// Clone |
---|
95 | virtual ClpDualRowPivot * clone(bool copyData = true) const; |
---|
96 | |
---|
97 | //@} |
---|
98 | /**@name gets and sets */ |
---|
99 | //@{ |
---|
100 | /// Mode |
---|
101 | inline int mode() const |
---|
102 | { return mode_;} |
---|
103 | /// Set/ get persistence |
---|
104 | inline void setPersistence(Persistence life) |
---|
105 | { persistence_ = life;} |
---|
106 | inline Persistence persistence() const |
---|
107 | { return persistence_ ;} |
---|
108 | //@} |
---|
109 | |
---|
110 | //--------------------------------------------------------------------------- |
---|
111 | |
---|
112 | private: |
---|
113 | ///@name Private member data |
---|
114 | /** Status |
---|
115 | 0) Normal |
---|
116 | -1) Needs initialization |
---|
117 | 1) Weights are stored by sequence number |
---|
118 | */ |
---|
119 | int state_; |
---|
120 | /** If 0 then we are using uninitialized weights, 1 then full, |
---|
121 | if 2 then uninitialized partial, 3 switchable */ |
---|
122 | int mode_; |
---|
123 | /// Life of weights |
---|
124 | Persistence persistence_; |
---|
125 | /// weight array |
---|
126 | double * weights_; |
---|
127 | /// square of infeasibility array (just for infeasible rows) |
---|
128 | CoinIndexedVector * infeasible_; |
---|
129 | /// alternate weight array (so we can unroll) |
---|
130 | CoinIndexedVector * alternateWeights_; |
---|
131 | /// save weight array (so we can use checkpoint) |
---|
132 | CoinIndexedVector * savedWeights_; |
---|
133 | /// Dubious weights |
---|
134 | int * dubiousWeights_; |
---|
135 | //@} |
---|
136 | }; |
---|
137 | |
---|
138 | #endif |
---|