6#ifndef CoinPresolveMatrix_H
7#define CoinPresolveMatrix_H
36#define deleteAction(array, type) delete[]((type)array)
38#define deleteAction(array, type) delete[] array
45#if PRESOLVE_DEBUG > 0 || PRESOLVE_CONSISTENCY > 0
47#define PRESOLVE_STMT(s) s
49#define PRESOLVEASSERT(x) \
50 ((x) ? 1 : ((std::cerr << "FAILED ASSERTION at line " << __LINE__ << ": " #x "\n"), abort(), 0))
52inline void DIE(
const char *s)
68#define PRESENT_IN_REDUCED '\377'
72#define PRESOLVEASSERT(x) \
75#define PRESOLVE_STMT(s) \
79inline void DIE(
const char *) {}
86#ifndef PRESOLVE_DETAIL
87#define PRESOLVE_DETAIL_PRINT(s) \
91#define PRESOLVE_DETAIL_PRINT(s) s
106#define PRESOLVE_INF COIN_DBL_MAX
108#define PRESOLVE_SMALL_INF 1.0e20
110#define PRESOLVEFINITE(n) (-PRESOLVE_INF < (n) && (n) < PRESOLVE_INF)
173 throw CoinError(error, ps_routine,
"CoinPresolve");
201 virtual const char *
name()
const = 0;
217class OsiSolverInterface;
349 unsigned char &st_byte =
rowstat_[sequence];
350 st_byte =
static_cast< unsigned char >(st_byte & (~7));
351 st_byte =
static_cast< unsigned char >(st_byte | status);
366 unsigned char &st_byte =
colstat_[sequence];
367 st_byte =
static_cast< unsigned char >(st_byte & (~7));
368 st_byte =
static_cast< unsigned char >(st_byte | status);
374 std::cout <<
"Bad status: Var " << sequence
375 <<
" isFree, lb = " <<
clo_[sequence]
376 <<
", ub = " <<
cup_[sequence] << std::endl;
385 std::cout <<
"Bad status: Var " << sequence
386 <<
" atUpperBound, lb = " <<
clo_[sequence]
387 <<
", ub = " <<
cup_[sequence] << std::endl;
393 std::cout <<
"Bad status: Var " << sequence
394 <<
" atLowerBound, lb = " <<
clo_[sequence]
395 <<
", ub = " <<
cup_[sequence] << std::endl;
401 std::cout <<
"Bad status: Var " << sequence
402 <<
" superBasic, lb = " <<
clo_[sequence]
403 <<
", ub = " <<
cup_[sequence] << std::endl;
477 void setCost(
const double *cost,
int lenParam);
576 for (
int i = 0; i <
ncols_; i++)
783const char *
statusName(CoinPrePostsolveMatrix::Status status);
814#define NO_LINK -66666666
823 int ipre = link[i].
pre;
824 int isuc = link[i].
suc;
826 link[ipre].
suc = isuc;
829 link[isuc].
pre = ipre;
841 int isuc = link[j].
suc;
863 int ipre = link[i].
pre;
864 int isuc = link[i].
suc;
930 double nonLinearVariable,
945 OsiSolverInterface *si,
950 double nonLinearVariable,
951 const char *prohibited,
984 for (
int i = 0; i <
nrows_; i++)
999 integerType_[i] =
static_cast< unsigned char >(variableType);
1070 return presolveOptions_;
1075 presolveOptions_ = value;
1099#if PRESOLVE_DEBUG > 2
1100 assert(fabs(change_amount) < 1.0e50);
1263 int presolveOptions_;
1291 double *randomNumber_;
1410 inline bool colInfinite(
int i)
const
1415 inline void unsetColInfinite(
int i)
1420 inline void setColInfinite(
int i)
1579 unsigned char *colstat,
1580 unsigned char *rowstat);
1598 unsigned char *colstat,
1599 unsigned char *rowstat);
1677 int *minndxs,
int *majlens,
1686 int *hrow,
int *hincol,
1690 hrow, hincol, clink, ncols, colx);
1699 int *hcol,
int *hinrow,
1703 hcol, hinrow, rlink, nrows, rowx);
1719 for (k = ks; k < ke; k++)
1722 if (minndxs[k] == tgt)
1731 if (minndxs[k] == tgt)
1771 const int *minndxs);
1860 int *majlens,
int *minndxs,
double *els)
1867 minndxs[kmi] = minndxs[ke - 1];
1868 els[kmi] = els[ke - 1];
1882 int *majlens,
int *minndxs,
double *els)
1888 int iMinor = minndxs[k];
1889 if (!marked[iMinor]) {
1890 minndxs[put] = iMinor;
1891 els[put++] = els[k];
1896 majlens[majndx] =
static_cast< int >(put - ks);
1912 int *hincol,
int *hrow,
double *colels)
1929 int *hinrow,
int *hcol,
double *rowels)
1960 int *hincol,
int *hrow,
This file contains the enum for the standard set of Coin messages and a class definition whose sole p...
const double ZTOLDP2
Alternate zero tolerance.
Status getColumnStatus(int sequence) const
Get column (structural variable) status.
const double * getRowPrice() const
Get row solution (dual variables).
bool defaultHandler_
Indicates if the current handler_ is default (true) or not (false).
~CoinPrePostsolveMatrix()
Destructor.
CoinBigIndex nelems_
current number of coefficients
double maxmin_
Maximization/minimization.
double * cost_
Objective coefficients.
CoinWarmStartBasis * getStatus()
Get status in the form of a CoinWarmStartBasis.
void setColSolution(const double *colSol, int lenParam)
Set column solution.
void setCost(const double *cost, int lenParam)
Set objective coefficients.
const int * getColLengths() const
Get column length vector for column-major packed matrix.
double * sol_
Vector of primal variable values.
double bulkRatio_
Ratio of bulk0_ to nelems0_; default is 2.
void setRowActivity(const double *rowAct, int lenParam)
Set row activity.
int nrows_
current number of rows
const int * getRowIndicesByCol() const
Get vector of row indices for column-major packed matrix.
const CoinBigIndex * getColStarts() const
Get column start vector for column-major packed matrix.
Status getRowStatus(int sequence) const
Get row status.
bool rowIsBasic(int sequence) const
Check if artificial for this row is basic.
CoinMessage messages_
Standard COIN messages.
void setRowStatus(int sequence, Status status)
Set row status (i.e., status of artificial for this row).
double * rowduals_
Vector of dual variable values.
int getNumCols() const
Get current number of columns.
const double ZTOLDP
Zero tolerance.
void setStatus(const CoinWarmStartBasis *basis)
Set the status of all variables from a basis.
const char * columnStatusString(int j) const
Return a print string for status of a column (structural variable).
int nrows0_
Allocated number of rows.
const double * getCost() const
Get objective coefficients.
double * clo_
Column (primal variable) lower bounds.
void setColumnStatus(int sequence, Status status)
Set column status (i.e., status of primal variable).
void setColumnStatusUsingValue(int iColumn)
Set status of column (structural variable) to the correct nonbasic status given bounds and current va...
const double * getColUpper() const
Get column upper bounds.
void setDualTolerance(double dualTol)
Set the dual feasibility tolerance.
CoinPrePostsolveMatrix(const OsiSolverInterface *si, int ncols_, int nrows_, CoinBigIndex nelems_)
`Native' constructor
void setPrimalTolerance(double primTol)
Set the primal feasibility tolerance.
void setReducedCost(const double *redCost, int lenParam)
Set reduced costs.
int ncols0_
Allocated number of columns.
int countEmptyCols()
Count empty columns.
Status
Enum for status of various sorts.
void setRowStatusUsingValue(int iRow)
Set status of row (artificial variable) to the correct nonbasic status given bounds and current value...
const double * getRowLower() const
Get row lower bounds.
void setColUpper(const double *colUpper, int lenParam)
Set column upper bounds.
CoinMessageHandler * handler_
Message handler.
int ncols_
current number of columns
CoinMessages messages() const
Return messages.
const char * rowStatusString(int i) const
Return a print string for status of a row (artificial variable).
void setRowUpper(const double *rowUpper, int lenParam)
Set row upper bounds.
double * colels_
Coefficients (positional correspondence with hrow_).
#define PRESOLVE_INF
The usual finite infinity.
double * rcosts_
Vector of reduced costs.
double * rup_
Row (constraint) upper bounds.
const double * getColSolution() const
Get column solution (primal variable values).
void setMessageHandler(CoinMessageHandler *handler)
Set message handler.
double ztoldj_
Dual feasibility tolerance.
CoinBigIndex getNumElems() const
Get current number of non-zero coefficients.
int * originalColumn_
Original column numbers.
double * acts_
Vector of constraint left-hand-side values (row activity).
void setRowLower(const double *rowLower, int lenParam)
Set row lower bounds.
const double * getElementsByCol() const
Get vector of elements for column-major packed matrix.
void setObjSense(double objSense)
Set the objective sense (max/min).
unsigned char * rowstat_
Status of constraints.
int * hincol_
Vector of column lengths.
int * hrow_
Row indices (positional correspondence with colels_).
int * originalRow_
Original row numbers.
double * rlo_
Row (constraint) lower bounds.
void setArtificialStatus(const char *artifStatus, int lenParam)
Set row (artificial variable) status vector.
void setObjOffset(double offset)
Set the objective function offset for the original system.
void coin_init_random_vec(double *work, int n)
Initialize a vector with random numbers.
double originalOffset_
Original objective offset.
const double * getRowActivity() const
Get row activity (constraint lhs values).
const double * getRowUpper() const
Get row upper bounds.
CoinBigIndex bulk0_
Allocated size of bulk storage for row indices and coefficients.
double ztolzb_
Primal feasibility tolerance.
void setRowPrice(const double *rowSol, int lenParam)
Set row solution.
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.
CoinBigIndex nelems0_
Allocated number of coefficients.
CoinMessageHandler * messageHandler() const
Return message handler.
const double * getReducedCost() const
Get reduced costs.
void setStructuralStatus(const char *strucStatus, int lenParam)
Set column (structural variable) status vector.
unsigned char * colstat_
Status of primal variables.
const double * getColLower() const
Get column lower bounds.
double * cup_
Column (primal variable) upper bounds.
int getNumRows() const
Get current number of rows.
CoinBigIndex * mcstrt_
Vector of column start positions in hrow_, colels_.
bool columnIsBasic(int sequence) const
Check if column (structural variable) is basic.
void setColLower(const double *colLower, int lenParam)
Set column lower bounds.
Error Class thrown by an exception.
Base class for message handling.
The standard set of Coin messages.
Class to hold and manipulate an array of massaged messages.
Sparse Matrix Base Class.
Augments CoinPrePostsolveMatrix with information about the problem that is only needed during postsol...
CoinBigIndex presolve_find_col(int col, CoinBigIndex krs, CoinBigIndex kre, const int *hcol)
Find position of a column in a row in a row-major matrix.
CoinPostsolveMatrix(ClpSimplex *si, int ncols0, int nrows0, CoinBigIndex nelems0, double maxmin_, double *sol, double *acts, unsigned char *colstat, unsigned char *rowstat)
`Native' constructor
~CoinPostsolveMatrix()
Destructor.
CoinBigIndex presolve_find_minor2(int tgt, CoinBigIndex ks, int majlen, const int *minndxs, const CoinBigIndex *majlinks)
Find position of a minor index in a major vector in a threaded matrix.
CoinBigIndex * link_
Thread array.
CoinBigIndex presolve_find_row2(int row, CoinBigIndex kcs, int collen, const int *hrow, const CoinBigIndex *clinks)
Find position of a row in a column in a column-major threaded matrix.
CoinBigIndex free_list_
First entry in free entries thread.
void presolve_delete_from_major2(int majndx, int minndx, CoinBigIndex *majstrts, int *majlens, int *minndxs, CoinBigIndex *majlinks, CoinBigIndex *free_listp)
Delete the entry for a minor index from a major vector in a threaded matrix.
CoinBigIndex maxlink_
Allocated size of link_.
void presolve_delete_from_col2(int row, int col, CoinBigIndex *mcstrt, int *hincol, int *hrow, CoinBigIndex *clinks, CoinBigIndex *free_listp)
Delete the entry for row row from column col in a column-major threaded matrix.
void assignPresolveToPostsolve(CoinPresolveMatrix *&preObj)
Load an empty CoinPostsolveMatrix from a CoinPresolveMatrix.
CoinPostsolveMatrix(OsiSolverInterface *si, int ncols0, int nrows0, CoinBigIndex nelems0, double maxmin_, double *sol, double *acts, unsigned char *colstat, unsigned char *rowstat)
Generic OSI constructor.
CoinBigIndex presolve_find_row3(int row, CoinBigIndex kcs, int collen, const int *hrow, const CoinBigIndex *clinks)
Find position of a row in a column in a column-major threaded matrix.
CoinBigIndex presolve_find_minor3(int tgt, CoinBigIndex ks, int majlen, const int *minndxs, const CoinBigIndex *majlinks)
Find position of a minor index in a major vector in a threaded matrix.
Collects all the information about the problem that is needed in both presolve and postsolve.
bool presolve_expand_col(CoinBigIndex *mcstrt, double *colels, int *hrow, int *hincol, presolvehlink *clink, int ncols, int colx)
Make sure a column (colx) in a column-major matrix has room for one more coefficient.
void presolve_make_memlists(int *lengths, presolvehlink *link, int n)
Initialise linked list for major vector order in bulk storage.
CoinBigIndex presolve_find_row1(int row, CoinBigIndex kcs, CoinBigIndex kce, const int *hrow)
Find position of a row in a column in a column-major matrix.
CoinBigIndex presolve_find_row(int row, CoinBigIndex kcs, CoinBigIndex kce, const int *hrow)
Find position of a row in a column in a column-major matrix.
void presolve_delete_from_row(int row, int col, const CoinBigIndex *mrstrt, int *hinrow, int *hcol, double *rowels)
Delete the entry for column col from row row in a row-major matrix.
CoinBigIndex presolve_find_col1(int col, CoinBigIndex krs, CoinBigIndex kre, const int *hcol)
Find position of a column in a row in a row-major matrix.
bool presolve_expand_major(CoinBigIndex *majstrts, double *majels, int *minndxs, int *majlens, presolvehlink *majlinks, int nmaj, int k)
Make sure a major-dimension vector k has room for one more coefficient.
void presolve_delete_from_col(int row, int col, const CoinBigIndex *mcstrt, int *hincol, int *hrow, double *colels)
Delete the entry for row row from column col in a column-major matrix.
CoinBigIndex presolve_find_minor(int tgt, CoinBigIndex ks, CoinBigIndex ke, const int *minndxs)
Find position of a minor index in a major vector.
const char * statusName(CoinPrePostsolveMatrix::Status status)
Generate a print string for a status code.
void presolve_delete_many_from_major(int majndx, char *marked, const CoinBigIndex *majstrts, int *majlens, int *minndxs, double *els)
Delete marked entries.
CoinBigIndex presolve_find_minor1(int tgt, CoinBigIndex ks, CoinBigIndex ke, const int *minndxs)
Find position of a minor index in a major vector.
bool presolve_expand_row(CoinBigIndex *mrstrt, double *rowels, int *hcol, int *hinrow, presolvehlink *rlink, int nrows, int rowx)
Make sure a row (rowx) in a row-major matrix has room for one more coefficient.
void presolve_delete_from_major(int majndx, int minndx, const CoinBigIndex *majstrts, int *majlens, int *minndxs, double *els)
Delete the entry for a minor index from a major vector.
Abstract base class of all presolve routines.
virtual ~CoinPresolveAction()
Virtual destructor.
virtual const char * name() const =0
Construct a postsolve object and add it to the transformation list.
virtual void postsolve(CoinPostsolveMatrix *prob) const =0
Apply the postsolve transformation for this particular presolve action.
static void throwCoinError(const char *error, const char *ps_routine)
Stub routine to throw exceptions.
const CoinPresolveAction * next
The next presolve transformation.
Augments CoinPrePostsolveMatrix with information about the problem that is only needed during presolv...
void update_model(ClpSimplex *si, int nrows0, int ncols0, CoinBigIndex nelems0)
Update the model held by a Clp OSI.
friend void assignPresolveToPostsolve(CoinPresolveMatrix *&preObj)
Initialize a CoinPostsolveMatrix object, destroying the CoinPresolveMatrix object.
void change_bias(double change_amount)
Adjust objective function constant offset.
double feasibilityTolerance_
Bounds can be moved by this to retain feasibility.
*Mark row as changed and add to list of rows to process next void addRow(int i)
int stepRowsToDo()
Step row ToDo lists.
const double * getElementsByRow() const
Get vector of elements for row-major packed matrix.
void setMaximumSubstitutionLevel(int level)
Set Maximum substitution level (normally 3).
*Mark column as not changed void unsetColChanged(int i)
int * hcol_
Column indices (positional correspondence with rowels_).
*Return the number of columns on the int numberColsToDo()
~CoinPresolveMatrix()
Destructor.
*Test if column is eligible for preprocessing bool colProhibited(int i) const
double dobias_
Objective function offset introduced during presolve.
int recomputeSums(int whichRow)
Recompute row lhs bounds.
*Mark row as ineligible for preprocessing void setRowProhibited(int i)
CoinPresolveMatrix(int ncols0, double maxmin, OsiSolverInterface *si, int nrows, CoinBigIndex nelems, bool doStatus, double nonLinearVariable, const char *prohibited, const char *rowProhibited=NULL)
Generic OSI constructor.
*Check if there are any prohibited rows or columns bool anyProhibited() const
bool anyInteger_
Flag to say if any variables are integer.
bool colProhibited2(int i) const
Test if column is eligible for preprocessing.
*Mark column as changed and add to list of columns to process next void addCol(int i)
int numberNextColsToDo_
Length of nextColsToDo_.
void statistics()
Say we want statistics - also set time.
*Mark row as used void setRowUsed(int i)
int * hinrow_
Vector of row lengths.
void setVariableType(int i, int variableType)
Set variable type information for a single variable.
double startTime_
Start time of presolve.
void setStatus(int status)
Set problem status.
void update_model(OsiSolverInterface *si, int nrows0, int ncols0, CoinBigIndex nelems0)
Update the model held by a generic OSI.
int numberRowsToDo_
Length of rowsToDo_.
*Mark row as unused void unsetRowUsed(int i)
int numberColsToDo_
Length of colsToDo_.
bool colUsed(int i) const
Test if column is marked as used.
double * rowels_
Coefficients (positional correspondence with hcol_).
unsigned char * integerType_
Tracks integrality of columns (1 for integer, 0 for continuous).
*Preallocated scratch work ncols_ double * usefulColumnDouble_
CoinBigIndex * mrstrt_
Vector of row start positions in hcol, rowels_.
presolvehlink * clink_
Linked list for the column-major representation.
*Has column been changed bool colChanged(int i) const
unsigned char * rowChanged_
Row change status information.
*Work array for count of infinite contributions to row lhs upper bound int * infiniteUp_
bool isInteger(int i) const
Check for integrality of the specified variable.
int stepColsToDo()
Step column ToDo lists.
void setMatrix(const CoinPackedMatrix *mtx)
Load the cofficient matrix.
*Work array for sum of finite contributions to row lhs upper bound double * sumUp_
bool rowUsed(int i) const
Test if row is marked as used.
*Mark column as unused void unsetColUsed(int i)
*Mark column as used void setColUsed(int i)
bool anyInteger() const
Check if there are any integer variables.
void setPass(int pass=0)
Set pass number.
*Return the number of rows on the int numberRowsToDo()
int status_
Output status: 0 = feasible, 1 = infeasible, 2 = unbounded.
void initRowsToDo()
Initialise the row ToDo lists.
int pass_
Presolve pass number.
void setVariableType(bool allIntegers, int lenParam)
Set the type of all variables.
int status()
Returns problem status (0 = feasible, 1 = infeasible, 2 = unbounded).
int numberNextRowsToDo_
Length of nextRowsToDo_.
void setFeasibilityTolerance(double val)
Set feasibility tolerance.
*Set a flag for presence of prohibited rows or columns void setAnyProhibited(bool val=true)
*Preallocated scratch work *nrows_ double * usefulRowDouble_
*Mark column as ineligible for preprocessing void setColProhibited(int i)
void setPresolveOptions(int value)
Sets any special options (see presolveOptions_).
CoinPresolveMatrix(int ncols0, double maxmin, ClpSimplex *si, int nrows, CoinBigIndex nelems, bool doStatus, double nonLinearVariable, double bulkRatio)
`Native' constructor
bool tuning_
Print statistics for tuning.
*Allocate scratch arrays void initializeStuff()
int * nextRowsToDo_
Output list of rows to process next.
int presolveOptions() const
Picks up any special options.
bool rowProhibited2(int i) const
Test if row is eligible for preprocessing.
*Preallocated scratch work *ncols_ int * usefulColumnInt_
void initColsToDo()
Initialise the column ToDo lists.
int * colsToDo_
Input list of columns to process.
*Mark column as changed void setColChanged(int i)
double feasibilityTolerance()
Return feasibility tolerance.
int maxSubstLevel_
Maximum substitution level.
*Work array for sum of finite contributions to row lhs lower bound double * sumDown_
*Mark row as changed void setRowChanged(int i)
*Preallocated scratch work *nrows_ int * usefulRowInt_
int * rowsToDo_
Input list of rows to process.
*Has row been changed bool rowChanged(int i) const
int * nextColsToDo_
Output list of columns to process next.
const int * getColIndicesByRow() const
Get vector of column indices for row-major packed matrix.
*Mark row as not changed void unsetRowChanged(int i)
*Work array for count of infinite contributions to row lhs lower bound int * infiniteDown_
presolvehlink * rlink_
Linked list for the row-major representation.
bool anyProhibited_
Fine control over presolve actions.
unsigned char * colChanged_
Column change status information.
void setVariableType(const unsigned char *variableType, int lenParam)
Set variable type information for all variables.
int countEmptyRows()
Count number of empty rows.
*Free scratch arrays void deleteStuff()
const CoinBigIndex * getRowStarts() const
Get row start vector for row-major packed matrix.
void setAnyInteger(bool anyInteger=true)
Set a flag for presence (true) or absence (false) of integer variables.
*Test if row is eligible for preprocessing bool rowProhibited(int i) const
The default COIN simplex (basis-oriented) warm start class.
Links to aid in packed matrix modification.
void PRESOLVE_MOVE_LINK(presolvehlink *link, int i, int j)
relink vector j in place of vector i
void PRESOLVE_INSERT_LINK(presolvehlink *link, int i, int j)
insert vector i after vector j
void PRESOLVE_REMOVE_LINK(presolvehlink *link, int i)
unlink vector i