source: trunk/Clp/src/ClpGubDynamicMatrix.hpp @ 1055

Last change on this file since 1055 was 1055, checked in by forrest, 14 years ago

out };

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 6.7 KB
Line 
1// Copyright (C) 2003, International Business Machines
2// Corporation and others.  All Rights Reserved.
3#ifndef ClpGubDynamicMatrix_H
4#define ClpGubDynamicMatrix_H
5
6
7#include "CoinPragma.hpp"
8
9#include "ClpGubMatrix.hpp"
10/** This implements Gub rows plus a ClpPackedMatrix.
11    This a dynamic version which stores the gub part and dynamically creates matrix.
12    All bounds are assumed to be zero and infinity
13
14    This is just a simple example for real column generation
15*/
16
17class ClpGubDynamicMatrix : public ClpGubMatrix {
18 
19public:
20  /**@name Main functions provided */
21   //@{
22  /// Partial pricing
23  virtual void partialPricing(ClpSimplex * model, double start, double end,
24                              int & bestSequence, int & numberWanted);
25  /** This is local to Gub to allow synchronization:
26      mode=0 when status of basis is good
27      mode=1 when variable is flagged
28      mode=2 when all variables unflagged (returns number flagged)
29      mode=3 just reset costs (primal)
30      mode=4 correct number of dual infeasibilities
31      mode=5 return 4 if time to re-factorize
32      mode=8  - make sure set is clean
33      mode=9  - adjust lower, upper on set by incoming
34  */
35  virtual int synchronize(ClpSimplex * model,int mode);
36  /// Sets up an effective RHS and does gub crash if needed
37  virtual void useEffectiveRhs(ClpSimplex * model,bool cheapest=true);
38  /**
39     update information for a pivot (and effective rhs)
40  */
41  virtual int updatePivot(ClpSimplex * model,double oldInValue, double oldOutValue);
42  /// Add a new variable to a set
43  void insertNonBasic(int sequence, int iSet);
44  /** Returns effective RHS offset if it is being used.  This is used for long problems
45      or big gub or anywhere where going through full columns is
46      expensive.  This may re-compute */
47  virtual double * rhsOffset(ClpSimplex * model,bool forceRefresh=false,
48                                bool check=false);
49    /** Return <code>y + A * scalar *x</code> in <code>y</code>.
50        @pre <code>x</code> must be of size <code>numColumns()</code>
51        @pre <code>y</code> must be of size <code>numRows()</code> */
52  virtual void times(double scalar,
53                       const double * x, double * y) const;
54  /** Just for debug
55      Returns sum and number of primal infeasibilities. Recomputes keys
56  */
57  virtual int checkFeasible(ClpSimplex * model,double & sum) const;
58  /// Cleans data after setWarmStart
59  void cleanData(ClpSimplex * model);
60  //@}
61
62 
63 
64  /**@name Constructors, destructor */
65  //@{
66  /** Default constructor. */
67  ClpGubDynamicMatrix();
68  /** Destructor */
69  virtual ~ClpGubDynamicMatrix();
70  //@}
71 
72  /**@name Copy method */
73  //@{
74  /** The copy constructor. */
75  ClpGubDynamicMatrix(const ClpGubDynamicMatrix&);
76  /** This is the real constructor.
77      It assumes factorization frequency will not be changed.
78      This resizes model !!!!
79   */
80  ClpGubDynamicMatrix(ClpSimplex * model, int numberSets,
81                      int numberColumns, const int * starts,
82                      const double * lower, const double * upper,
83                      const int * startColumn, const int * row,
84                      const double * element, const double * cost,
85                      const double * lowerColumn=NULL, const double * upperColumn=NULL,
86                      const unsigned char * status=NULL);
87 
88  ClpGubDynamicMatrix& operator=(const ClpGubDynamicMatrix&);
89  /// Clone
90  virtual ClpMatrixBase * clone() const ;
91  //@}
92  /**@name gets and sets */
93  //@{
94  /// enums for status of various sorts
95  enum DynamicStatus {
96    inSmall = 0x01,
97    atUpperBound = 0x02,
98    atLowerBound = 0x03
99  };
100  /// Whether flagged
101  inline bool flagged(int i) const {
102    return (dynamicStatus_[i]&8)!=0;
103  }
104  inline void setFlagged(int i) {
105    dynamicStatus_[i] |= 8;
106  }
107  inline void unsetFlagged(int i) {
108    dynamicStatus_[i]  &= ~8;;
109  }
110  inline void setDynamicStatus(int sequence, DynamicStatus status)
111  {
112    unsigned char & st_byte = dynamicStatus_[sequence];
113    st_byte &= ~7;
114    st_byte |= status;
115  }
116  inline DynamicStatus getDynamicStatus(int sequence) const
117  {return static_cast<DynamicStatus> (dynamicStatus_[sequence]&7);}
118  /// Saved value of objective offset
119  inline double objectiveOffset() const
120  { return objectiveOffset_;}
121  /// Starts of each column
122  inline CoinBigIndex * startColumn() const
123  { return startColumn_;}
124  /// rows
125  inline int * row() const
126  { return row_;}
127  /// elements
128  inline float * element() const
129  { return element_;}
130  /// costs
131  inline float * cost() const
132  { return cost_;}
133  /// full starts
134  inline int * fullStart() const
135  { return fullStart_;}
136  /// ids of active columns (just index here)
137  inline int * id() const
138  { return id_;}
139  /// Optional lower bounds on columns
140  inline float * lowerColumn() const
141  { return lowerColumn_;}
142  /// Optional upper bounds on columns
143  inline float * upperColumn() const
144  { return upperColumn_;}
145  /// Optional true lower bounds on sets
146  inline float * lowerSet() const
147  { return lowerSet_;}
148  /// Optional true upper bounds on sets
149  inline float * upperSet() const
150  { return upperSet_;}
151  /// size
152  inline int numberGubColumns() const
153  { return numberGubColumns_;}
154  /// first free
155  inline int firstAvailable() const
156  { return firstAvailable_;}
157  /// set first free
158  inline void setFirstAvailable(int value)
159  { firstAvailable_ = value;}
160  /// first dynamic
161  inline int firstDynamic() const
162  { return firstDynamic_;}
163  /// number of columns in dynamic model
164  inline int lastDynamic() const
165  { return lastDynamic_;}
166  /// size of working matrix (max)
167  inline int numberElements() const
168  { return numberElements_;}
169  /// Status region for gub slacks
170  inline unsigned char * gubRowStatus() const
171  { return status_;}
172  /// Status region for gub variables
173  inline unsigned char * dynamicStatus() const
174  { return dynamicStatus_;}
175  /// Returns which set a variable is in
176  int whichSet (int sequence) const;
177  //@}
178   
179   
180protected:
181  /**@name Data members
182     The data members are protected to allow access for derived classes. */
183  //@{
184  /// Saved value of objective offset
185  double objectiveOffset_;
186  /// Starts of each column
187  CoinBigIndex * startColumn_;
188  /// rows
189  int * row_;
190  /// elements
191  float * element_;
192  /// costs
193  float * cost_;
194  /// full starts
195  int * fullStart_;
196  /// ids of active columns (just index here)
197  int * id_;
198  /// for status and which bound
199  unsigned char * dynamicStatus_;
200  /// Optional lower bounds on columns
201  float * lowerColumn_;
202  /// Optional upper bounds on columns
203  float * upperColumn_;
204  /// Optional true lower bounds on sets
205  float * lowerSet_;
206  /// Optional true upper bounds on sets
207  float * upperSet_;
208  /// size
209  int numberGubColumns_;
210  /// first free
211  int firstAvailable_;
212  /// saved first free
213  int savedFirstAvailable_;
214  /// first dynamic
215  int firstDynamic_;
216  /// number of columns in dynamic model
217  int lastDynamic_;
218  /// size of working matrix (max)
219  int numberElements_;
220   //@}
221};
222
223#endif
Note: See TracBrowser for help on using the repository browser.