|
CoinUtils 2.11.12
|
Declarations for CoinPresolveMatrix and CoinPostsolveMatrix and their common base class CoinPrePostsolveMatrix. More...
#include "CoinPragma.hpp"#include "CoinPackedMatrix.hpp"#include "CoinMessage.hpp"#include "CoinTime.hpp"#include <cmath>#include <cassert>#include <cfloat>#include <cstdlib>Go to the source code of this file.
Classes | |
| class | CoinPresolveAction |
| Abstract base class of all presolve routines. More... | |
| class | presolvehlink |
| Links to aid in packed matrix modification. More... | |
| class | CoinPresolveMatrix |
| Augments CoinPrePostsolveMatrix with information about the problem that is only needed during presolve. More... | |
| class | CoinPostsolveMatrix |
| Augments CoinPrePostsolveMatrix with information about the problem that is only needed during postsolve. More... | |
Macros | |
| #define | deleteAction(array, type) |
| #define | PRESOLVEASSERT(x) |
| #define | PRESOLVE_STMT(s) |
| #define | PRESOLVE_DETAIL_PRINT(s) |
| #define | PRESOLVE_INF COIN_DBL_MAX |
| The usual finite infinity. | |
| #define | PRESOLVE_SMALL_INF 1.0e20 |
| And a small infinity. | |
| #define | PRESOLVEFINITE(n) |
| Check for infinity using finite infinity. | |
Functions | |
| void | DIE (const char *) |
Functions to work with variable status | |
Functions to work with the CoinPrePostsolveMatrix::Status enum and related vectors.
| |
| void | setRowStatus (int sequence, Status status) |
| Set row status (i.e., status of artificial for this row). | |
| Status | getRowStatus (int sequence) const |
| Get row status. | |
| bool | rowIsBasic (int sequence) const |
| Check if artificial for this row is basic. | |
| void | setColumnStatus (int sequence, Status status) |
| Set column status (i.e., status of primal variable). | |
| Status | getColumnStatus (int sequence) const |
| Get column (structural variable) status. | |
| bool | columnIsBasic (int sequence) const |
| Check if column (structural variable) is basic. | |
| void | setRowStatusUsingValue (int iRow) |
| Set status of row (artificial variable) to the correct nonbasic status given bounds and current value. | |
| void | setColumnStatusUsingValue (int iColumn) |
| Set status of column (structural variable) to the correct nonbasic status given bounds and current value. | |
| void | setStructuralStatus (const char *strucStatus, int lenParam) |
| Set column (structural variable) status vector. | |
| void | setArtificialStatus (const char *artifStatus, int lenParam) |
| Set row (artificial variable) status vector. | |
| void | setStatus (const CoinWarmStartBasis *basis) |
| Set the status of all variables from a basis. | |
| CoinWarmStartBasis * | getStatus () |
| Get status in the form of a CoinWarmStartBasis. | |
| const char * | columnStatusString (int j) const |
| Return a print string for status of a column (structural variable). | |
| const char * | rowStatusString (int i) const |
| Return a print string for status of a row (artificial variable). | |
Functions to load problem and solution information | |
These functions can be used to load portions of the problem definition and solution. See also the CoinPresolveMatrix and CoinPostsolveMatrix classes. | |
| void | setObjOffset (double offset) |
| Set the objective function offset for the original system. | |
| void | setObjSense (double objSense) |
| Set the objective sense (max/min). | |
| void | setPrimalTolerance (double primTol) |
| Set the primal feasibility tolerance. | |
| void | setDualTolerance (double dualTol) |
| Set the dual feasibility tolerance. | |
| void | setColLower (const double *colLower, int lenParam) |
| Set column lower bounds. | |
| void | setColUpper (const double *colUpper, int lenParam) |
| Set column upper bounds. | |
| void | setColSolution (const double *colSol, int lenParam) |
| Set column solution. | |
| void | setCost (const double *cost, int lenParam) |
| Set objective coefficients. | |
| void | setReducedCost (const double *redCost, int lenParam) |
| Set reduced costs. | |
| void | setRowLower (const double *rowLower, int lenParam) |
| Set row lower bounds. | |
| void | setRowUpper (const double *rowUpper, int lenParam) |
| Set row upper bounds. | |
| void | setRowPrice (const double *rowSol, int lenParam) |
| Set row solution. | |
| void | setRowActivity (const double *rowAct, int lenParam) |
| Set row activity. | |
Functions to retrieve problem and solution information | |
| int | getNumCols () const |
| Get current number of columns. | |
| int | getNumRows () const |
| Get current number of rows. | |
| CoinBigIndex | getNumElems () const |
| Get current number of non-zero coefficients. | |
| const CoinBigIndex * | getColStarts () const |
| Get column start vector for column-major packed matrix. | |
| const int * | getColLengths () const |
| Get column length vector for column-major packed matrix. | |
| const int * | getRowIndicesByCol () const |
| Get vector of row indices for column-major packed matrix. | |
| const double * | getElementsByCol () const |
| Get vector of elements for column-major packed matrix. | |
| const double * | getColLower () const |
| Get column lower bounds. | |
| const double * | getColUpper () const |
| Get column upper bounds. | |
| const double * | getCost () const |
| Get objective coefficients. | |
| const double * | getRowLower () const |
| Get row lower bounds. | |
| const double * | getRowUpper () const |
| Get row upper bounds. | |
| const double * | getColSolution () const |
| Get column solution (primal variable values). | |
| const double * | getRowActivity () const |
| Get row activity (constraint lhs values). | |
| const double * | getRowPrice () const |
| Get row solution (dual variables). | |
| const double * | getReducedCost () const |
| Get reduced costs. | |
| int | countEmptyCols () |
| Count empty columns. | |
Variables | |
| const double | ZTOLDP = 1e-12 |
| Zero tolerance. | |
| const double | ZTOLDP2 = 1e-10 |
| Alternate zero tolerance. | |
Current and Allocated Size | |
During pre- and postsolve, the matrix will change in size. During presolve it will shrink; during postsolve it will grow. Hence there are two sets of size variables, one for the current size and one for the allocated size. (See the general comments for the CoinPrePostsolveMatrix class for more information.) | |
| int | ncols_ |
| current number of columns | |
| int | nrows_ |
| current number of rows | |
| CoinBigIndex | nelems_ |
| current number of coefficients | |
| int | ncols0_ |
| Allocated number of columns. | |
| int | nrows0_ |
| Allocated number of rows. | |
| CoinBigIndex | nelems0_ |
| Allocated number of coefficients. | |
| CoinBigIndex | bulk0_ |
| Allocated size of bulk storage for row indices and coefficients. | |
| double | bulkRatio_ |
| Ratio of bulk0_ to nelems0_; default is 2. | |
Problem representation | |
The matrix is the common column-major format: A pair of vectors with positional correspondence to hold coefficients and row indices, and a second pair of vectors giving the starting position and length of each column in the first pair. | |
| CoinBigIndex * | mcstrt_ |
| Vector of column start positions in hrow_, colels_. | |
| int * | hincol_ |
| Vector of column lengths. | |
| int * | hrow_ |
| Row indices (positional correspondence with colels_). | |
| double * | colels_ |
| Coefficients (positional correspondence with hrow_). | |
| double * | cost_ |
| Objective coefficients. | |
| double | originalOffset_ |
| Original objective offset. | |
| double * | clo_ |
| Column (primal variable) lower bounds. | |
| double * | cup_ |
| Column (primal variable) upper bounds. | |
| double * | rlo_ |
| Row (constraint) lower bounds. | |
| double * | rup_ |
| Row (constraint) upper bounds. | |
| int * | originalColumn_ |
| Original column numbers. | |
| int * | originalRow_ |
| Original row numbers. | |
| double | ztolzb_ |
| Primal feasibility tolerance. | |
| double | ztoldj_ |
| Dual feasibility tolerance. | |
| double | maxmin_ |
| Maximization/minimization. | |
Problem solution information | |
The presolve phase will work without any solution information (appropriate for initial optimisation) or with solution information (appropriate for reoptimisation). When solution information is supplied, presolve will maintain it to the best of its ability. colstat_ is checked to determine the presence/absence of status information. sol_ is checked for primal solution information, and rowduals_ for dual solution information. The postsolve phase requires the complete solution information from the presolved problem (status, primal and dual solutions). It will be transformed into a correct solution for the original problem. | |
| double * | sol_ |
| Vector of primal variable values. | |
| double * | rowduals_ |
| Vector of dual variable values. | |
| double * | acts_ |
| Vector of constraint left-hand-side values (row activity). | |
| double * | rcosts_ |
| Vector of reduced costs. | |
| unsigned char * | colstat_ |
| Status of primal variables. | |
| unsigned char * | rowstat_ |
| Status of constraints. | |
Message handling | |
Uses the standard COIN approach: a default handler is installed, and the CoinPrePostsolveMatrix object takes responsibility for it. If the client replaces the handler with one of their own, it becomes their responsibility. | |
| #define | NO_LINK -66666666 |
| CoinMessageHandler * | handler_ |
| Message handler. | |
| bool | defaultHandler_ |
| Indicates if the current handler_ is default (true) or not (false). | |
| CoinMessage | messages_ |
| Standard COIN messages. | |
| CoinMessageHandler * | messageHandler () const |
| Return message handler. | |
| void | setMessageHandler (CoinMessageHandler *handler) |
| Set message handler. | |
| CoinMessages | messages () const |
| Return messages. | |
| double * | presolve_dupmajor (const double *elems, const int *indices, int length, CoinBigIndex offset, int tgt=-1) |
Duplicate a major-dimension vector; optionally omit the entry with minor index tgt. | |
| void | coin_init_random_vec (double *work, int n) |
| Initialize a vector with random numbers. | |
Constructors & Destructors | |
| enum | Status { isFree = 0x00 , basic = 0x01 , atUpperBound = 0x02 , atLowerBound = 0x03 , superBasic = 0x04 } |
| Enum for status of various sorts. More... | |
| CoinPrePostsolveMatrix (const OsiSolverInterface *si, int ncols_, int nrows_, CoinBigIndex nelems_) | |
| `Native' constructor | |
| CoinPrePostsolveMatrix (const ClpSimplex *si, int ncols_, int nrows_, CoinBigIndex nelems_, double bulkRatio) | |
| ClpOsi constructor. | |
| ~CoinPrePostsolveMatrix () | |
| Destructor. | |
Declarations for CoinPresolveMatrix and CoinPostsolveMatrix and their common base class CoinPrePostsolveMatrix.
Also declarations for CoinPresolveAction and a number of non-member utility functions.
Definition in file CoinPresolveMatrix.hpp.
| #define deleteAction | ( | array, | |
| type ) |
Definition at line 38 of file CoinPresolveMatrix.hpp.
| #define PRESOLVEASSERT | ( | x | ) |
Definition at line 72 of file CoinPresolveMatrix.hpp.
| #define PRESOLVE_STMT | ( | s | ) |
Definition at line 75 of file CoinPresolveMatrix.hpp.
| #define PRESOLVE_DETAIL_PRINT | ( | s | ) |
Definition at line 87 of file CoinPresolveMatrix.hpp.
| #define PRESOLVE_INF COIN_DBL_MAX |
The usual finite infinity.
Definition at line 106 of file CoinPresolveMatrix.hpp.
| #define PRESOLVE_SMALL_INF 1.0e20 |
And a small infinity.
Definition at line 108 of file CoinPresolveMatrix.hpp.
| #define PRESOLVEFINITE | ( | n | ) |
Check for infinity using finite infinity.
Definition at line 110 of file CoinPresolveMatrix.hpp.
| #define NO_LINK -66666666 |
Definition at line 814 of file CoinPresolveMatrix.hpp.
| enum Status |
Enum for status of various sorts.
Matches CoinWarmStartBasis::Status and adds superBasic. Most code that converts between CoinPrePostsolveMatrix::Status and CoinWarmStartBasis::Status will break if this correspondence is broken.
superBasic is an unresolved problem: there's no analogue in CoinWarmStartBasis::Status.
| Enumerator | |
|---|---|
| isFree | |
| basic | |
| atUpperBound | |
| atLowerBound | |
| superBasic | |
Definition at line 325 of file CoinPresolveMatrix.hpp.
|
inline |
Definition at line 79 of file CoinPresolveMatrix.hpp.
| CoinPrePostsolveMatrix | ( | const OsiSolverInterface * | si, |
| int | ncols_, | ||
| int | nrows_, | ||
| CoinBigIndex | nelems_ ) |
`Native' constructor
This constructor creates an empty object which must then be loaded. On the other hand, it doesn't assume that the client is an OsiSolverInterface. */ CoinPrePostsolveMatrix(int ncols_alloc, int nrows_alloc, CoinBigIndex nelems_alloc);
/*! Generic OSI constructor
See OSI code for the definition.
| CoinPrePostsolveMatrix | ( | const ClpSimplex * | si, |
| int | ncols_, | ||
| int | nrows_, | ||
| CoinBigIndex | nelems_, | ||
| double | bulkRatio ) |
ClpOsi constructor.
See Clp code for the definition.
Destructor.
|
inline |
Set row status (i.e., status of artificial for this row).
Definition at line 347 of file CoinPresolveMatrix.hpp.
|
inline |
Get row status.
Definition at line 354 of file CoinPresolveMatrix.hpp.
|
inline |
Check if artificial for this row is basic.
Definition at line 359 of file CoinPresolveMatrix.hpp.
|
inline |
Set column status (i.e., status of primal variable).
Definition at line 364 of file CoinPresolveMatrix.hpp.
|
inline |
Get column (structural variable) status.
Definition at line 415 of file CoinPresolveMatrix.hpp.
|
inline |
Check if column (structural variable) is basic.
Definition at line 420 of file CoinPresolveMatrix.hpp.
| void setRowStatusUsingValue | ( | int | iRow | ) |
Set status of row (artificial variable) to the correct nonbasic status given bounds and current value.
| void setColumnStatusUsingValue | ( | int | iColumn | ) |
Set status of column (structural variable) to the correct nonbasic status given bounds and current value.
| void setStructuralStatus | ( | const char * | strucStatus, |
| int | lenParam ) |
Set column (structural variable) status vector.
| void setArtificialStatus | ( | const char * | artifStatus, |
| int | lenParam ) |
Set row (artificial variable) status vector.
| void setStatus | ( | const CoinWarmStartBasis * | basis | ) |
Set the status of all variables from a basis.
| CoinWarmStartBasis * getStatus | ( | ) |
Get status in the form of a CoinWarmStartBasis.
| const char * columnStatusString | ( | int | j | ) | const |
Return a print string for status of a column (structural variable).
| const char * rowStatusString | ( | int | i | ) | const |
Return a print string for status of a row (artificial variable).
| void setObjOffset | ( | double | offset | ) |
Set the objective function offset for the original system.
| void setObjSense | ( | double | objSense | ) |
Set the objective sense (max/min).
Coded as 1.0 for min, -1.0 for max. Yes, there's a method, and a matching attribute. No, you really don't want to set this to maximise.
| void setPrimalTolerance | ( | double | primTol | ) |
Set the primal feasibility tolerance.
| void setDualTolerance | ( | double | dualTol | ) |
Set the dual feasibility tolerance.
| void setColLower | ( | const double * | colLower, |
| int | lenParam ) |
Set column lower bounds.
| void setColUpper | ( | const double * | colUpper, |
| int | lenParam ) |
Set column upper bounds.
| void setColSolution | ( | const double * | colSol, |
| int | lenParam ) |
Set column solution.
| void setCost | ( | const double * | cost, |
| int | lenParam ) |
Set objective coefficients.
| void setReducedCost | ( | const double * | redCost, |
| int | lenParam ) |
Set reduced costs.
| void setRowLower | ( | const double * | rowLower, |
| int | lenParam ) |
Set row lower bounds.
| void setRowUpper | ( | const double * | rowUpper, |
| int | lenParam ) |
Set row upper bounds.
| void setRowPrice | ( | const double * | rowSol, |
| int | lenParam ) |
Set row solution.
| void setRowActivity | ( | const double * | rowAct, |
| int | lenParam ) |
Set row activity.
|
inline |
Get current number of columns.
Definition at line 493 of file CoinPresolveMatrix.hpp.
|
inline |
Get current number of rows.
Definition at line 498 of file CoinPresolveMatrix.hpp.
|
inline |
Get current number of non-zero coefficients.
Definition at line 503 of file CoinPresolveMatrix.hpp.
|
inline |
Get column start vector for column-major packed matrix.
Definition at line 508 of file CoinPresolveMatrix.hpp.
|
inline |
Get column length vector for column-major packed matrix.
Definition at line 513 of file CoinPresolveMatrix.hpp.
|
inline |
Get vector of row indices for column-major packed matrix.
Definition at line 518 of file CoinPresolveMatrix.hpp.
|
inline |
Get vector of elements for column-major packed matrix.
Definition at line 523 of file CoinPresolveMatrix.hpp.
|
inline |
Get column lower bounds.
Definition at line 528 of file CoinPresolveMatrix.hpp.
|
inline |
Get column upper bounds.
Definition at line 533 of file CoinPresolveMatrix.hpp.
|
inline |
Get objective coefficients.
Definition at line 538 of file CoinPresolveMatrix.hpp.
|
inline |
Get row lower bounds.
Definition at line 543 of file CoinPresolveMatrix.hpp.
|
inline |
Get row upper bounds.
Definition at line 548 of file CoinPresolveMatrix.hpp.
|
inline |
Get column solution (primal variable values).
Definition at line 553 of file CoinPresolveMatrix.hpp.
|
inline |
Get row activity (constraint lhs values).
Definition at line 558 of file CoinPresolveMatrix.hpp.
|
inline |
Get row solution (dual variables).
Definition at line 563 of file CoinPresolveMatrix.hpp.
|
inline |
Get reduced costs.
Definition at line 568 of file CoinPresolveMatrix.hpp.
|
inline |
Count empty columns.
Definition at line 573 of file CoinPresolveMatrix.hpp.
|
inline |
Return message handler.
Definition at line 586 of file CoinPresolveMatrix.hpp.
|
inline |
Set message handler.
The client retains responsibility for the handler — it will not be destroyed with the CoinPrePostsolveMatrix object.
Definition at line 595 of file CoinPresolveMatrix.hpp.
|
inline |
Return messages.
Definition at line 604 of file CoinPresolveMatrix.hpp.
| double * presolve_dupmajor | ( | const double * | elems, |
| const int * | indices, | ||
| int | length, | ||
| CoinBigIndex | offset, | ||
| int | tgt = -1 ) |
Duplicate a major-dimension vector; optionally omit the entry with minor index tgt.
Designed to copy a major-dimension vector from the paired coefficient (elems) and minor index (indices) arrays used in the standard packed matrix representation. Copies length entries starting at offset.
If tgt is specified, the entry with minor index == tgt is omitted from the copy.
| void coin_init_random_vec | ( | double * | work, |
| int | n ) |
Initialize a vector with random numbers.
| const double ZTOLDP = 1e-12 |
Zero tolerance.
OSL had a fixed zero tolerance; we still use that here.
Definition at line 98 of file CoinPresolveMatrix.hpp.
| const double ZTOLDP2 = 1e-10 |
Alternate zero tolerance.
Use a different one if we are doing doubletons, etc.
Definition at line 103 of file CoinPresolveMatrix.hpp.
| int ncols_ |
current number of columns
Definition at line 621 of file CoinPresolveMatrix.hpp.
| int nrows_ |
current number of rows
Definition at line 623 of file CoinPresolveMatrix.hpp.
| CoinBigIndex nelems_ |
current number of coefficients
Definition at line 625 of file CoinPresolveMatrix.hpp.
| int ncols0_ |
Allocated number of columns.
Definition at line 628 of file CoinPresolveMatrix.hpp.
| int nrows0_ |
Allocated number of rows.
Definition at line 630 of file CoinPresolveMatrix.hpp.
| CoinBigIndex nelems0_ |
Allocated number of coefficients.
Definition at line 632 of file CoinPresolveMatrix.hpp.
| CoinBigIndex bulk0_ |
Allocated size of bulk storage for row indices and coefficients.
This is the space allocated for hrow_ and colels_. This must be large enough to allow columns to be copied into empty space when they need to be expanded. For efficiency (to minimize the number of times the representation must be compressed) it's recommended that this be at least 2*nelems0_.
Definition at line 641 of file CoinPresolveMatrix.hpp.
| double bulkRatio_ |
Ratio of bulk0_ to nelems0_; default is 2.
Definition at line 643 of file CoinPresolveMatrix.hpp.
| CoinBigIndex* mcstrt_ |
Vector of column start positions in hrow_, colels_.
Definition at line 655 of file CoinPresolveMatrix.hpp.
| int* hincol_ |
Vector of column lengths.
Definition at line 657 of file CoinPresolveMatrix.hpp.
| int* hrow_ |
Row indices (positional correspondence with colels_).
Definition at line 659 of file CoinPresolveMatrix.hpp.
| double* colels_ |
Coefficients (positional correspondence with hrow_).
Definition at line 661 of file CoinPresolveMatrix.hpp.
| double* cost_ |
Objective coefficients.
Definition at line 664 of file CoinPresolveMatrix.hpp.
| double originalOffset_ |
Original objective offset.
Definition at line 666 of file CoinPresolveMatrix.hpp.
| double* clo_ |
Column (primal variable) lower bounds.
Definition at line 669 of file CoinPresolveMatrix.hpp.
| double* cup_ |
Column (primal variable) upper bounds.
Definition at line 671 of file CoinPresolveMatrix.hpp.
| double* rlo_ |
Row (constraint) lower bounds.
Definition at line 674 of file CoinPresolveMatrix.hpp.
| double* rup_ |
Row (constraint) upper bounds.
Definition at line 676 of file CoinPresolveMatrix.hpp.
| int* originalColumn_ |
Original column numbers.
Over the current range of column numbers in the presolved problem, the entry for column j will contain the index of the corresponding column in the original problem.
Definition at line 684 of file CoinPresolveMatrix.hpp.
| int* originalRow_ |
Original row numbers.
Over the current range of row numbers in the presolved problem, the entry for row i will contain the index of the corresponding row in the original problem.
Definition at line 691 of file CoinPresolveMatrix.hpp.
| double ztolzb_ |
Primal feasibility tolerance.
Definition at line 694 of file CoinPresolveMatrix.hpp.
| double ztoldj_ |
Dual feasibility tolerance.
Definition at line 696 of file CoinPresolveMatrix.hpp.
| double maxmin_ |
Maximization/minimization.
Yes, there's a variable here. No, you really don't want to set this to maximise. See the main notes for CoinPresolveMatrix.
Definition at line 703 of file CoinPresolveMatrix.hpp.
| double* sol_ |
Vector of primal variable values.
If sol_ exists, it is assumed that primal solution information should be updated and that acts_ also exists.
Definition at line 726 of file CoinPresolveMatrix.hpp.
| double* rowduals_ |
Vector of dual variable values.
If rowduals_ exists, it is assumed that dual solution information should be updated and that rcosts_ also exists.
Definition at line 732 of file CoinPresolveMatrix.hpp.
| double* acts_ |
Vector of constraint left-hand-side values (row activity).
Produced by evaluating constraints according to sol_. Updated iff sol_ exists.
Definition at line 738 of file CoinPresolveMatrix.hpp.
| double* rcosts_ |
Vector of reduced costs.
Produced by evaluating dual constraints according to rowduals_. Updated iff rowduals_ exists.
Definition at line 744 of file CoinPresolveMatrix.hpp.
| unsigned char* colstat_ |
Status of primal variables.
Coded with CoinPrePostSolveMatrix::Status, one code per char. colstat_ and rowstat_ MUST be allocated as a single vector. This is to maintain compatibility with ClpPresolve and OsiPresolve, which do it this way.
Definition at line 752 of file CoinPresolveMatrix.hpp.
| unsigned char* rowstat_ |
Status of constraints.
More accurately, the status of the logical variable associated with the constraint. Coded with CoinPrePostSolveMatrix::Status, one code per char. Note that this must be allocated as a single vector with colstat_.
Definition at line 760 of file CoinPresolveMatrix.hpp.
| CoinMessageHandler* handler_ |
Message handler.
Definition at line 772 of file CoinPresolveMatrix.hpp.
| bool defaultHandler_ |
Indicates if the current handler_ is default (true) or not (false).
Definition at line 774 of file CoinPresolveMatrix.hpp.
| CoinMessage messages_ |
Standard COIN messages.
Definition at line 776 of file CoinPresolveMatrix.hpp.