Clp 1.17.6

- 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 2083 2019-01-06 19:38:09Z unxusr $ */
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:
56 enum Status {
57 isFree = 0x00,
58 basic = 0x01,
59 atUpperBound = 0x02,
60 atLowerBound = 0x03,
61 superBasic = 0x04
62 };
63
67 typedef CoinTriple< int, int, int > XferEntry;
68
72 typedef std::vector< XferEntry > XferVec;
73
74 public:
85 inline int getNumStructural() const { return numStructural_; }
87
89 inline int getNumArtificial() const { return numArtificial_; }
90
95 int numberBasicStructurals() const;
96
98 inline Status getStructStatus(int i) const
99 {
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 {
107 char &st_byte = structuralStatus_[i >> 2];
108 st_byte = static_cast< char >(st_byte & ~(3 << ((i & 3) << 1)));
109 st_byte = static_cast< char >(st_byte | (st << ((i & 3) << 1)));
110 }
111
117 inline char *getStructuralStatus() { return structuralStatus_; }
118
124 inline const char *getStructuralStatus() const { return structuralStatus_; }
125
129 inline char *getArtificialStatus() { return artificialStatus_; }
130
132 inline Status getArtifStatus(int i) const
133 {
134 const int st = (artificialStatus_[i >> 2] >> ((i & 3) << 1)) & 3;
135 return static_cast< CoinWarmStartBasis::Status >(st);
136 }
137
139 inline void setArtifStatus(int i, Status st)
140 {
141 char &st_byte = artificialStatus_[i >> 2];
142 st_byte = static_cast< char >(st_byte & ~(3 << ((i & 3) << 1)));
143 st_byte = static_cast< char >(st_byte | (st << ((i & 3) << 1)));
144 }
145
151 inline const char *getArtificialStatus() const { return artificialStatus_; }
153
156
164 virtual CoinWarmStartDiff *
165 generateDiff(const CoinWarmStart *const oldCWS) const;
166
173 virtual void
174 applyDiff(const CoinWarmStartDiff *const cwsdDiff);
175
177
180
186 virtual void setSize(int ns, int na);
187
196 virtual void resize(int newNumberRows, int newNumberColumns);
197
214 virtual void compressRows(int tgtCnt, const int *tgts);
215
227 virtual void deleteRows(int rawTgtCnt, const int *rawTgts);
228
239 virtual void deleteColumns(int number, const int *which);
240
253 virtual void mergeBasis(const CoinWarmStartBasis *src,
254 const XferVec *xferRows,
255 const XferVec *xferCols);
256
258
262
268 CoinWarmStartBasis();
269
279 CoinWarmStartBasis(int ns, int na, const char *sStat, const char *aStat);
280
282 CoinWarmStartBasis(const CoinWarmStartBasis &ws);
283
285 virtual CoinWarmStart *clone() const
286 {
287 return new CoinWarmStartBasis(*this);
288 }
289
291 virtual ~CoinWarmStartBasis();
292
295 virtual CoinWarmStartBasis &operator=(const CoinWarmStartBasis &rhs);
296
312 virtual void assignBasisStatus(int ns, int na, char *&sStat, char *&aStat);
314
317
319 virtual void print() const;
321 bool fullBasis() const;
323 bool fixFullBasis();
324
326
327 protected:
334 int numStructural_;
337 int numArtificial_;
339 int maxSize_;
341 char *structuralStatus_;
343 char *artificialStatus_;
345 };
346
351 inline CoinWarmStartBasis::Status getStatus(const char *array, int i)
352 {
353 const int st = (array[i >> 2] >> ((i & 3) << 1)) & 3;
354 return static_cast< CoinWarmStartBasis::Status >(st);
355 }
356
361 inline void setStatus(char *array, int i, CoinWarmStartBasis::Status st)
362 {
363 char &st_byte = array[i >> 2];
364 st_byte = static_cast< char >(st_byte & ~(3 << ((i & 3) << 1)));
365 st_byte = static_cast< char >(st_byte | (st << ((i & 3) << 1)));
366 }
367
371 const char *statusName(CoinWarmStartBasis::Status status);
376 char statusToChar(CoinWarmStartBasis::Status status);
379 CoinWarmStartBasis::Status charToStatus(char status);
380
404 class CoinWarmStartBasisDiff : public virtual CoinWarmStartDiff {
405 public:
407 virtual CoinWarmStartDiff *clone() const
408 {
409 CoinWarmStartBasisDiff *cwsbd = new CoinWarmStartBasisDiff(*this);
410 return (dynamic_cast< CoinWarmStartDiff * >(cwsbd));
411 }
412
414 virtual CoinWarmStartBasisDiff &operator=(const CoinWarmStartBasisDiff &rhs);
415
417 virtual ~CoinWarmStartBasisDiff();
418
419 protected:
426 CoinWarmStartBasisDiff()
427 : sze_(0)
428 , difference_(0)
429 {
430 }
431
442 CoinWarmStartBasisDiff(const CoinWarmStartBasisDiff &cwsbd);
443
445 CoinWarmStartBasisDiff(int sze, const unsigned int *const diffNdxs,
446 const unsigned int *const diffVals);
447
449 CoinWarmStartBasisDiff(const CoinWarmStartBasis *rhs);
450
451 private:
452 friend CoinWarmStartDiff *
453 CoinWarmStartBasis::generateDiff(const CoinWarmStart *const oldCWS) const;
454 friend void
455 CoinWarmStartBasis::applyDiff(const CoinWarmStartDiff *const diff);
456
458 int sze_;
459
462 unsigned int *difference_;
463 };
464
465 #endif
466
467 /* vi: softtabstop=2 shiftwidth=2 expandtab tabstop=2
468 */
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:462
CoinWarmStartBasis::XferEntry
CoinTriple< int, int, int > XferEntry
Transfer vector entry for mergeBasis(const CoinWarmStartBasis*,const XferVec*,const XferVec*) ...
Definition: CoinWarmStartBasis.hpp:67
CoinWarmStartBasis::fixFullBasis
bool fixFullBasis()
Returns true if full basis and fixes up (for debug)
charToStatus
CoinWarmStartBasis::Status charToStatus(char status)
Convert character to status.
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:361
CoinWarmStartBasis::clone
virtual CoinWarmStart * clone() const
`Virtual constructor&#39;
Definition: CoinWarmStartBasis.hpp:285
CoinWarmStartBasis::getStructStatus
Status getStructStatus(int i) const
Return the status of the specified structural variable.
Definition: CoinWarmStartBasis.hpp:98
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:335
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
CoinWarmStartBasis::superBasic
Not basic and not at bound.
Definition: CoinWarmStartBasis.hpp:61
CoinWarmStartBasisDiff::CoinWarmStartBasisDiff
CoinWarmStartBasisDiff()
Default constructor.
Definition: CoinWarmStartBasis.hpp:426
CoinWarmStartBasis::atUpperBound
Nonbasic at upper bound.
Definition: CoinWarmStartBasis.hpp:59
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:139
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:117
CoinWarmStartBasis::numberBasicStructurals
int numberBasicStructurals() const
Return the number of basic structurals.
CoinWarmStartBasis::numArtificial_
int numArtificial_
The number of artificial variables.
Definition: CoinWarmStartBasis.hpp:337
CoinWarmStartBasisDiff
A `diff&#39; between two CoinWarmStartBasis objects.
Definition: CoinWarmStartBasis.hpp:404
CoinWarmStartBasis::getArtificialStatus
const char * getArtificialStatus() const
const overload for getArtificialStatus()
Definition: CoinWarmStartBasis.hpp:151
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:509
CoinWarmStartBasisDiff::clone
virtual CoinWarmStartDiff * clone() const
`Virtual constructor&#39;
Definition: CoinWarmStartBasis.hpp:407
CoinWarmStartBasis::isFree
Nonbasic free variable.
Definition: CoinWarmStartBasis.hpp:57
CoinWarmStartBasis::getArtifStatus
Status getArtifStatus(int i) const
Return the status of the specified artificial variable.
Definition: CoinWarmStartBasis.hpp:132
CoinWarmStartBasisDiff::sze_
int sze_
Number of entries (and allocated capacity), in units of int.
Definition: CoinWarmStartBasis.hpp:458
CoinWarmStartBasis::artificialStatus_
char * artificialStatus_
The status of the artificial variables.
Definition: CoinWarmStartBasis.hpp:343
CoinWarmStartBasis::structuralStatus_
char * structuralStatus_
The status of the structural variables.
Definition: CoinWarmStartBasis.hpp:341
CoinSort.hpp
CoinWarmStartBasis::getNumStructural
int getNumStructural() const
Return the number of structural variables.
Definition: CoinWarmStartBasis.hpp:86
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:339
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:124
CoinWarmStartBasis::basic
Basic variable.
Definition: CoinWarmStartBasis.hpp:58
CoinWarmStartBasisDiff::operator=
virtual CoinWarmStartBasisDiff & operator=(const CoinWarmStartBasisDiff &rhs)
Assignment.
CoinWarmStartDiff
Abstract base class for warm start `diff&#39; objects.
Definition: CoinWarmStart.hpp:44
CoinWarmStartBasis::~CoinWarmStartBasis
virtual ~CoinWarmStartBasis()
Destructor.
CoinWarmStartBasis::XferVec
std::vector< XferEntry > XferVec
Transfer vector for mergeBasis(const CoinWarmStartBasis*,const XferVec*,const XferVec*) ...
Definition: CoinWarmStartBasis.hpp:72
CoinWarmStartBasis::Status
Status
Enum for status of variables.
Definition: CoinWarmStartBasis.hpp:56
CoinWarmStartBasis::atLowerBound
Nonbasic at lower bound.
Definition: CoinWarmStartBasis.hpp:60
CoinWarmStartBasis::getNumArtificial
int getNumArtificial() const
Return the number of artificial variables.
Definition: CoinWarmStartBasis.hpp:89
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:129
CoinWarmStartBasis::deleteRows
virtual void deleteRows(int rawTgtCnt, const int *rawTgts)
Delete a set of rows from the basis.
statusToChar
char statusToChar(CoinWarmStartBasis::Status status)
In an example Aleksandr Kazachkov sent to me, I noticed he was using code as above but with char - it...
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