source: branches/pre/include/ClpPrimalColumnSteepest.hpp @ 210

Last change on this file since 210 was 210, checked in by forrest, 17 years ago

Trying

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.2 KB
Line 
1// Copyright (C) 2002, International Business Machines
2// Corporation and others.  All Rights Reserved.
3#ifndef ClpPrimalColumnSteepest_H
4#define ClpPrimalColumnSteepest_H
5
6#include "ClpPrimalColumnPivot.hpp"
7#include <bitset>
8
9//#############################################################################
10
11
12/** Primal Column Pivot Steepest Edge Algorithm Class
13
14See Forrest-Goldfarb paper for algorithm
15
16*/
17
18class CoinIndexedVector;
19
20class ClpPrimalColumnSteepest : public ClpPrimalColumnPivot {
21 
22public:
23 
24  ///@name Algorithmic methods
25  //@{
26 
27  /** Returns pivot column, -1 if none.
28      updateArray has cost updates (also use pivotRow_ from last iteration)
29  */
30  virtual int pivotColumn(CoinIndexedVector * updates,
31                          CoinIndexedVector * spareRow1,
32                          CoinIndexedVector * spareRow2,
33                          CoinIndexedVector * spareColumn1,
34                          CoinIndexedVector * spareColumn2);
35
36  /// Updates weights - part 1 - also checks accuracy
37  virtual void updateWeights(CoinIndexedVector * input);
38
39  /// Checks accuracy - just for debug
40  void checkAccuracy(int sequence,double relativeTolerance,
41                     CoinIndexedVector * rowArray1,
42                     CoinIndexedVector * rowArray2);
43
44  /// Initialize weights
45  void initializeWeights();
46
47  /// Save weights
48  virtual void saveWeights(ClpSimplex * model,int mode);
49  /// Gets rid of last update
50  virtual void unrollWeights();
51  /// Gets rid of all arrays
52  virtual void clearArrays();
53  /// Returns true if would not find any column
54  virtual bool looksOptimal() const;
55  //@}
56 
57  /**@name gets and sets */
58  //@{
59  /// Mode
60  inline int mode() const
61    { return mode_;};
62 //@}
63
64 
65  ///@name Constructors and destructors
66  //@{
67  /** Default Constructor
68      0 is exact devex, 1 full steepest, 2 is partial exact devex
69      3 switches between 0 and 2 depending on factorization
70      4 starts as partial dantzig but then may switch between 0 and 2.
71      By partial exact devex is meant that the weights are updated as normal
72      but only part of the nonbasic variables are scanned. 
73      This can be faster on very easy problems.
74  */
75  ClpPrimalColumnSteepest(int mode=3); 
76 
77  /// Copy constructor
78  ClpPrimalColumnSteepest(const ClpPrimalColumnSteepest &);
79 
80  /// Assignment operator
81  ClpPrimalColumnSteepest & operator=(const ClpPrimalColumnSteepest& rhs);
82 
83  /// Destructor
84  virtual ~ClpPrimalColumnSteepest ();
85
86  /// Clone
87  virtual ClpPrimalColumnPivot * clone(bool copyData = true) const;
88 
89  //@}
90
91  ///@name Private functions to deal with devex
92  /** reference would be faster using ClpSimplex's status_,
93      but I prefer to keep modularity.
94  */
95  inline bool reference(int i) const {
96    return ((reference_[i>>5]>>(i&31))&1)!=0;
97  }
98  inline void setReference(int i,bool trueFalse) {
99    unsigned int & value = reference_[i>>5];
100    int bit = i&31;
101    if (trueFalse)
102      value |= (1<<bit);
103    else
104      value &= ~(1<<bit);
105  }
106  //@}
107  //---------------------------------------------------------------------------
108 
109private:
110  ///@name Private member data
111  // Update weight
112  double devex_;
113  /// weight array
114  double * weights_;
115  /// square of infeasibility array (just for infeasible columns)
116  CoinIndexedVector * infeasible_;
117  /// alternate weight array (so we can unroll)
118  CoinIndexedVector * alternateWeights_;
119  /// save weight array (so we can use checkpoint)
120  double * savedWeights_;
121  // Array for exact devex to say what is in reference framework
122  unsigned int * reference_;
123  /** Status
124      0) Normal
125      -1) Needs initialization
126      1) Weights are stored by sequence number
127  */
128  int state_;
129  /**
130      0 is exact devex, 1 full steepest, 2 is partial exact devex
131      3 switches between 0 and 2 depending on factorization
132      4 starts as partial dantzig but then may switch between 0 and 2.
133      By partial exact devex is meant that the weights are updated as normal
134      but only part of the nonbasic variables are scanned. 
135      This can be faster on very easy problems.*/
136  int mode_;
137  /// Number of times switched from partial dantzig to 0/2
138  int numberSwitched_;
139  // This is pivot row (or pivot sequence round re-factorization)
140  int pivotSequence_; 
141  // This is saved pivot sequence
142  int savedPivotSequence_; 
143  // This is saved outgoing variable
144  int savedSequenceOut_; 
145  //@}
146};
147
148#endif
Note: See TracBrowser for help on using the repository browser.