summaryrefslogtreecommitdiff
path: root/thirdparty/linux/include/coin/ClpPrimalColumnPivot.hpp
blob: 678da303df2b173d574f1518f13cec3af65de5ff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
/* $Id: ClpPrimalColumnPivot.hpp 1732 2011-05-31 08:09:41Z forrest $ */
// Copyright (C) 2002, International Business Machines
// Corporation and others.  All Rights Reserved.
// This code is licensed under the terms of the Eclipse Public License (EPL).

#ifndef ClpPrimalcolumnPivot_H
#define ClpPrimalcolumnPivot_H

class ClpSimplex;
class CoinIndexedVector;

//#############################################################################

/** Primal Column Pivot Abstract Base Class

Abstract Base Class for describing an interface to an algorithm
to choose column pivot in primal simplex algorithm.  For some algorithms
e.g. Dantzig choice then some functions may be null.  For Dantzig
the only one of any importance is pivotColumn.

If  you wish to inherit from this look at ClpPrimalColumnDantzig.cpp
as that is simplest version.
*/

class ClpPrimalColumnPivot  {

public:

     ///@name Algorithmic methods
     //@{

     /** Returns pivot column, -1 if none

         Normally updates reduced costs using result of last iteration
         before selecting incoming column.

         The Packed CoinIndexedVector updates has cost updates - for normal LP
         that is just +-weight where a feasibility changed.  It also has
         reduced cost from last iteration in pivot row

         Inside pivotColumn the pivotRow_ and reduced cost from last iteration
         are also used.

         So in the simplest case i.e. feasible we compute the row of the
         tableau corresponding to last pivot and add a multiple of this
         to current reduced costs.

         We can use other arrays to help updates
     */
     virtual int pivotColumn(CoinIndexedVector * updates,
                             CoinIndexedVector * spareRow1,
                             CoinIndexedVector * spareRow2,
                             CoinIndexedVector * spareColumn1,
                             CoinIndexedVector * spareColumn2) = 0;

     /// Updates weights - part 1 (may be empty)
     virtual void updateWeights(CoinIndexedVector * input);

     /** Saves any weights round factorization as pivot rows may change
         Will be empty unless steepest edge (will save model)
         May also recompute infeasibility stuff
         1) before factorization
         2) after good factorization (if weights empty may initialize)
         3) after something happened but no factorization
            (e.g. check for infeasible)
         4) as 2 but restore weights from previous snapshot
         5) forces some initialization e.g. weights
         Also sets model
     */
     virtual void saveWeights(ClpSimplex * model, int mode) = 0;
     /** Signals pivot row choice:
         -2 (default) - use normal pivot row choice
         -1 to numberRows-1 - use this (will be checked)
         way should be -1 to go to lower bound, +1 to upper bound
     */
     virtual int pivotRow(double & way) {
          way = 0;
          return -2;
     }
     /// Gets rid of all arrays (may be empty)
     virtual void clearArrays();
     /// Returns true if would not find any column
     virtual bool looksOptimal() const {
          return looksOptimal_;
     }
     /// Sets optimality flag (for advanced use)
     virtual void setLooksOptimal(bool flag) {
          looksOptimal_ = flag;
     }
     //@}


     ///@name Constructors and destructors
     //@{
     /// Default Constructor
     ClpPrimalColumnPivot();

     /// Copy constructor
     ClpPrimalColumnPivot(const ClpPrimalColumnPivot &);

     /// Assignment operator
     ClpPrimalColumnPivot & operator=(const ClpPrimalColumnPivot& rhs);

     /// Destructor
     virtual ~ClpPrimalColumnPivot ();

     /// Clone
     virtual ClpPrimalColumnPivot * clone(bool copyData = true) const = 0;

     //@}

     ///@name Other
     //@{
     /// Returns model
     inline ClpSimplex * model() {
          return model_;
     }
     /// Sets model
     inline void setModel(ClpSimplex * newmodel) {
          model_ = newmodel;
     }

     /// Returns type (above 63 is extra information)
     inline int type() {
          return type_;
     }

     /** Returns number of extra columns for sprint algorithm - 0 means off.
         Also number of iterations before recompute
     */
     virtual int numberSprintColumns(int & numberIterations) const;
     /// Switch off sprint idea
     virtual void switchOffSprint();
     /// Called when maximum pivots changes
     virtual void maximumPivotsChanged() {}

     //@}

     //---------------------------------------------------------------------------

protected:
     ///@name Protected member data
     //@{
     /// Pointer to model
     ClpSimplex * model_;
     /// Type of column pivot algorithm
     int type_;
     /// Says if looks optimal (normally computed)
     bool looksOptimal_;
     //@}
};
#ifndef CLP_PRIMAL_SLACK_MULTIPLIER
#define CLP_PRIMAL_SLACK_MULTIPLIER 1.01
#endif
#endif