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

Last change on this file since 2470 was 2385, checked in by unxusr, 9 months ago

formatting

  • Property svn:keywords set to Id
File size: 4.5 KB
Line 
1/* $Id: AbcPrimalColumnPivot.hpp 2385 2019-01-06 19:43:06Z stefan $ */
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  ///@name Algorithmic methods
30  //@{
31
32  /** Returns pivot column, -1 if none
33
34         Normally updates reduced costs using result of last iteration
35         before selecting incoming column.
36
37         The Packed CoinIndexedVector updates has cost updates - for normal LP
38         that is just +-weight where a feasibility changed.  It also has
39         reduced cost from last iteration in pivot row
40
41         Inside pivotColumn the pivotRow_ and reduced cost from last iteration
42         are also used.
43
44         So in the simplest case i.e. feasible we compute the row of the
45         tableau corresponding to last pivot and add a multiple of this
46         to current reduced costs.
47
48         We can use other arrays to help updates
49     */
50  virtual int pivotColumn(CoinPartitionedVector *updates,
51    CoinPartitionedVector *spareRow2,
52    CoinPartitionedVector *spareColumn1)
53    = 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  {
77    way = 0;
78    return -2;
79  }
80  /// Gets rid of all arrays (may be empty)
81  virtual void clearArrays();
82  /// Returns true if would not find any column
83  virtual bool looksOptimal() const
84  {
85    return looksOptimal_;
86  }
87  /// Sets optimality flag (for advanced use)
88  virtual void setLooksOptimal(bool flag)
89  {
90    looksOptimal_ = flag;
91  }
92  //@}
93
94  ///@name Constructors and destructors
95  //@{
96  /// Default Constructor
97  AbcPrimalColumnPivot();
98
99  /// Copy constructor
100  AbcPrimalColumnPivot(const AbcPrimalColumnPivot &);
101
102  /// Assignment operator
103  AbcPrimalColumnPivot &operator=(const AbcPrimalColumnPivot &rhs);
104
105  /// Destructor
106  virtual ~AbcPrimalColumnPivot();
107
108  /// Clone
109  virtual AbcPrimalColumnPivot *clone(bool copyData = true) const = 0;
110
111  //@}
112
113  ///@name Other
114  //@{
115  /// Returns model
116  inline AbcSimplex *model()
117  {
118    return model_;
119  }
120  /// Sets model
121  inline void setModel(AbcSimplex *newmodel)
122  {
123    model_ = newmodel;
124  }
125
126  /// Returns type (above 63 is extra information)
127  inline int type()
128  {
129    return type_;
130  }
131
132  /** Returns number of extra columns for sprint algorithm - 0 means off.
133         Also number of iterations before recompute
134     */
135  virtual int numberSprintColumns(int &numberIterations) const;
136  /// Switch off sprint idea
137  virtual void switchOffSprint();
138  /// Called when maximum pivots changes
139  virtual void maximumPivotsChanged() {}
140
141  //@}
142
143  //---------------------------------------------------------------------------
144
145protected:
146  ///@name Protected member data
147  //@{
148  /// Pointer to model
149  AbcSimplex *model_;
150  /// Type of column pivot algorithm
151  int type_;
152  /// Says if looks optimal (normally computed)
153  bool looksOptimal_;
154  //@}
155};
156#ifndef CLP_PRIMAL_SLACK_MULTIPLIER
157#define CLP_PRIMAL_SLACK_MULTIPLIER 1.01
158#endif
159#endif
160
161/* vi: softtabstop=2 shiftwidth=2 expandtab tabstop=2
162*/
Note: See TracBrowser for help on using the repository browser.