Osi 0.107.9

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

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
67 typedef CoinTriple<int,int,int> XferEntry ;
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
267 CoinWarmStartBasis();
268
278 CoinWarmStartBasis(int ns, int na, const char* sStat, const char* aStat) ;
279
281 CoinWarmStartBasis(const CoinWarmStartBasis& ws) ;
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_;
336 int numArtificial_;
338 int maxSize_;
340 char * structuralStatus_;
342 char * artificialStatus_;
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
395 class CoinWarmStartBasisDiff : public virtual CoinWarmStartDiff
396 { public:
397
399 virtual CoinWarmStartDiff *clone() const
400 { CoinWarmStartBasisDiff *cwsbd = new CoinWarmStartBasisDiff(*this) ;
401 return (dynamic_cast<CoinWarmStartDiff *>(cwsbd)) ; }
402
404 virtual
405 CoinWarmStartBasisDiff &operator= (const CoinWarmStartBasisDiff &rhs) ;
406
408 virtual ~CoinWarmStartBasisDiff();
409
410 protected:
411
418 CoinWarmStartBasisDiff () : sze_(0), difference_(0) { }
419
430 CoinWarmStartBasisDiff (const CoinWarmStartBasisDiff &cwsbd) ;
431
433 CoinWarmStartBasisDiff (int sze, const unsigned int *const diffNdxs,
434 const unsigned int *const diffVals) ;
435
437 CoinWarmStartBasisDiff (const CoinWarmStartBasis * rhs);
438
439 private:
440
441 friend CoinWarmStartDiff*
442 CoinWarmStartBasis::generateDiff(const CoinWarmStart *const oldCWS) const ;
443 friend void
444 CoinWarmStartBasis::applyDiff(const CoinWarmStartDiff *const diff) ;
445
447 int sze_ ;
448
451 unsigned int *difference_ ;
452
453 } ;
454
455
456 #endif
CoinHelperFunctions.hpp
CoinWarmStartBasis::assignBasisStatus
virtual void assignBasisStatus(int ns, int na, char *&sStat, char *&aStat)
Assign the status vectors to be the warm start information.
CoinWarmStartBasis::resize
virtual void resize(int newNumberRows, int newNumberColumns)
Set basis capacity; existing basis is maintained.
CoinWarmStartBasis::deleteColumns
virtual void deleteColumns(int number, const int *which)
Delete a set of columns from the basis.
CoinWarmStartBasisDiff::difference_
unsigned int * difference_
Array of diff indices and diff values.
Definition: CoinWarmStartBasis.hpp:451
CoinWarmStartBasis::fixFullBasis
bool fixFullBasis()
Returns true if full basis and fixes up (for debug)
CoinWarmStartBasis::setSize
virtual void setSize(int ns, int na)
Set basis capacity; existing basis is discarded.
CoinWarmStartBasisDiff::~CoinWarmStartBasisDiff
virtual ~CoinWarmStartBasisDiff()
Destructor.
CoinWarmStartBasis::setStatus
void setStatus(char *array, int i, CoinWarmStartBasis::Status st)
Set the status of the specified variable in the given status array.
Definition: CoinWarmStartBasis.hpp:360
CoinWarmStartBasis::clone
virtual CoinWarmStart * clone() const
`Virtual constructor&#39;
Definition: CoinWarmStartBasis.hpp:284
CoinWarmStartBasis::getStructStatus
Status getStructStatus(int i) const
Return the status of the specified structural variable.
Definition: CoinWarmStartBasis.hpp:99
CoinWarmStartBasis::setStructStatus
void setStructStatus(int i, Status st)
Set the status of the specified structural variable.
Definition: CoinWarmStartBasis.hpp:105
CoinWarmStartBasis::numStructural_
int numStructural_
The number of structural variables.
Definition: CoinWarmStartBasis.hpp:334
CoinWarmStartBasis::getStatus
CoinWarmStartBasis::Status getStatus(const char *array, int i)
Get the status of the specified variable in the given status array.
Definition: CoinWarmStartBasis.hpp:351
CoinWarmStartBasisDiff::CoinWarmStartBasisDiff
CoinWarmStartBasisDiff()
Default constructor.
Definition: CoinWarmStartBasis.hpp:418
CoinWarmStartBasis::atUpperBound
Nonbasic at upper bound.
Definition: CoinWarmStartBasis.hpp:60
CoinWarmStartBasis::CoinWarmStartBasis
CoinWarmStartBasis()
Default constructor.
CoinWarmStartBasis::compressRows
virtual void compressRows(int tgtCnt, const int *tgts)
Delete a set of rows from the basis.
CoinWarmStartBasis
The default COIN simplex (basis-oriented) warm start class.
Definition: CoinWarmStartBasis.hpp:40
CoinWarmStartBasis::setArtifStatus
void setArtifStatus(int i, Status st)
Set the status of the specified artificial variable.
Definition: CoinWarmStartBasis.hpp:137
CoinPrePostsolveMatrix::statusName
const char * statusName(CoinPrePostsolveMatrix::Status status)
Generate a print string for a status code.
CoinWarmStartBasis::mergeBasis
virtual void mergeBasis(const CoinWarmStartBasis *src, const XferVec *xferRows, const XferVec *xferCols)
Merge entries from a source basis into this basis.
CoinWarmStartBasis::getStructuralStatus
char * getStructuralStatus()
Return the status array for the structural variables.
Definition: CoinWarmStartBasis.hpp:116
CoinWarmStartBasis::numberBasicStructurals
int numberBasicStructurals() const
Return the number of basic structurals.
CoinWarmStartBasis::numArtificial_
int numArtificial_
The number of artificial variables.
Definition: CoinWarmStartBasis.hpp:336
CoinWarmStartBasisDiff
A `diff&#39; between two CoinWarmStartBasis objects.
Definition: CoinWarmStartBasis.hpp:395
CoinWarmStartBasis::getArtificialStatus
const char * getArtificialStatus() const
const overload for getArtificialStatus()
Definition: CoinWarmStartBasis.hpp:148
CoinWarmStartBasis::print
virtual void print() const
Prints in readable format (for debug)
CoinWarmStartBasis::fullBasis
bool fullBasis() const
Returns true if full basis (for debug)
CoinTriple
Definition: CoinSort.hpp:459
CoinWarmStartBasisDiff::clone
virtual CoinWarmStartDiff * clone() const
`Virtual constructor&#39;
Definition: CoinWarmStartBasis.hpp:399
CoinWarmStartBasis::isFree
Nonbasic free variable.
Definition: CoinWarmStartBasis.hpp:58
CoinWarmStartBasis::getArtifStatus
Status getArtifStatus(int i) const
Return the status of the specified artificial variable.
Definition: CoinWarmStartBasis.hpp:131
CoinWarmStartBasisDiff::sze_
int sze_
Number of entries (and allocated capacity), in units of int.
Definition: CoinWarmStartBasis.hpp:447
CoinWarmStartBasis::artificialStatus_
char * artificialStatus_
The status of the artificial variables.
Definition: CoinWarmStartBasis.hpp:342
CoinWarmStartBasis::structuralStatus_
char * structuralStatus_
The status of the structural variables.
Definition: CoinWarmStartBasis.hpp:340
CoinSort.hpp
CoinWarmStartBasis::getNumStructural
int getNumStructural() const
Return the number of structural variables.
Definition: CoinWarmStartBasis.hpp:87
CoinWarmStartBasis::XferVec
std::vector< XferEntry > XferVec
Transfer vector for mergeBasis(const CoinWarmStartBasis*,const XferVec*,const XferVec*) ...
Definition: CoinWarmStartBasis.hpp:72
CoinWarmStartBasis::generateDiff
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...
CoinWarmStartBasis::maxSize_
int maxSize_
The maximum sise (in ints - actually 4*char) (so resize does not need to do new)
Definition: CoinWarmStartBasis.hpp:338
CoinWarmStart.hpp
Copyright (C) 2000 – 2003, International Business Machines Corporation and others.
CoinWarmStartBasis::getStructuralStatus
const char * getStructuralStatus() const
const overload for getStructuralStatus()
Definition: CoinWarmStartBasis.hpp:123
CoinWarmStartBasis::basic
Basic variable.
Definition: CoinWarmStartBasis.hpp:59
CoinWarmStartBasisDiff::operator=
virtual CoinWarmStartBasisDiff & operator=(const CoinWarmStartBasisDiff &rhs)
Assignment.
CoinWarmStartDiff
Abstract base class for warm start `diff&#39; objects.
Definition: CoinWarmStart.hpp:48
CoinWarmStartBasis::~CoinWarmStartBasis
virtual ~CoinWarmStartBasis()
Destructor.
CoinWarmStartBasis::Status
Status
Enum for status of variables.
Definition: CoinWarmStartBasis.hpp:57
CoinWarmStartBasis::atLowerBound
Nonbasic at lower bound.
Definition: CoinWarmStartBasis.hpp:61
CoinWarmStartBasis::getNumArtificial
int getNumArtificial() const
Return the number of artificial variables.
Definition: CoinWarmStartBasis.hpp:90
CoinWarmStartBasis::operator=
virtual CoinWarmStartBasis & operator=(const CoinWarmStartBasis &rhs)
Assignment.
CoinWarmStartBasis::getArtificialStatus
char * getArtificialStatus()
As for getStructuralStatus , but returns the status array for the artificial variables.
Definition: CoinWarmStartBasis.hpp:128
CoinWarmStartBasis::deleteRows
virtual void deleteRows(int rawTgtCnt, const int *rawTgts)
Delete a set of rows from the basis.
CoinWarmStartBasis::applyDiff
virtual void applyDiff(const CoinWarmStartDiff *const cwsdDiff)
Apply diff to this basis.
CoinWarmStart
Abstract base class for warm start information.
Definition: CoinWarmStart.hpp:21
CoinWarmStartBasis::XferEntry
CoinTriple< int, int, int > XferEntry
Transfer vector entry for mergeBasis(const CoinWarmStartBasis*,const XferVec*,const XferVec*) ...
Definition: CoinWarmStartBasis.hpp:67