Cbc  2.9.9
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CoinWarmStartBasis.hpp
Go to the documentation of this file.
1 /* $Id: CoinWarmStartBasis.hpp 1515 2011-12-10 23:38:04Z lou $ */
13 #ifndef CoinWarmStartBasis_H
14 #define CoinWarmStartBasis_H
15 
16 #include <vector>
17 
18 #include "CoinSort.hpp"
19 #include "CoinHelperFunctions.hpp"
20 #include "CoinWarmStart.hpp"
21 
22 //#############################################################################
23 
40 class CoinWarmStartBasis : public virtual CoinWarmStart {
41 public:
42 
57  enum Status {
58  isFree = 0x00,
59  basic = 0x01,
60  atUpperBound = 0x02,
61  atLowerBound = 0x03
62  };
63 
68 
72  typedef std::vector<XferEntry> XferVec ;
73 
74 public:
75 
86  inline int getNumStructural() const { return numStructural_; }
88 
90  inline int getNumArtificial() const { return numArtificial_; }
91 
96  int numberBasicStructurals() const ;
97 
99  inline Status getStructStatus(int i) const {
100  const int st = (structuralStatus_[i>>2] >> ((i&3)<<1)) & 3;
101  return static_cast<CoinWarmStartBasis::Status>(st);
102  }
103 
105  inline void setStructStatus(int i, Status st) {
106  char& st_byte = structuralStatus_[i>>2];
107  st_byte = static_cast<char>(st_byte & ~(3 << ((i&3)<<1))) ;
108  st_byte = static_cast<char>(st_byte | (st << ((i&3)<<1))) ;
109  }
110 
116  inline char * getStructuralStatus() { return structuralStatus_; }
117 
123  inline const char * getStructuralStatus() const { return structuralStatus_; }
124 
128  inline char * getArtificialStatus() { return artificialStatus_; }
129 
131  inline Status getArtifStatus(int i) const {
132  const int st = (artificialStatus_[i>>2] >> ((i&3)<<1)) & 3;
133  return static_cast<CoinWarmStartBasis::Status>(st);
134  }
135 
137  inline void setArtifStatus(int i, Status st) {
138  char& st_byte = artificialStatus_[i>>2];
139  st_byte = static_cast<char>(st_byte & ~(3 << ((i&3)<<1))) ;
140  st_byte = static_cast<char>(st_byte | (st << ((i&3)<<1))) ;
141  }
142 
148  inline const char * getArtificialStatus() const { return artificialStatus_; }
149 
151 
154 
162  virtual CoinWarmStartDiff*
163  generateDiff (const CoinWarmStart *const oldCWS) const ;
164 
171  virtual void
172  applyDiff (const CoinWarmStartDiff *const cwsdDiff) ;
173 
175 
176 
179 
185  virtual void setSize(int ns, int na) ;
186 
195  virtual void resize (int newNumberRows, int newNumberColumns);
196 
213  virtual void compressRows (int tgtCnt, const int *tgts) ;
214 
226  virtual void deleteRows(int rawTgtCnt, const int *rawTgts) ;
227 
238  virtual void deleteColumns(int number, const int * which);
239 
252  virtual void mergeBasis(const CoinWarmStartBasis *src,
253  const XferVec *xferRows,
254  const XferVec *xferCols) ;
255 
257 
261 
268 
278  CoinWarmStartBasis(int ns, int na, const char* sStat, const char* aStat) ;
279 
282 
284  virtual CoinWarmStart *clone() const
285  {
286  return new CoinWarmStartBasis(*this);
287  }
288 
290  virtual ~CoinWarmStartBasis();
291 
294  virtual CoinWarmStartBasis& operator=(const CoinWarmStartBasis& rhs) ;
295 
311  virtual void assignBasisStatus(int ns, int na, char*& sStat, char*& aStat) ;
313 
316 
318  virtual void print() const;
320  bool fullBasis() const;
322  bool fixFullBasis();
323 
325 
326 protected:
333  int numStructural_;
338  int maxSize_;
344 };
345 
346 
351 inline CoinWarmStartBasis::Status getStatus(const char *array, int i) {
352  const int st = (array[i>>2] >> ((i&3)<<1)) & 3;
353  return static_cast<CoinWarmStartBasis::Status>(st);
354 }
355 
360 inline void setStatus(char * array, int i, CoinWarmStartBasis::Status st) {
361  char& st_byte = array[i>>2];
362  st_byte = static_cast<char>(st_byte & ~(3 << ((i&3)<<1))) ;
363  st_byte = static_cast<char>(st_byte | (st << ((i&3)<<1))) ;
364 }
365 
369 const char *statusName(CoinWarmStartBasis::Status status) ;
370 
371 
396 { public:
397 
399  virtual CoinWarmStartDiff *clone() const
400  { CoinWarmStartBasisDiff *cwsbd = new CoinWarmStartBasisDiff(*this) ;
401  return (dynamic_cast<CoinWarmStartDiff *>(cwsbd)) ; }
402 
404  virtual
406 
408  virtual ~CoinWarmStartBasisDiff();
409 
410  protected:
411 
419 
431 
433  CoinWarmStartBasisDiff (int sze, const unsigned int *const diffNdxs,
434  const unsigned int *const diffVals) ;
435 
438 
439  private:
440 
441  friend CoinWarmStartDiff*
442  CoinWarmStartBasis::generateDiff(const CoinWarmStart *const oldCWS) const ;
443  friend void
445 
447  int sze_ ;
448 
451  unsigned int *difference_ ;
452 
453 } ;
454 
455 
456 #endif
virtual void assignBasisStatus(int ns, int na, char *&sStat, char *&aStat)
Assign the status vectors to be the warm start information.
virtual void resize(int newNumberRows, int newNumberColumns)
Set basis capacity; existing basis is maintained.
virtual void deleteColumns(int number, const int *which)
Delete a set of columns from the basis.
unsigned int * difference_
Array of diff indices and diff values.
bool fixFullBasis()
Returns true if full basis and fixes up (for debug)
virtual void setSize(int ns, int na)
Set basis capacity; existing basis is discarded.
virtual ~CoinWarmStartBasisDiff()
Destructor.
void setStatus(char *array, int i, CoinWarmStartBasis::Status st)
Set the status of the specified variable in the given status array.
virtual CoinWarmStart * clone() const
`Virtual constructor&#39;
Status getStructStatus(int i) const
Return the status of the specified structural variable.
void setStructStatus(int i, Status st)
Set the status of the specified structural variable.
int numStructural_
The number of structural variables.
CoinWarmStartBasis::Status getStatus(const char *array, int i)
Get the status of the specified variable in the given status array.
CoinWarmStartBasisDiff()
Default constructor.
CoinWarmStartBasis()
Default constructor.
virtual void compressRows(int tgtCnt, const int *tgts)
Delete a set of rows from the basis.
The default COIN simplex (basis-oriented) warm start class.
void setArtifStatus(int i, Status st)
Set the status of the specified artificial variable.
const char * statusName(CoinPrePostsolveMatrix::Status status)
Generate a print string for a status code.
virtual void mergeBasis(const CoinWarmStartBasis *src, const XferVec *xferRows, const XferVec *xferCols)
Merge entries from a source basis into this basis.
char * getStructuralStatus()
Return the status array for the structural variables.
int numberBasicStructurals() const
Return the number of basic structurals.
int numArtificial_
The number of artificial variables.
A `diff&#39; between two CoinWarmStartBasis objects.
const char * getArtificialStatus() const
const overload for getArtificialStatus()
virtual void print() const
Prints in readable format (for debug)
bool fullBasis() const
Returns true if full basis (for debug)
virtual CoinWarmStartDiff * clone() const
`Virtual constructor&#39;
Nonbasic free variable.
Status getArtifStatus(int i) const
Return the status of the specified artificial variable.
int sze_
Number of entries (and allocated capacity), in units of int.
char * artificialStatus_
The status of the artificial variables.
char * structuralStatus_
The status of the structural variables.
int getNumStructural() const
Return the number of structural variables.
std::vector< XferEntry > XferVec
Transfer vector for mergeBasis(const CoinWarmStartBasis*,const XferVec*,const XferVec*) ...
virtual CoinWarmStartDiff * generateDiff(const CoinWarmStart *const oldCWS) const
Generate a `diff&#39; that can convert the warm start basis passed as a parameter to the warm start basis...
int maxSize_
The maximum sise (in ints - actually 4*char) (so resize does not need to do new)
Copyright (C) 2000 – 2003, International Business Machines Corporation and others.
const char * getStructuralStatus() const
const overload for getStructuralStatus()
virtual CoinWarmStartBasisDiff & operator=(const CoinWarmStartBasisDiff &rhs)
Assignment.
Abstract base class for warm start `diff&#39; objects.
virtual ~CoinWarmStartBasis()
Destructor.
Status
Enum for status of variables.
int getNumArtificial() const
Return the number of artificial variables.
virtual CoinWarmStartBasis & operator=(const CoinWarmStartBasis &rhs)
Assignment.
char * getArtificialStatus()
As for getStructuralStatus , but returns the status array for the artificial variables.
virtual void deleteRows(int rawTgtCnt, const int *rawTgts)
Delete a set of rows from the basis.
virtual void applyDiff(const CoinWarmStartDiff *const cwsdDiff)
Apply diff to this basis.
Abstract base class for warm start information.
CoinTriple< int, int, int > XferEntry
Transfer vector entry for mergeBasis(const CoinWarmStartBasis*,const XferVec*,const XferVec*) ...