source: trunk/Clp/src/ClpPrimalColumnPivot.hpp @ 1525

Last change on this file since 1525 was 1525, checked in by mjs, 10 years ago

Formatted .cpp, .hpp, .c, .h files with "astyle -A4 -p". This matches the formatting used in the grand CBC reorganization.

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