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

- Alphabetical List
- Class List
- Class Hierarchy
- Class Members

# CoinWarmStartBasis Class Reference

The default COIN simplex (basis-oriented) warm start class. More...

`#include <CoinWarmStartBasis.hpp>`

Inheritance diagram for CoinWarmStartBasis:

[legend]
Collaboration diagram for CoinWarmStartBasis:

[legend]
List of all members.

## Public Types
typedef CoinTriple< int, int, int > | XferEntry
| Transfer vector entry for mergeBasis(const CoinWarmStartBasis*,const XferVec*,const XferVec*).
typedef std::vector< XferEntry > | XferVec
| Transfer vector for mergeBasis(const CoinWarmStartBasis*,const XferVec*,const XferVec*).
| isFree = 0x00
| Nonbasic free variable.
| basic = 0x01
| Basic variable.
| atUpperBound = 0x02
| Nonbasic at upper bound.
| atLowerBound = 0x03
| Nonbasic at lower bound.
enum | Status { isFree = 0x00, basic = 0x01, atUpperBound = 0x02, atLowerBound = 0x03 }
| Enum for status of variables. More...
## Public Member Functions
Methods to get and set basis information.
The status of variables is kept in a pair of arrays, one for structural variables, and one for artificials (aka logicals and slacks). The status is coded using the values of the Status enum. See also: CoinWarmStartBasis::Status for a description of the packing used in the status arrays.
int | getNumStructural () const
| Return the number of structural variables.
int | getNumArtificial () const
| Return the number of artificial variables.
int | numberBasicStructurals () const
| Return the number of basic structurals.
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.
char * | getStructuralStatus ()
| Return the status array for the structural variables.
const char * | getStructuralStatus () const
| `const` overload for getStructuralStatus()
char * | getArtificialStatus ()
| As for getStructuralStatus , but returns the status array for the artificial variables.
Status | getArtifStatus (int i) const
| Return the status of the specified artificial variable.
void | setArtifStatus (int i, Status st)
| Set the status of the specified artificial variable.
const char * | getArtificialStatus () const
| `const` overload for getArtificialStatus()
Basis `diff' methods
virtual CoinWarmStartDiff * | generateDiff (const CoinWarmStart *const oldCWS) const
| Generate a `diff' that can convert the warm start basis passed as a parameter to the warm start basis specified by `this`.
virtual void | applyDiff (const CoinWarmStartDiff *const cwsdDiff)
| Apply `diff` to this basis.
Methods to modify the warm start object
virtual void | setSize (int ns, int na)
| Set basis capacity; existing basis is discarded.
virtual void | resize (int newNumberRows, int newNumberColumns)
| Set basis capacity; existing basis is maintained.
virtual void | compressRows (int tgtCnt, const int *tgts)
| Delete a set of rows from the basis.
virtual void | deleteRows (int rawTgtCnt, const int *rawTgts)
| Delete a set of rows from the basis.
virtual void | deleteColumns (int number, const int *which)
| Delete a set of columns from the basis.
virtual void | mergeBasis (const CoinWarmStartBasis *src, const XferVec *xferRows, const XferVec *xferCols)
| Merge entries from a source basis into this basis.
Constructors, destructors, and related functions
| CoinWarmStartBasis ()
| Default constructor.
| CoinWarmStartBasis (int ns, int na, const char *sStat, const char *aStat)
| Constructs a warm start object with the specified status vectors.
| CoinWarmStartBasis (const CoinWarmStartBasis &ws)
| Copy constructor.
virtual CoinWarmStart * | clone () const
| `Virtual constructor'
virtual | ~CoinWarmStartBasis ()
| Destructor.
virtual CoinWarmStartBasis & | operator= (const CoinWarmStartBasis &rhs)
| Assignment.
virtual void | assignBasisStatus (int ns, int na, char *&sStat, char *&aStat)
| Assign the status vectors to be the warm start information.
Miscellaneous methods
virtual void | print () const
| Prints in readable format (for debug).
## Protected Attributes
Protected data members
See also: CoinWarmStartBasis::Status for a description of the packing used in the status arrays.
int | numStructural_
| The number of structural variables.
int | numArtificial_
| The number of artificial variables.
int | maxSize_
| The maximum sise (in ints - actually 4*char) (so resize does not need to do new).
char * | structuralStatus_
| The status of the structural variables.
char * | artificialStatus_
| The status of the artificial variables.
## Related Functions
(Note that these are not member functions.)
CoinWarmStartBasis::Status | getStatus (const char *array, int i)
| Get the status of the specified variable in the given status array.
void | setStatus (char *array, int i, CoinWarmStartBasis::Status st)
| Set the status of the specified variable in the given status array.

## Detailed Description

The default COIN simplex (basis-oriented) warm start class.

CoinWarmStartBasis provides for a warm start object which contains the status of each variable (structural and artificial).

Todo:
  Modify this class so that the number of status entries per byte and bytes per status vector allocation unit are not hardcoded. At the least, collect this into a couple of macros.

Todo:
  Consider separate fields for allocated capacity and actual basis size. We could avoid some reallocation, at the price of retaining more space than we need. Perhaps more important, we could do much better sanity checks.

Definition at line 38 of file CoinWarmStartBasis.hpp.

## Member Typedef Documentation

typedef CoinTriple<int,int,int> CoinWarmStartBasis::XferEntry

Transfer vector entry for mergeBasis(const CoinWarmStartBasis*,const XferVec*,const XferVec*).

Definition at line 65 of file CoinWarmStartBasis.hpp.

typedef std::vector<XferEntry> CoinWarmStartBasis::XferVec

Transfer vector for mergeBasis(const CoinWarmStartBasis*,const XferVec*,const XferVec*).

Definition at line 70 of file CoinWarmStartBasis.hpp.

## Member Enumeration Documentation

enum CoinWarmStartBasis::Status

Enum for status of variables.

Matches CoinPrePostsolveMatrix::Status, without superBasic. Most code that converts between CoinPrePostsolveMatrix::Status and CoinWarmStartBasis::Status will break if this correspondence is broken.

The status vectors are currently packed using two bits per status code, four codes per byte. The location of the status information for variable `i` is in byte `i>>2` and occupies bits 0:1 if `i%4 == 0`, bits 2:3 if `i%4 == 1`, etc. The non-member functions getStatus(const char*,int) and setStatus(char*,int,CoinWarmStartBasis::Status) are provided to hide details of the packing.

Enumerator:

  isFree | Nonbasic free variable.
  basic | Basic variable.
  atUpperBound | Nonbasic at upper bound.
  atLowerBound | Nonbasic at lower bound.

Definition at line 55 of file CoinWarmStartBasis.hpp.

## Constructor & Destructor Documentation

CoinWarmStartBasis::CoinWarmStartBasis | ( |  | ) |

Default constructor.

Creates a warm start object representing an empty basis (0 rows, 0 columns).

Referenced by clone().

CoinWarmStartBasis::CoinWarmStartBasis | ( | int | ns,
|  | int | na,
|  | const char * | sStat,
|  | const char * | aStat |
| ) |  |  |

Constructs a warm start object with the specified status vectors.

The parameters are copied. Consider assignBasisStatus(int,int,char*&,char*&) if the object should assume ownership.

See also:
  CoinWarmStartBasis::Status for a description of the packing used in the status arrays.

CoinWarmStartBasis::CoinWarmStartBasis | ( | const CoinWarmStartBasis & | ws | ) |

Copy constructor.

virtual CoinWarmStartBasis::~CoinWarmStartBasis | ( |  | ) | `[virtual]`

Destructor.

## Member Function Documentation

int CoinWarmStartBasis::getNumStructural | ( |  | ) | const`[inline]`

Return the number of structural variables.

Definition at line 85 of file CoinWarmStartBasis.hpp.

References numStructural_.

int CoinWarmStartBasis::getNumArtificial | ( |  | ) | const`[inline]`

Return the number of artificial variables.

Definition at line 88 of file CoinWarmStartBasis.hpp.

References numArtificial_.

int CoinWarmStartBasis::numberBasicStructurals | ( |  | ) | const

Return the number of basic structurals.

A fast test for an all-slack basis.

Status CoinWarmStartBasis::getStructStatus | ( | int | i | ) | const`[inline]`

Return the status of the specified structural variable.

Definition at line 97 of file CoinWarmStartBasis.hpp.

References structuralStatus_.

void CoinWarmStartBasis::setStructStatus | ( | int | i,
|  | Status | st |
| ) |  |  | `[inline]`

Set the status of the specified structural variable.

Definition at line 103 of file CoinWarmStartBasis.hpp.

References structuralStatus_.

char* CoinWarmStartBasis::getStructuralStatus | ( |  | ) | `[inline]`

Return the status array for the structural variables.

The status information is stored using the codes defined in the Status enum, 2 bits per variable, packed 4 variables per byte.

Definition at line 114 of file CoinWarmStartBasis.hpp.

References structuralStatus_.

const char* CoinWarmStartBasis::getStructuralStatus | ( |  | ) | const`[inline]`

`const` overload for getStructuralStatus()

Definition at line 121 of file CoinWarmStartBasis.hpp.

References structuralStatus_.

char* CoinWarmStartBasis::getArtificialStatus | ( |  | ) | `[inline]`

As for getStructuralStatus , but returns the status array for the artificial variables.

Definition at line 126 of file CoinWarmStartBasis.hpp.

References artificialStatus_.

Status CoinWarmStartBasis::getArtifStatus | ( | int | i | ) | const`[inline]`

Return the status of the specified artificial variable.

Definition at line 129 of file CoinWarmStartBasis.hpp.

References artificialStatus_.

void CoinWarmStartBasis::setArtifStatus | ( | int | i,
|  | Status | st |
| ) |  |  | `[inline]`

Set the status of the specified artificial variable.

Definition at line 135 of file CoinWarmStartBasis.hpp.

References artificialStatus_.

const char* CoinWarmStartBasis::getArtificialStatus | ( |  | ) | const`[inline]`

`const` overload for getArtificialStatus()

Definition at line 146 of file CoinWarmStartBasis.hpp.

References artificialStatus_.

virtual CoinWarmStartDiff* CoinWarmStartBasis::generateDiff | ( | const CoinWarmStart *const | oldCWS | ) | const`[virtual]`

Generate a `diff' that can convert the warm start basis passed as a parameter to the warm start basis specified by `this`.

