source: trunk/Clp/src/AbcPrimalColumnPivot.hpp @ 1878

Last change on this file since 1878 was 1878, checked in by forrest, 7 years ago

minor changes to implement Aboca

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