#include <CbcFathomDynamicProgramming.hpp>
Inheritance diagram for CbcFathomDynamicProgramming:
Public Member Functions | |
CbcFathomDynamicProgramming () | |
CbcFathomDynamicProgramming (CbcModel &model) | |
CbcFathomDynamicProgramming (const CbcFathomDynamicProgramming &rhs) | |
virtual | ~CbcFathomDynamicProgramming () |
virtual void | setModel (CbcModel *model) |
update model (This is needed if cliques update matrix etc) | |
virtual CbcFathom * | clone () const |
Clone. | |
virtual void | resetModel (CbcModel *model) |
Resets stuff if model changes. | |
virtual int | fathom (double *&newSolution) |
returns 0 if no fathoming attempted, 1 fully fathomed , 2 incomplete search, 3 incomplete search but treat as complete. | |
int | maximumSize () const |
Maximum size allowed. | |
void | setMaximumSize (int value) |
int | checkPossible (int allowableSize=0) |
Returns type of algorithm and sets up arrays. | |
void | setAlgorithm (int value) |
bool | tryColumn (int numberElements, const int *rows, const double *coefficients, double cost, int upper=COIN_INT_MAX) |
Tries a column returns true if was used in making any changes. | |
const double * | cost () const |
Returns cost array. | |
const int * | back () const |
Returns back array. | |
int | target () const |
Gets bit pattern for target result. | |
void | setTarget (int value) |
Sets bit pattern for target result. | |
Protected Attributes | |
int | size_ |
Size of states (power of 2 unless just one constraint). | |
int | type_ |
Type - 0 coefficients and rhs all 1, 1 - coefficients > 1 or rhs > 1. | |
double * | cost_ |
Space for states. | |
int * | back_ |
Which state produced this cheapest one. | |
int * | lookup_ |
Some rows may be satisified so we need a lookup. | |
int * | indices_ |
Space for sorted indices. | |
int | numberActive_ |
Number of active rows. | |
int | maximumSizeAllowed_ |
Maximum size allowed. | |
int * | startBit_ |
Start bit for each active row. | |
int * | numberBits_ |
Number bits for each active row. | |
int * | rhs_ |
Effective rhs. | |
int * | coefficients_ |
Space for sorted coefficients. | |
int | target_ |
Target pattern. | |
int | numberNonOne_ |
Number of Non 1 rhs. | |
int | bitPattern_ |
Current bit pattern. | |
int | algorithm_ |
Current algorithm. | |
Private Member Functions | |
void | gutsOfDelete () |
Does deleteions. | |
bool | addOneColumn0 (int numberElements, const int *rows, double cost) |
Adds one attempt of one column of type 0, returns true if was used in making any changes. | |
bool | addOneColumn1 (int numberElements, const int *rows, const int *coefficients, double cost) |
Adds one attempt of one column of type 1, returns true if was used in making any changes. | |
bool | addOneColumn1A (int numberElements, const int *rows, const int *coefficients, double cost) |
Adds one attempt of one column of type 1, returns true if was used in making any changes. | |
int | bitPattern (int numberElements, const int *rows, const int *coefficients) |
Gets bit pattern from original column. | |
int | bitPattern (int numberElements, const int *rows, const double *coefficients) |
Gets bit pattern from original column. | |
int | decodeBitPattern (int bitPattern, int *values, int numberRows) |
Fills in original column (dense) from bit pattern - returning number nonzero. | |
CbcFathomDynamicProgramming & | operator= (const CbcFathomDynamicProgramming &rhs) |
Illegal Assignment operator. |
The idea is that after some branching the problem will be effectively smaller than the original problem and maybe there will be a more specialized technique which can completely fathom this branch quickly.
This is a dynamic programming implementation which is very fast for some specialized problems. It expects small integral rhs, an all integer problem and positive integral coefficients. At present it can not do general set covering problems just set partitioning. It can find multiple optima for various rhs combinations.
The main limiting factor is size of state space. Each 1 rhs doubles the size of the problem. 2 or 3 rhs quadruples, 4,5,6,7 by 8 etc.
Definition at line 25 of file CbcFathomDynamicProgramming.hpp.
CbcFathomDynamicProgramming::CbcFathomDynamicProgramming | ( | ) |
CbcFathomDynamicProgramming::CbcFathomDynamicProgramming | ( | CbcModel & | model | ) |
CbcFathomDynamicProgramming::CbcFathomDynamicProgramming | ( | const CbcFathomDynamicProgramming & | rhs | ) |
virtual CbcFathomDynamicProgramming::~CbcFathomDynamicProgramming | ( | ) | [virtual] |
virtual void CbcFathomDynamicProgramming::setModel | ( | CbcModel * | model | ) | [virtual] |
virtual CbcFathom* CbcFathomDynamicProgramming::clone | ( | ) | const [virtual] |
virtual void CbcFathomDynamicProgramming::resetModel | ( | CbcModel * | model | ) | [virtual] |
virtual int CbcFathomDynamicProgramming::fathom | ( | double *& | newSolution | ) | [virtual] |
returns 0 if no fathoming attempted, 1 fully fathomed , 2 incomplete search, 3 incomplete search but treat as complete.
If solution then newSolution will not be NULL and will be freed by CbcModel. It is expected that the solution is better than best so far but CbcModel will double check.
If returns 3 then of course there is no guarantee of global optimum
Implements CbcFathom.
int CbcFathomDynamicProgramming::maximumSize | ( | ) | const [inline] |
Maximum size allowed.
Definition at line 57 of file CbcFathomDynamicProgramming.hpp.
References maximumSizeAllowed_.
void CbcFathomDynamicProgramming::setMaximumSize | ( | int | value | ) | [inline] |
int CbcFathomDynamicProgramming::checkPossible | ( | int | allowableSize = 0 |
) |
Returns type of algorithm and sets up arrays.
void CbcFathomDynamicProgramming::setAlgorithm | ( | int | value | ) | [inline] |
bool CbcFathomDynamicProgramming::tryColumn | ( | int | numberElements, | |
const int * | rows, | |||
const double * | coefficients, | |||
double | cost, | |||
int | upper = COIN_INT_MAX | |||
) |
Tries a column returns true if was used in making any changes.
const double* CbcFathomDynamicProgramming::cost | ( | ) | const [inline] |
Returns cost array.
Definition at line 73 of file CbcFathomDynamicProgramming.hpp.
References cost_.
const int* CbcFathomDynamicProgramming::back | ( | ) | const [inline] |
Returns back array.
Definition at line 76 of file CbcFathomDynamicProgramming.hpp.
References back_.
int CbcFathomDynamicProgramming::target | ( | ) | const [inline] |
Gets bit pattern for target result.
Definition at line 79 of file CbcFathomDynamicProgramming.hpp.
References target_.
void CbcFathomDynamicProgramming::setTarget | ( | int | value | ) | [inline] |
Sets bit pattern for target result.
Definition at line 82 of file CbcFathomDynamicProgramming.hpp.
References target_.
void CbcFathomDynamicProgramming::gutsOfDelete | ( | ) | [private] |
Does deleteions.
bool CbcFathomDynamicProgramming::addOneColumn0 | ( | int | numberElements, | |
const int * | rows, | |||
double | cost | |||
) | [private] |
Adds one attempt of one column of type 0, returns true if was used in making any changes.
bool CbcFathomDynamicProgramming::addOneColumn1 | ( | int | numberElements, | |
const int * | rows, | |||
const int * | coefficients, | |||
double | cost | |||
) | [private] |
Adds one attempt of one column of type 1, returns true if was used in making any changes.
At present the user has to call it once for each possible value
bool CbcFathomDynamicProgramming::addOneColumn1A | ( | int | numberElements, | |
const int * | rows, | |||
const int * | coefficients, | |||
double | cost | |||
) | [private] |
Adds one attempt of one column of type 1, returns true if was used in making any changes.
At present the user has to call it once for each possible value. This version is when there are enough 1 rhs to do faster
int CbcFathomDynamicProgramming::bitPattern | ( | int | numberElements, | |
const int * | rows, | |||
const int * | coefficients | |||
) | [private] |
Gets bit pattern from original column.
int CbcFathomDynamicProgramming::bitPattern | ( | int | numberElements, | |
const int * | rows, | |||
const double * | coefficients | |||
) | [private] |
Gets bit pattern from original column.
int CbcFathomDynamicProgramming::decodeBitPattern | ( | int | bitPattern, | |
int * | values, | |||
int | numberRows | |||
) | [private] |
Fills in original column (dense) from bit pattern - returning number nonzero.
CbcFathomDynamicProgramming& CbcFathomDynamicProgramming::operator= | ( | const CbcFathomDynamicProgramming & | rhs | ) | [private] |
Illegal Assignment operator.
int CbcFathomDynamicProgramming::size_ [protected] |
Size of states (power of 2 unless just one constraint).
Definition at line 118 of file CbcFathomDynamicProgramming.hpp.
int CbcFathomDynamicProgramming::type_ [protected] |
Type - 0 coefficients and rhs all 1, 1 - coefficients > 1 or rhs > 1.
Definition at line 122 of file CbcFathomDynamicProgramming.hpp.
double* CbcFathomDynamicProgramming::cost_ [protected] |
Space for states.
Definition at line 124 of file CbcFathomDynamicProgramming.hpp.
Referenced by cost().
int* CbcFathomDynamicProgramming::back_ [protected] |
Which state produced this cheapest one.
Definition at line 126 of file CbcFathomDynamicProgramming.hpp.
Referenced by back().
int* CbcFathomDynamicProgramming::lookup_ [protected] |
Some rows may be satisified so we need a lookup.
Definition at line 128 of file CbcFathomDynamicProgramming.hpp.
int* CbcFathomDynamicProgramming::indices_ [protected] |
int CbcFathomDynamicProgramming::numberActive_ [protected] |
int CbcFathomDynamicProgramming::maximumSizeAllowed_ [protected] |
Maximum size allowed.
Definition at line 134 of file CbcFathomDynamicProgramming.hpp.
Referenced by maximumSize(), and setMaximumSize().
int* CbcFathomDynamicProgramming::startBit_ [protected] |
int* CbcFathomDynamicProgramming::numberBits_ [protected] |
int* CbcFathomDynamicProgramming::rhs_ [protected] |
int* CbcFathomDynamicProgramming::coefficients_ [protected] |
int CbcFathomDynamicProgramming::target_ [protected] |
Target pattern.
Definition at line 144 of file CbcFathomDynamicProgramming.hpp.
Referenced by setTarget(), and target().
int CbcFathomDynamicProgramming::numberNonOne_ [protected] |
int CbcFathomDynamicProgramming::bitPattern_ [protected] |
int CbcFathomDynamicProgramming::algorithm_ [protected] |
Current algorithm.
Definition at line 150 of file CbcFathomDynamicProgramming.hpp.
Referenced by setAlgorithm().