The capabilities are limited: the basis passed as a parameter can be no larger than the basis pointed to by `this`.

Reimplemented from CoinWarmStart.

Reimplemented in OsiDylpWarmStartBasis.

virtual void CoinWarmStartBasis::applyDiff | ( | const CoinWarmStartDiff *const | cwsdDiff | ) | `[virtual]`

Apply `diff` to this basis.

Update this basis by applying `diff`. It's assumed that the allocated capacity of the basis is sufficiently large.

Reimplemented from CoinWarmStart.

Reimplemented in OsiDylpWarmStartBasis.

virtual void CoinWarmStartBasis::setSize | ( | int | ns,
|  | int | na |
| ) |  |  | `[virtual]`

Set basis capacity; existing basis is discarded.

After execution of this routine, the warm start object does not describe a valid basis: all structural and artificial variables have status isFree.

Reimplemented in OsiDylpWarmStartBasis.

virtual void CoinWarmStartBasis::resize | ( | int | newNumberRows,
|  | int | newNumberColumns |
| ) |  |  | `[virtual]`

Set basis capacity; existing basis is maintained.

After execution of this routine, the warm start object describes a valid basis: the status of new structural variables (added columns) is set to nonbasic at lower bound, and the status of new artificial variables (added rows) is set to basic. (The basis can be invalid if new structural variables do not have a finite lower bound.)

