source:trunk/Clp/src/ClpPrimalColumnPivot.hpp

Last change on this file was 2385, checked in by unxusr, 10 months ago

formatting

• Property svn:eol-style set to `native`
• Property svn:keywords set to `Id`
File size: 4.5 KB
Line
1/* \$Id: ClpPrimalColumnPivot.hpp 2385 2019-01-06 19:43:06Z stefan \$ */
5
6#ifndef ClpPrimalcolumnPivot_H
7#define ClpPrimalcolumnPivot_H
8
9class ClpSimplex;
10class CoinIndexedVector;
11
12//#############################################################################
13
14/** Primal Column Pivot Abstract Base Class
15
16Abstract Base Class for describing an interface to an algorithm
17to choose column pivot in primal simplex algorithm.  For some algorithms
18e.g. Dantzig choice then some functions may be null.  For Dantzig
19the only one of any importance is pivotColumn.
20
21If  you wish to inherit from this look at ClpPrimalColumnDantzig.cpp
22as that is simplest version.
23*/
24
25class ClpPrimalColumnPivot {
26
27public:
28  ///@name Algorithmic methods
29  //@{
30
31  /** Returns pivot column, -1 if none
32
33         Normally updates reduced costs using result of last iteration
34         before selecting incoming column.
35
36         The Packed CoinIndexedVector updates has cost updates - for normal LP
37         that is just +-weight where a feasibility changed.  It also has
38         reduced cost from last iteration in pivot row
39
40         Inside pivotColumn the pivotRow_ and reduced cost from last iteration
41         are also used.
42
43         So in the simplest case i.e. feasible we compute the row of the
44         tableau corresponding to last pivot and add a multiple of this
45         to current reduced costs.
46
47         We can use other arrays to help updates
48     */
50    CoinIndexedVector *spareRow1,
51    CoinIndexedVector *spareRow2,
52    CoinIndexedVector *spareColumn1,
53    CoinIndexedVector *spareColumn2)
54    = 0;
55
56  /// Updates weights - part 1 (may be empty)
57  virtual void updateWeights(CoinIndexedVector *input);
58
59  /** Saves any weights round factorization as pivot rows may change
60         Will be empty unless steepest edge (will save model)
61         May also recompute infeasibility stuff
62         1) before factorization
63         2) after good factorization (if weights empty may initialize)
64         3) after something happened but no factorization
65            (e.g. check for infeasible)
66         4) as 2 but restore weights from previous snapshot
67         5) forces some initialization e.g. weights
68         Also sets model
69     */
70  virtual void saveWeights(ClpSimplex *model, int mode) = 0;
71  /** Signals pivot row choice:
72         -2 (default) - use normal pivot row choice
73         -1 to numberRows-1 - use this (will be checked)
74         way should be -1 to go to lower bound, +1 to upper bound
75     */
76  virtual int pivotRow(double &way)
77  {
78    way = 0;
79    return -2;
80  }
81  /// Gets rid of all arrays (may be empty)
82  virtual void clearArrays();
83  /// Returns true if would not find any column
84  virtual bool looksOptimal() const
85  {
86    return looksOptimal_;
87  }
88  /// Sets optimality flag (for advanced use)
89  virtual void setLooksOptimal(bool flag)
90  {
91    looksOptimal_ = flag;
92  }
93  //@}
94
95  ///@name Constructors and destructors
96  //@{
97  /// Default Constructor
98  ClpPrimalColumnPivot();
99
100  /// Copy constructor
101  ClpPrimalColumnPivot(const ClpPrimalColumnPivot &);
102
103  /// Assignment operator
104  ClpPrimalColumnPivot &operator=(const ClpPrimalColumnPivot &rhs);
105
106  /// Destructor
107  virtual ~ClpPrimalColumnPivot();
108
109  /// Clone
110  virtual ClpPrimalColumnPivot *clone(bool copyData = true) const = 0;
111
112  //@}
113
114  ///@name Other
115  //@{
116  /// Returns model
117  inline ClpSimplex *model()
118  {
119    return model_;
120  }
121  /// Sets model
122  inline void setModel(ClpSimplex *newmodel)
123  {
124    model_ = newmodel;
125  }
126
127  /// Returns type (above 63 is extra information)
128  inline int type()
129  {
130    return type_;
131  }
132
133  /** Returns number of extra columns for sprint algorithm - 0 means off.
134         Also number of iterations before recompute
135     */
136  virtual int numberSprintColumns(int &numberIterations) const;
137  /// Switch off sprint idea
138  virtual void switchOffSprint();
139  /// Called when maximum pivots changes
140  virtual void maximumPivotsChanged() {}
141
142  //@}
143
144  //---------------------------------------------------------------------------
145
146protected:
147  ///@name Protected member data
148  //@{
149  /// Pointer to model
150  ClpSimplex *model_;
151  /// Type of column pivot algorithm
152  int type_;
153  /// Says if looks optimal (normally computed)
154  bool looksOptimal_;
155  //@}
156};
157#ifndef CLP_PRIMAL_SLACK_MULTIPLIER
158#define CLP_PRIMAL_SLACK_MULTIPLIER 1.01
159#endif
160#endif
161
162/* vi: softtabstop=2 shiftwidth=2 expandtab tabstop=2
163*/
Note: See TracBrowser for help on using the repository browser.