1 | /* $Id: AbcDualRowPivot.hpp 2385 2019-01-06 19:43:06Z unxusr $ */ |
---|
2 | // Copyright (C) 2002, International Business Machines |
---|
3 | // Corporation and others, Copyright (C) 2012, FasterCoin. All Rights Reserved. |
---|
4 | // This code is licensed under the terms of the Eclipse Public License (EPL). |
---|
5 | |
---|
6 | #ifndef AbcDualRowPivot_H |
---|
7 | #define AbcDualRowPivot_H |
---|
8 | #include "AbcCommon.hpp" |
---|
9 | |
---|
10 | class AbcSimplex; |
---|
11 | class CoinIndexedVector; |
---|
12 | |
---|
13 | //############################################################################# |
---|
14 | |
---|
15 | /** Dual Row Pivot Abstract Base Class |
---|
16 | |
---|
17 | Abstract Base Class for describing an interface to an algorithm |
---|
18 | to choose row pivot in dual simplex algorithm. For some algorithms |
---|
19 | e.g. Dantzig choice then some functions may be null. |
---|
20 | |
---|
21 | */ |
---|
22 | |
---|
23 | class AbcDualRowPivot { |
---|
24 | |
---|
25 | public: |
---|
26 | ///@name Algorithmic methods |
---|
27 | //@{ |
---|
28 | |
---|
29 | /// Returns pivot row, -1 if none |
---|
30 | virtual int pivotRow() = 0; |
---|
31 | |
---|
32 | /** Does most of work for weights and returns pivot alpha. |
---|
33 | Also does FT update */ |
---|
34 | virtual double updateWeights1(CoinIndexedVector &input, CoinIndexedVector &updateColumn) = 0; |
---|
35 | virtual void updateWeightsOnly(CoinIndexedVector &input) = 0; |
---|
36 | virtual double updateWeights(CoinIndexedVector &input, CoinIndexedVector &updateColumn) = 0; |
---|
37 | /// Actually updates weights |
---|
38 | virtual void updateWeights2(CoinIndexedVector &input, CoinIndexedVector &updateColumn) = 0; |
---|
39 | |
---|
40 | /** Updates primal solution (and maybe list of candidates) |
---|
41 | Uses input vector which it deletes |
---|
42 | Would be faster if we kept basic regions, but on other hand it |
---|
43 | means everything is always in sync |
---|
44 | */ |
---|
45 | virtual void updatePrimalSolution(CoinIndexedVector &updateColumn, |
---|
46 | double theta) |
---|
47 | = 0; |
---|
48 | virtual void updatePrimalSolutionAndWeights(CoinIndexedVector &weightsVector, |
---|
49 | CoinIndexedVector &updateColumn, |
---|
50 | double theta); |
---|
51 | /** Saves any weights round factorization as pivot rows may change |
---|
52 | Will be empty unless steepest edge (will save model) |
---|
53 | May also recompute infeasibility stuff |
---|
54 | 1) before factorization |
---|
55 | 2) after good factorization (if weights empty may initialize) |
---|
56 | 3) after something happened but no factorization |
---|
57 | (e.g. check for infeasible) |
---|
58 | 4) as 2 but restore weights from previous snapshot |
---|
59 | 5) for strong branching - initialize , infeasibilities |
---|
60 | */ |
---|
61 | virtual void saveWeights(AbcSimplex *model, int mode); |
---|
62 | /// Recompute infeasibilities |
---|
63 | virtual void recomputeInfeasibilities(); |
---|
64 | /// checks accuracy and may re-initialize (may be empty) |
---|
65 | virtual void checkAccuracy(); |
---|
66 | /// Gets rid of all arrays (may be empty) |
---|
67 | virtual void clearArrays(); |
---|
68 | /// Returns true if would not find any row |
---|
69 | virtual bool looksOptimal() const |
---|
70 | { |
---|
71 | return false; |
---|
72 | } |
---|
73 | //@} |
---|
74 | |
---|
75 | ///@name Constructors and destructors |
---|
76 | //@{ |
---|
77 | /// Default Constructor |
---|
78 | AbcDualRowPivot(); |
---|
79 | |
---|
80 | /// Copy constructor |
---|
81 | AbcDualRowPivot(const AbcDualRowPivot &); |
---|
82 | |
---|
83 | /// Assignment operator |
---|
84 | AbcDualRowPivot &operator=(const AbcDualRowPivot &rhs); |
---|
85 | |
---|
86 | /// Destructor |
---|
87 | virtual ~AbcDualRowPivot(); |
---|
88 | |
---|
89 | /// Clone |
---|
90 | virtual AbcDualRowPivot *clone(bool copyData = true) const = 0; |
---|
91 | |
---|
92 | //@} |
---|
93 | |
---|
94 | ///@name Other |
---|
95 | //@{ |
---|
96 | /// Returns model |
---|
97 | inline AbcSimplex *model() |
---|
98 | { |
---|
99 | return model_; |
---|
100 | } |
---|
101 | |
---|
102 | /// Sets model (normally to NULL) |
---|
103 | inline void setModel(AbcSimplex *newmodel) |
---|
104 | { |
---|
105 | model_ = newmodel; |
---|
106 | } |
---|
107 | |
---|
108 | /// Returns type (above 63 is extra information) |
---|
109 | inline int type() |
---|
110 | { |
---|
111 | return type_; |
---|
112 | } |
---|
113 | |
---|
114 | //@} |
---|
115 | |
---|
116 | //--------------------------------------------------------------------------- |
---|
117 | |
---|
118 | protected: |
---|
119 | ///@name Protected member data |
---|
120 | //@{ |
---|
121 | /// Pointer to model |
---|
122 | AbcSimplex *model_; |
---|
123 | /// Type of row pivot algorithm |
---|
124 | int type_; |
---|
125 | //@} |
---|
126 | }; |
---|
127 | #ifndef CLP_DUAL_COLUMN_MULTIPLIER |
---|
128 | //#define CLP_DUAL_COLUMN_MULTIPLIER 0.99999 |
---|
129 | #endif |
---|
130 | #endif |
---|
131 | |
---|
132 | /* vi: softtabstop=2 shiftwidth=2 expandtab tabstop=2 |
---|
133 | */ |
---|