Reimplemented in OsiDylpWarmStartBasis.

virtual void CoinWarmStartBasis::compressRows | ( | int | tgtCnt,
|  | const int * | tgts |
| ) |  |  | `[virtual]`

Delete a set of rows from the basis.

Warning:
  This routine assumes that the set of indices to be deleted is sorted in ascending order and contains no duplicates. Use deleteRows() if this is not the case.

  The resulting basis is guaranteed valid only if all deleted constraints are slack (hence the associated logicals are basic).

Removal of a tight constraint with a nonbasic logical implies that some basic variable must be made nonbasic. This correction is left to the client.

Reimplemented in OsiDylpWarmStartBasis.

virtual void CoinWarmStartBasis::deleteRows | ( | int | rawTgtCnt,
|  | const int * | rawTgts |
| ) |  |  | `[virtual]`

Delete a set of rows from the basis.

Warning:
  The resulting basis is guaranteed valid only if all deleted constraints are slack (hence the associated logicals are basic).

Removal of a tight constraint with a nonbasic logical implies that some basic variable must be made nonbasic. This correction is left to the client.

Reimplemented in OsiDylpWarmStartBasis.

virtual void CoinWarmStartBasis::deleteColumns | ( | int | number,
|  | const int * | which |
| ) |  |  | `[virtual]`

