source: trunk/Clp/src/AbcDualRowSteepest.hpp @ 2385

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

formatting

  • Property svn:keywords set to Id
File size: 4.6 KB
Line 
1/* $Id: AbcDualRowSteepest.hpp 2385 2019-01-06 19:43:06Z unxusr $ */
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 AbcDualRowSteepest_H
7#define AbcDualRowSteepest_H
8
9#include "AbcDualRowPivot.hpp"
10class CoinIndexedVector;
11
12//#############################################################################
13
14/** Dual Row Pivot Steepest Edge Algorithm Class
15   
16    See Forrest-Goldfarb paper for algorithm
17   
18*/
19
20class AbcDualRowSteepest : public AbcDualRowPivot {
21
22public:
23  ///@name Algorithmic methods
24  //@{
25
26  /// Returns pivot row, -1 if none
27  virtual int pivotRow();
28
29  /** Updates weights and returns pivot alpha.
30      Also does FT update */
31  virtual double updateWeights(CoinIndexedVector &input, CoinIndexedVector &updatedColumn);
32  virtual double updateWeights1(CoinIndexedVector &input, CoinIndexedVector &updateColumn);
33  virtual void updateWeightsOnly(CoinIndexedVector &input);
34  /// Actually updates weights
35  virtual void updateWeights2(CoinIndexedVector &input, CoinIndexedVector &updateColumn);
36
37  /** Updates primal solution (and maybe list of candidates)
38      Uses input vector which it deletes
39  */
40  virtual void updatePrimalSolution(CoinIndexedVector &input,
41    double theta);
42
43  virtual void updatePrimalSolutionAndWeights(CoinIndexedVector &weightsVector,
44    CoinIndexedVector &updateColumn,
45    double theta);
46  /** Saves any weights round factorization as pivot rows may change
47      Save model
48      May also recompute infeasibility stuff
49      1) before factorization
50      2) after good factorization (if weights empty may initialize)
51      3) after something happened but no factorization
52      (e.g. check for infeasible)
53      4) as 2 but restore weights from previous snapshot
54      5) for strong branching - initialize (uninitialized) , infeasibilities
55  */
56  virtual void saveWeights(AbcSimplex *model, int mode);
57  /// Recompute infeasibilities
58  virtual void recomputeInfeasibilities();
59  /// Gets rid of all arrays
60  virtual void clearArrays();
61  /// Returns true if would not find any row
62  virtual bool looksOptimal() const;
63  //@}
64
65  /** enums for persistence
66   */
67  enum Persistence {
68    normal = 0x00, // create (if necessary) and destroy
69    keep = 0x01 // create (if necessary) and leave
70  };
71
72  ///@name Constructors and destructors
73  //@{
74  /** Default Constructor
75      0 is uninitialized, 1 full, 2 is partial uninitialized,
76      3 starts as 2 but may switch to 1.
77      By partial is meant that the weights are updated as normal
78      but only part of the infeasible basic variables are scanned.
79      This can be faster on very easy problems.
80  */
81  AbcDualRowSteepest(int mode = 3);
82
83  /// Copy constructor
84  AbcDualRowSteepest(const AbcDualRowSteepest &);
85
86  /// Assignment operator
87  AbcDualRowSteepest &operator=(const AbcDualRowSteepest &rhs);
88
89  /// Fill most values
90  void fill(const AbcDualRowSteepest &rhs);
91
92  /// Destructor
93  virtual ~AbcDualRowSteepest();
94
95  /// Clone
96  virtual AbcDualRowPivot *clone(bool copyData = true) const;
97
98  //@}
99  /**@name gets and sets */
100  //@{
101  /// Mode
102  inline int mode() const
103  {
104    return mode_;
105  }
106  /// Set/ get persistence
107  inline void setPersistence(Persistence life)
108  {
109    persistence_ = life;
110  }
111  inline Persistence persistence() const
112  {
113    return persistence_;
114  }
115  /// Infeasible vector
116  inline CoinIndexedVector *infeasible() const
117  {
118    return infeasible_;
119  }
120  /// Weights vector
121  inline CoinIndexedVector *weights() const
122  {
123    return weights_;
124  }
125  /// Model
126  inline AbcSimplex *model() const
127  {
128    return model_;
129  }
130  //@}
131
132  //---------------------------------------------------------------------------
133
134private:
135  ///@name Private member data
136  /// norm saved before going into update
137  double norm_;
138  /// Ratio of size of factorization to number of rows
139  double factorizationRatio_;
140  /** Status
141      0) Normal
142      -1) Needs initialization
143      1) Weights are stored by sequence number
144  */
145  int state_;
146  /** If 0 then we are using uninitialized weights, 1 then full,
147      if 2 then uninitialized partial, 3 switchable */
148  int mode_;
149  /// Life of weights
150  Persistence persistence_;
151  /// weight array
152  CoinIndexedVector *weights_;
153  /// square of infeasibility array (just for infeasible rows)
154  CoinIndexedVector *infeasible_;
155  /// save weight array (so we can use checkpoint)
156  CoinIndexedVector *savedWeights_;
157  //@}
158};
159
160// For Devex stuff
161#undef DEVEX_TRY_NORM
162#define DEVEX_TRY_NORM 1.0e-8
163#define DEVEX_ADD_ONE 1.0
164#endif
165
166/* vi: softtabstop=2 shiftwidth=2 expandtab tabstop=2
167*/
Note: See TracBrowser for help on using the repository browser.