Delete a set of columns from the basis.

Warning:
  The resulting basis is guaranteed valid only if all deleted variables are nonbasic.

Removal of a basic variable implies that some nonbasic variable must be made basic. This correction is left to the client.

virtual void CoinWarmStartBasis::mergeBasis | ( | const CoinWarmStartBasis * | src,
|  | const XferVec * | xferRows,
|  | const XferVec * | xferCols |
| ) |  |  | `[virtual]`

Merge entries from a source basis into this basis.

Warning:
  It's the client's responsibility to ensure validity of the merged basis, if that's important to the application.

The vector xferCols (xferRows) specifies runs of entries to be taken from the source basis and placed in this basis. Each entry is a CoinTriple, with first specifying the starting source index of a run, second specifying the starting destination index, and third specifying the run length.

virtual CoinWarmStart* CoinWarmStartBasis::clone | ( |  | ) | const`[inline, virtual]`

`Virtual constructor'

Implements CoinWarmStart.

Reimplemented in OsiDylpWarmStartBasis.

Definition at line 282 of file CoinWarmStartBasis.hpp.

References CoinWarmStartBasis().

virtual CoinWarmStartBasis& CoinWarmStartBasis::operator= | ( | const CoinWarmStartBasis & | rhs | ) | `[virtual]`

Assignment.

virtual void CoinWarmStartBasis::assignBasisStatus | ( | int | ns,
|  | int | na,
|  | char *& | sStat,
|  | char *& | aStat |
| ) |  |  | `[virtual]`

Assign the status vectors to be the warm start information.

In this method the CoinWarmStartBasis object assumes ownership of the pointers and upon return the argument pointers will be NULL. If copying is desirable, use the array constructor or the assignment operator .

Note:
  The pointers passed to this method will be freed using delete[], so they must be created using new[].

Reimplemented in OsiDylpWarmStartBasis.

virtual void CoinWarmStartBasis::print | ( |  | ) | const`[virtual]`

Prints in readable format (for debug).

Reimplemented in OsiDylpWarmStartBasis.

## Friends And Related Function Documentation

CoinWarmStartBasis::Status getStatus | ( | const char * | array,
|  | int | i |
| ) |  |  | `[related]`

Get the status of the specified variable in the given status array.

Definition at line 345 of file CoinWarmStartBasis.hpp.

void setStatus | ( | char * | array,
|  | int | i,
|  | CoinWarmStartBasis::Status | st |
| ) |  |  | `[related]`

Set the status of the specified variable in the given status array.

Definition at line 354 of file CoinWarmStartBasis.hpp.

## Member Data Documentation

int CoinWarmStartBasis::numStructural_`[protected]`

The number of structural variables.

Definition at line 328 of file CoinWarmStartBasis.hpp.

Referenced by getNumStructural().

int CoinWarmStartBasis::numArtificial_`[protected]`

The number of artificial variables.

Definition at line 330 of file CoinWarmStartBasis.hpp.

Referenced by getNumArtificial().

int CoinWarmStartBasis::maxSize_`[protected]`

The maximum sise (in ints - actually 4*char) (so resize does not need to do new).

Definition at line 332 of file CoinWarmStartBasis.hpp.

char* CoinWarmStartBasis::structuralStatus_`[protected]`

The status of the structural variables.

Definition at line 334 of file CoinWarmStartBasis.hpp.

Referenced by getStructStatus(), getStructuralStatus(), and setStructStatus().

char* CoinWarmStartBasis::artificialStatus_`[protected]`

The status of the artificial variables.

Definition at line 336 of file CoinWarmStartBasis.hpp.

Referenced by getArtificialStatus(), getArtifStatus(), and setArtifStatus().

The documentation for this class was generated from the following file:

- /home/coin/SVN-release/Cgl-0.52.0/CoinUtils/src/CoinWarmStartBasis.hpp