70#include <ClpSimplex.hpp>
71#include <ClpPrimalColumnSteepest.hpp>
72#include <ClpDualRowSteepest.hpp>
73#include <CoinIndexedVector.hpp>
76#include <config_clp.h>
77#define CLP_VERSION VERSION
92#define snprintf _snprintf
96#ifdef LPI_CLP_DEBUG_WRITE_FILES
101#define SUMINFEASBOUND 1.0e-3
127#define COLS_PER_PACKET SCIP_DUALPACKETSIZE
129#define ROWS_PER_PACKET SCIP_DUALPACKETSIZE
164 assert(num <= lpi->cstatsize);
186 assert(num <= lpi->rstatsize);
315 lpi->
clp->defaultFactorizationFrequency();
339 lpi->
clp->setPerturbation(50);
408 lpi->
clp->setSpecialOptions(32|64|128|1024|32768|262144|2097152|0x2000000);
428 lpi->
clp->setPerturbation(100);
431 lpi->
clp->setSpecialOptions(32|64|128|1024|32768|262144|2097152|0x2000000);
434 lpi->
clp->setMoreSpecialOptions(8192);
437 lpi->
clp->setPersistenceFlag(0);
467 return "COIN-OR Linear Programming Solver developed by J. Forrest et.al. (projects.coin-or.org/Clp)";
476 return (
void*) lpi->
clp;
488 SCIPerrorMessage(
"SCIPlpiSetIntegralityInformation() has not been implemented yet.\n");
545 (*lpi)->clp =
new ClpSimplex();
548 (*lpi)->cstatsize = 0;
549 (*lpi)->rstatsize = 0;
550 (*lpi)->startscratch =
true;
552 (*lpi)->validFactorization =
false;
553 (*lpi)->setFactorizationFrequency =
false;
554 (*lpi)->fastmip =
FALSE;
555 (*lpi)->lastalgorithm = 0;
570 ClpPrimalColumnSteepest primalSteepest;
571 (*lpi)->clp->setPrimalColumnPivotAlgorithm(primalSteepest);
579 ClpDualRowSteepest dualSteepest;
580 (*lpi)->clp->setDualRowPivotAlgorithm(dualSteepest);
583 (*lpi)->clp->setStrParam(ClpProbName, std::string(name) );
586 (*lpi)->clp->setOptimizationDirection(objsen);
589 (*lpi)->clp->setLogLevel(0);
592 (*lpi)->clp->scaling(3);
603 (*lpi)->clp->setSpecialOptions(32|64|128|1024|32768|262144|2097152|0x2000000);
633 (*lpi)->clp->setMoreSpecialOptions(8192);
698 for( j = 0; j < nnonz; j++ )
716 assert( nnonz > beg[ncols-1] );
720 ClpSimplex* clp = lpi->
clp;
726 mybeg[ncols] = nnonz;
729 clp->loadProblem(ncols, nrows, mybeg, ind, val, lb, ub,
obj, lhs, rhs);
733 clp->setOptimizationDirection(objsen);
736 if ( colnames || rownames )
738 std::vector<std::string> columnNames(ncols);
739 std::vector<std::string> rowNames(nrows);
742 for (
int j = 0; j < ncols; ++j)
743 columnNames[j].assign(colnames[j]);
747 for (
int i = 0;
i < ncols; ++
i)
748 rowNames[
i].assign(rownames[
i]);
750 clp->copyNames(rowNames, columnNames);
787 int numCols = lpi->
clp->getNumCols();
799 for( j = 0; j < nnonz; j++ )
808 mybeg[ncols] = nnonz;
811 lpi->
clp->addColumns(ncols, lb, ub,
obj, mybeg, ind, val);
815 for (
int j = 0; j <= ncols; ++j)
819 lpi->
clp->addColumns(ncols, lb, ub,
obj, mybeg, 0, 0);
826 std::vector<std::string> columnNames(ncols);
827 for (
int j = 0; j < ncols; ++j)
828 columnNames[j].assign(colnames[j]);
829 lpi->
clp->copyColumnNames(columnNames, numCols, numCols + ncols);
846 assert(lastcol < lpi->clp->numberColumns());
847 assert(firstcol <= lastcol + 1);
852 if( firstcol > lastcol )
858 int num = lastcol-firstcol+1;
863 for (
int j = firstcol; j <= lastcol; ++j)
864 which[j - firstcol] = j;
866 lpi->
clp->deleteColumns(num, which);
890 int ncols = lpi->
clp->getNumCols();
894 for (
int j = 0; j < ncols; ++j)
899 lpi->
clp->deleteColumns(cnt, which);
904 for (
int j = 0; j < ncols; ++j)
945 int numRows = lpi->
clp->getNumRows();
954 int ncols = lpi->
clp->getNumCols();
955 for (
int j = 0; j < nnonz; ++j)
958 assert( 0 <= ind[j] && ind[j] < ncols );
964 mybeg[nrows] = nnonz;
967 lpi->
clp->addRows(nrows, lhs, rhs, mybeg, ind, val);
972 for (
int i = 0;
i <= nrows; ++
i)
974 lpi->
clp->addRows(nrows, lhs, rhs, mybeg, 0, 0);
981 std::vector<std::string> rowNames(nrows);
982 for (
int j = 0; j < nrows; ++j)
983 rowNames[j].assign(rownames[j]);
984 lpi->
clp->copyRowNames(rowNames, numRows, numRows + nrows);
1001 assert(lastrow < lpi->clp->numberRows());
1002 assert(firstrow <= lastrow + 1);
1004 SCIPdebugMessage(
"calling SCIPlpiDelRows() (number: %d)\n", lastrow-firstrow+1);
1007 if( firstrow > lastrow )
1013 int num = lastrow-firstrow+1;
1018 for (
int i = firstrow;
i <= lastrow; ++
i)
1019 which[
i - firstrow] =
i;
1021 lpi->
clp->deleteRows(num, which);
1046 int nrows = lpi->
clp->getNumRows();
1050 for (
int i = 0;
i < nrows; ++
i)
1052 if ( dstat[
i] == 1 )
1055 lpi->
clp->deleteRows(cnt, which);
1060 for (
int i = 0;
i < nrows; ++
i)
1062 if ( dstat[
i] == 1 )
1089 lpi->
clp->resize(0,0);
1114 ClpSimplex* clp = lpi->
clp;
1116#if SCIP_DISABLED_CODE
1119 double*
sol = lpi->
clp->primalColumnSolution();
1120 const double* colLower = lpi->
clp->getColLower();
1121 const double* colUpper = lpi->
clp->getColUpper();
1124 for (
int j = 0; j < ncols; ++j)
1128 SCIPerrorMessage(
"LP Error: fixing lower bound for variable %d to infinity.\n", ind[j]);
1133 SCIPerrorMessage(
"LP Error: fixing upper bound for variable %d to -infinity.\n", ind[j]);
1137 clp->setColumnBounds(ind[j], lb[j], ub[j]);
1139#if SCIP_DISABLED_CODE
1143 if( clp->statusExists() )
1148 switch ( clp->getColumnStatus(k) )
1150 case ClpSimplex::isFree:
1151 case ClpSimplex::superBasic:
1154 case ClpSimplex::atUpperBound:
1155 sol[k] = colUpper[k];
1156 assert( colUpper[k] == ub[j] );
1158 case ClpSimplex::isFixed:
1159 case ClpSimplex::atLowerBound:
1160 sol[k] = colLower[k];
1161 assert( colLower[k] == lb[j] );
1199 ClpSimplex* clp = lpi->
clp;
1201 for (
int i = 0;
i < nrows; ++
i)
1202 clp->setRowBounds(ind[
i], lhs[
i], rhs[
i]);
1220 assert(0 <= row && row < lpi->clp->numberRows());
1221 assert(0 <= col && col < lpi->clp->numberColumns());
1225 lpi->
clp->matrix()->modifyCoefficient(row, col, newval);
1245 lpi->
clp->setOptimizationDirection(objsen);
1268 ClpSimplex* clp = lpi->
clp;
1271 for(
int j = 0; j < ncols; ++j )
1272 clp->setObjCoeff(ind[j],
obj[j]);
1290 assert(0 <= row && row <= lpi->clp->numberRows() );
1298 ClpSimplex* clp = lpi->
clp;
1301 double* lhs = clp->rowLower();
1302 double* rhs = clp->rowUpper();
1304 double lhsval = lhs[row];
1305 if( lhsval > -COIN_DBL_MAX )
1307 else if( scaleval < 0.0 )
1308 lhsval = COIN_DBL_MAX;
1309 double rhsval = rhs[row];
1310 if( rhsval < COIN_DBL_MAX)
1312 else if( scaleval < 0.0 )
1313 rhsval = -COIN_DBL_MAX;
1314 if( scaleval < 0.0 )
1328 CoinPackedMatrix* M = clp->matrix();
1329 assert( M->getNumCols() == clp->numberColumns() );
1331 const CoinBigIndex* beg = M->getVectorStarts();
1332 const int* length = M->getVectorLengths();
1333 const int* ind = M->getIndices();
1334 double* val = M->getMutableElements();
1336 for (
int j = 0; j < M->getNumCols(); ++j)
1338 for (CoinBigIndex k = beg[j]; k < beg[j] + length[j]; ++k)
1363 assert(0 <= col && col <= lpi->clp->numberColumns() );
1371 ClpSimplex* clp = lpi->
clp;
1374 double* objvec = clp->objective();
1375 objvec[col] *= scaleval;
1378 double* lb = clp->columnLower();
1379 double* ub = clp->columnUpper();
1380 double lbval = lb[col];
1381 double ubval = ub[col];
1383 if( lbval > -COIN_DBL_MAX )
1385 else if( scaleval < 0.0 )
1386 lbval = COIN_DBL_MAX;
1387 if( ubval < COIN_DBL_MAX )
1389 else if( scaleval < 0.0 )
1390 ubval = -COIN_DBL_MAX;
1391 if( scaleval < 0.0 )
1402 CoinPackedMatrix* M = clp->matrix();
1403 assert( M->getNumCols() == clp->numberColumns() );
1405 const CoinBigIndex* beg = M->getVectorStarts();
1406 const int* length = M->getVectorLengths();
1407 double* val = M->getMutableElements();
1408 for (CoinBigIndex k = beg[col]; k < beg[col] + length[col]; ++k)
1440 *nrows = lpi->
clp->numberRows();
1458 *ncols = lpi->
clp->numberColumns();
1476 *nnonz = lpi->
clp->getNumElements();
1503 assert(lastcol < lpi->clp->numberColumns());
1504 assert(firstcol <= lastcol + 1);
1508 ClpSimplex* clp = lpi->
clp;
1513 const double* colLower = clp->getColLower();
1514 const double* colUpper = clp->getColUpper();
1520 if ( nnonz !=
NULL )
1522 CoinPackedMatrix* M = clp->matrix();
1524 assert( M->getNumCols() == clp->numberColumns() );
1526 const CoinBigIndex* Mbeg = M->getVectorStarts();
1527 const int* Mlength = M->getVectorLengths();
1528 const int* Mind = M->getIndices();
1529 const double* Mval = M->getElements();
1533 for (
int j = firstcol; j <= lastcol; ++j)
1535 beg[j-firstcol] = *nnonz;
1540 (*nnonz) += Mlength[j];
1569 assert(lastrow < lpi->clp->numberRows());
1570 assert(firstrow <= lastrow + 1);
1574 ClpSimplex* clp = lpi->
clp;
1577 const double* rowLower = clp->getRowLower();
1578 const double* rowUpper = clp->getRowUpper();
1584 if ( nnonz !=
NULL )
1586 ClpMatrixBase* M = clp->rowCopy();
1588 M = clp->clpMatrix()->reverseOrderedCopy();
1590 assert( M->getNumRows() == clp->numberRows() );
1592 const CoinBigIndex* Mbeg = M->getVectorStarts();
1593 const int* Mlength = M->getVectorLengths();
1594 const int* Mind = M->getIndices();
1595 const double* Mval = M->getElements();
1598 for(
int i = firstrow;
i <= lastrow; ++
i )
1600 beg[
i-firstrow] = *nnonz;
1601 for( CoinBigIndex k = Mbeg[
i]; k < Mbeg[
i] + Mlength[
i]; ++k )
1603 ind[*nnonz] = Mind[k];
1604 val[*nnonz] = Mval[k];
1621 int namestoragesize,
1627 assert(colnames !=
NULL || namestoragesize == 0);
1628 assert(namestorage !=
NULL || namestoragesize == 0);
1629 assert(namestoragesize >= 0);
1632 assert(lastcol < lpi->clp->numberColumns());
1633 assert(firstcol <= lastcol + 1);
1648 int namestoragesize,
1654 assert(rownames !=
NULL || namestoragesize == 0);
1655 assert(namestorage !=
NULL || namestoragesize == 0);
1656 assert(namestoragesize >= 0);
1659 assert(lastrow < lpi->clp->numberRows());
1660 assert(firstrow <= lastrow + 1);
1698 if ( lpi->
clp->getObjSense() < 0 )
1719 assert(lastcol < lpi->clp->numberColumns());
1720 assert(firstcol <= lastcol + 1);
1724 const double*
obj = lpi->
clp->getObjCoefficients();
1744 assert(lastcol < lpi->clp->numberColumns());
1745 assert(firstcol <= lastcol + 1);
1751 const double* colLower = lpi->
clp->getColLower();
1757 const double* colUpper = lpi->
clp->getColUpper();
1777 assert(lastrow < lpi->clp->numberRows());
1778 assert(firstrow <= lastrow + 1);
1784 const double* rowLower = lpi->
clp->getRowLower();
1790 const double* rowUpper = lpi->
clp->getRowUpper();
1810 assert(0 <= col && col < lpi->clp->numberColumns());
1811 assert(0 <= row && row < lpi->clp->numberRows());
1814 *val = lpi->
clp->matrix()->getCoefficient(row, col);
1840 SCIPdebugMessage(
"calling Clp primal(): %d cols, %d rows\n", lpi->
clp->numberColumns(), lpi->
clp->numberRows());
1842#ifdef LPI_CLP_DEBUG_WRITE_FILES
1844 snprintf(filename, 255,
"debug_p_%d.mps", fileNr);
1845 fileNr = fileNr % 2;
1858 lpi->
clp->allSlackBasis(
true);
1869 int startFinishOptions = 1;
1871 startFinishOptions = startFinishOptions | 2;
1874 int status = lpi->
clp->primal(0, startFinishOptions);
1876#ifdef LPI_CLP_DEBUG_WRITE_FILES
1877 char basisname[255];
1878 snprintf(basisname, 255,
"debug_p_%d.bas", fileNr);
1882 fileNr = fileNr % 2;
1900 if ( status == 4 || status == 5 || status == -1 )
1915 SCIPdebugMessage(
"calling Clp dual(): %d cols, %d rows\n", lpi->
clp->numberColumns(), lpi->
clp->numberRows());
1917#ifdef LPI_CLP_DEBUG_WRITE_FILES
1919 snprintf(filename, 255,
"debug_d_%d.mps", fileNr);
1922 snprintf(filename, 255,
"debug_d_%d.sav", fileNr);
1935 lpi->
clp->allSlackBasis(
true);
1946 int startFinishOptions = 1;
1948 startFinishOptions = startFinishOptions | 2;
1951 int status = lpi->
clp->dual(0, startFinishOptions);
1953#ifdef LPI_CLP_DEBUG_WRITE_FILES
1954 char basisname[255];
1955 snprintf(basisname, 255,
"debug_d_%d.bas", fileNr);
1959 fileNr = fileNr % 2;
1977 if ( status == 4 || status == 5 || status == -1 )
1993 SCIPdebugMessage(
"calling Clp barrier(): %d cols, %d rows; crossover: %u\n", lpi->
clp->numberColumns(), lpi->
clp->numberRows(), crossover);
2004#if (CLP_VERSION_MAJOR >= 1 && CLP_VERSION_MINOR > 17) || CLP_VERSION_MAJOR >= 2
2005 int startFinishOptions = 1;
2006 int status = lpi->
clp->barrier(crossover, startFinishOptions);
2008 int status = lpi->
clp->barrier(crossover);
2027 if ( status == 4 || status == 5 || status == -1 )
2073 SCIPdebugMessage(
"calling SCIPlpiStrongbranch() on variable %d (%d iterations)\n", col, itlim);
2082 ClpSimplex* clp = lpi->
clp;
2085 int ncols = clp->numberColumns();
2086 assert( 0 <= col && col < ncols );
2087 double** outputSolution =
NULL;
2092 int* outputStatus =
NULL;
2095 int* outputIterations =
NULL;
2099 int iterlimit = clp->maximumIterations();
2100 clp->setMaximumIterations(itlim);
2103 double objval = clp->objectiveValue();
2106 int specialoptions = clp->specialOptions();
2110 lpi->
clp->setSpecialOptions(32|64|128|512|1024|2048|4096|32768|262144|2097152|0x2000000);
2120 int startFinishOptions = 1;
2122 startFinishOptions = startFinishOptions | 2;
2125 *down =
EPSCEIL(psol - 1.0, 1e-06);
2143 int res = clp->strongBranching(1, &col, up, down, outputSolution, outputStatus, outputIterations,
false,
true, startFinishOptions);
2146 clp->setSpecialOptions(specialoptions);
2159 *iter = outputIterations[0] + outputIterations[1];
2162 clp->setMaximumIterations(iterlimit);
2194 SCIPdebugMessage(
"calling SCIPlpiStrongbranches() on %d variables (%d iterations)\n", ncols, itlim);
2205 ClpSimplex* clp = lpi->
clp;
2208 int n = clp->numberColumns();
2209 assert( 0 < ncols && ncols <= n );
2210 double** outputSolution =
NULL;
2212 for (
int j = 0; j < 2*ncols; ++j)
2217 int* outputStatus =
NULL;
2220 int* outputIterations =
NULL;
2224 int iterlimit = clp->maximumIterations();
2225 clp->setMaximumIterations(itlim);
2228 double objval = clp->objectiveValue();
2231 int specialoptions = clp->specialOptions();
2235 lpi->
clp->setSpecialOptions(32|64|128|512|1024|2048|4096|32768|262144|2097152|0x2000000);
2245 int startFinishOptions = 1;
2247 startFinishOptions = startFinishOptions | 2;
2250 for (
int j = 0; j < ncols; ++j)
2252 assert( 0 <= cols[j] && cols[j] < n );
2253 down[j] =
EPSCEIL(psols[j] - 1.0, 1e-06);
2254 up[j] =
EPSFLOOR(psols[j] + 1.0, 1e-06);
2257 downvalid[j] =
TRUE;
2276 int res = clp->strongBranching(ncols, cols, up, down, outputSolution, outputStatus, outputIterations,
false,
true, startFinishOptions);
2279 clp->setSpecialOptions(specialoptions);
2283 for (
int j = 0; j < ncols; ++j)
2290 *iter += outputIterations[2*j] + outputIterations[2*j+1];
2297 clp->setMaximumIterations(iterlimit);
2446 if ( lpi->
clp->primalFeasible() )
2447 *primalfeasible =
TRUE;
2449 *primalfeasible =
FALSE;
2451 if ( lpi->
clp->dualFeasible() )
2452 *dualfeasible =
TRUE;
2454 *dualfeasible =
FALSE;
2457 if (lpi->
clp->status()==0 && ( ! (*primalfeasible) || ! (*dualfeasible)) )
2459 if ( !(*primalfeasible) && lpi->
clp->sumPrimalInfeasibilities() <
SUMINFEASBOUND )
2461 lpi->
clp->setNumberPrimalInfeasibilities(0);
2462 *primalfeasible =
TRUE;
2466 lpi->
clp->setNumberDualInfeasibilities(0);
2467 *dualfeasible =
TRUE;
2489 return ( lpi->
clp->status() == 2 );
2507 if ( lpi->
clp->rayExists() )
2509 return ( lpi->
clp->status() == 2 );
2525 return ( lpi->
clp->isProvenDualInfeasible() && lpi->
clp->primalFeasible() );
2544 return ( lpi->
clp->status() == 1 && (lpi->
clp->secondaryStatus() == 0 || lpi->
clp->secondaryStatus() == 6) );
2558 return ( lpi->
clp->primalFeasible() );
2577 return ( lpi->
clp->status() == 1 && lpi->
clp->secondaryStatus() == 0 && lpi->
clp->rayExists() );
2595 if ( lpi->
clp->rayExists() )
2597 if ( lpi->
clp->status() == 1 && lpi->
clp->secondaryStatus() == 0 )
2618 return ( lpi->
clp->status() == 1 && lpi->
clp->secondaryStatus() == 0 && lpi->
clp->dualFeasible() );
2632 return ( lpi->
clp->isProvenDualInfeasible() );
2646 return ( lpi->
clp->dualFeasible() );
2664 return( lpi->
clp->isProvenOptimal() && (lpi->
clp->secondaryStatus() == 0 || lpi->
clp->secondaryStatus() == 6));
2711 assert( 0 <= lpi->
clp->status() && lpi->
clp->status() <= 5 );
2713 return( (lpi->
clp->status() <= 3) && (lpi->
clp->secondaryStatus() <= 1 || lpi->
clp->secondaryStatus() == 6 || lpi->
clp->secondaryStatus() == 9) );
2728 if ( lpi->
clp->status() == 1 )
2730 if ( lpi->
clp->secondaryStatus() == 1 )
2736 return ( lpi->
clp->isObjectiveLimitTestValid() && lpi->
clp->isDualObjectiveLimitReached() );
2759 return ( lpi->
clp->status() == 3 && lpi->
clp->secondaryStatus() != 9 );
2775 return ( lpi->
clp->status() == 3 && lpi->
clp->secondaryStatus() == 9 );
2789 return lpi->
clp->status();
2830 ClpSimplex* clp = lpi->
clp;
2832 *
objval = clp->objectiveValue();
2836 const double*
sol = clp->getColSolution();
2839 if( dualsol !=
NULL )
2841 const double* dsol = clp->getRowPrice();
2844 if( activity !=
NULL )
2846 const double* act = clp->getRowActivity();
2849 if( redcost !=
NULL )
2851 const double* red = clp->getReducedCost();
2872 const double* clpray = lpi->
clp->unboundedRay();
2874 if ( clpray ==
NULL )
2897 const double* dualray = lpi->
clp->infeasibilityRay();
2899 if ( dualray ==
NULL )
2905 double maxabsvalue = 0.0;
2906 double feastol = lpi->
clp->primalTolerance();
2907 for (
int j = 0; j < lpi->
clp->numberRows(); ++j)
2909 double val = fabs(dualray[j]);
2912 if ( val >= feastol )
2914 if ( val > maxabsvalue )
2916 if ( val < minabsvalue )
2922 if ( maxabsvalue > 0.0 )
2924 assert( 0.0 < minabsvalue && minabsvalue <= maxabsvalue );
2928 double scalingfactor = maxabsvalue;
2929 if ( minabsvalue / scalingfactor < feastol )
2930 scalingfactor = minabsvalue / feastol;
2932 for (
int j = 0; j < lpi->
clp->numberRows(); ++j)
2933 dualfarkas[j] = -dualray[j]/scalingfactor;
2938 for (
int j = 0; j < lpi->
clp->numberRows(); ++j)
2939 dualfarkas[j] = -dualray[j];
2958 *iterations = lpi->
clp->numberIterations();
3006 ClpSimplex* clp = lpi->
clp;
3010 for(
int i = 0;
i < clp->numberRows(); ++
i )
3012 switch ( clp->getRowStatus(
i) )
3014 case ClpSimplex::isFree:
3017 case ClpSimplex::basic:
3020 case ClpSimplex::atUpperBound:
3023 case ClpSimplex::atLowerBound:
3026 case ClpSimplex::superBasic:
3029 case ClpSimplex::isFixed:
3030 if (clp->getRowPrice()[
i] > 0.0)
3046 const double* lb = clp->getColLower();
3047 const double* ub = clp->getColUpper();
3050 for(
int j = 0; j < clp->numberColumns(); ++j )
3052 switch ( clp->getColumnStatus(j) )
3054 case ClpSimplex::isFree:
3057 case ClpSimplex::basic:
3060 case ClpSimplex::atUpperBound:
3062 assert( ub[j] < COIN_DBL_MAX );
3064 case ClpSimplex::atLowerBound:
3066 assert( lb[j] > -COIN_DBL_MAX );
3068 case ClpSimplex::superBasic:
3071 case ClpSimplex::isFixed:
3072 if (clp->getReducedCost()[j] > 0.0)
3075 assert( lb[j] > -COIN_DBL_MAX );
3080 assert( ub[j] < COIN_DBL_MAX );
3119 ClpSimplex* clp = lpi->
clp;
3120 clp->createStatus();
3122 const double* lhs = clp->getRowLower();
3123 const double* rhs = clp->getRowUpper();
3125 for(
int i = 0;
i < clp->numberRows(); ++
i )
3127 int status = rstat[
i];
3128 assert( 0 <= status && status <= 3 );
3135 if ( lhs[
i] <= -COIN_DBL_MAX && rhs[
i] >= COIN_DBL_MAX )
3136 clp->setRowStatus(
i, ClpSimplex::isFree);
3138 clp->setRowStatus(
i, ClpSimplex::superBasic);
3141 clp->setRowStatus(
i, ClpSimplex::basic);
3144 clp->setRowStatus(
i, ClpSimplex::atUpperBound);
3147 if (
EPSEQ(rhs[
i], lhs[
i], 1e-6) )
3148 clp->setRowStatus(
i, ClpSimplex::isFixed);
3150 clp->setRowStatus(
i, ClpSimplex::atLowerBound);
3159 const double* lb = clp->getColLower();
3160 const double* ub = clp->getColUpper();
3162 for(
int j = 0; j < clp->numberColumns(); ++j )
3164 int status = cstat[j];
3165 assert( 0 <= status && status <= 3 );
3172 if ( lb[j] <= -COIN_DBL_MAX && ub[j] >= COIN_DBL_MAX )
3173 clp->setColumnStatus(j, ClpSimplex::isFree);
3175 clp->setColumnStatus(j, ClpSimplex::superBasic);
3178 clp->setColumnStatus(j, ClpSimplex::basic);
3181 clp->setColumnStatus(j, ClpSimplex::atUpperBound);
3184 if (
EPSEQ(ub[j], lb[j], 1e-6) )
3185 clp->setColumnStatus(j, ClpSimplex::isFixed);
3187 clp->setColumnStatus(j, ClpSimplex::atLowerBound);
3210 clp->setWhatsChanged(clp->whatsChanged() & (~512));
3228 ClpSimplex* clp = lpi->
clp;
3229 int nrows = clp->numberRows();
3230 int ncols = clp->numberColumns();
3238 if ( clp->secondaryStatus() == 6 )
3240 assert( clp->getNumElements() == 0 );
3241 for (
int i = 0;
i < nrows; ++
i)
3245 clp->getBasics(idx);
3247 for (
int i = 0;
i < nrows; ++
i)
3249 if ( idx[
i] < ncols )
3252 bind[
i] = -1 - (idx[
i] - ncols);
3286 if ( ninds !=
NULL )
3289 ClpSimplex* clp = lpi->
clp;
3290 clp->getBInvRow(
r, coef);
3325 if ( ninds !=
NULL )
3328 ClpSimplex* clp = lpi->
clp;
3329 clp->getBInvCol(
c, coef);
3360 if ( ninds !=
NULL )
3363 ClpSimplex* clp = lpi->
clp;
3364 clp->getBInvARow(
r, coef, 0);
3394 if ( ninds !=
NULL )
3397 ClpSimplex* clp = lpi->
clp;
3398 clp->getBInvACol(
c, coef);
3430 int ncols = lpi->
clp->numberColumns();
3431 int nrows = lpi->
clp->numberRows();
3446 (*lpistate)->ncols = ncols;
3447 (*lpistate)->nrows = nrows;
3474 if( lpistate ==
NULL )
3477 lpncols = lpi->
clp->numberColumns();
3478 lpnrows = lpi->
clp->numberRows();
3490 for(
i = lpistate->
ncols;
i < lpncols; ++
i )
3496 bnd = (lpi->
clp->getColUpper())[
i];
3505 for(
i = lpistate->
nrows;
i < lpnrows; ++
i )
3524 lpi->
clp->allSlackBasis(
true);
3543 if ( *lpistate !=
NULL )
3556 return (lpistate !=
NULL);
3573 if ( lpi->
clp->readBasis(fname) < 0 )
3599 if ( lpi->
clp->writeBasis(fname,
false, 0) )
3694 if( lpi->
clp->scalingFlag() != 0 )
3706 *ival = lpi->
clp->maximumIterations();
3754 primalmode = 3; dualmode = 3;
break;
3756 primalmode = 0; dualmode = 1;
break;
3759 primalmode = 1; dualmode = 0;
break;
3761 primalmode = 1; dualmode = 2;
break;
3763 primalmode = 2; dualmode = 3;
break;
3769 ClpPrimalColumnSteepest primalpivot(primalmode);
3770 lpi->
clp->setPrimalColumnPivotAlgorithm(primalpivot);
3771 ClpDualRowSteepest dualpivot(dualmode);
3772 lpi->
clp->setDualRowPivotAlgorithm(dualpivot);
3782 lpi->
clp->scaling((ival > 0) ? 3 : 0);
3799 lpi->
clp->setLogLevel(2);
3801 lpi->
clp->setLogLevel(0);
3806 lpi->
clp->setMaximumIterations(ival);
3839 *dval = lpi->
clp->primalTolerance();
3842 *dval = lpi->
clp->dualTolerance();
3848 *dval = lpi->
clp->dualObjectiveLimit();
3851 *dval = lpi->
clp->maximumSeconds();
3884 lpi->
clp->setPrimalTolerance(dval);
3895 lpi->
clp->setDualTolerance(dval);
3903 lpi->
clp->setDualObjectiveLimit(dval);
3913 lpi->
clp->setMaximumSeconds(dval);
3954 return COIN_DBL_MAX;
3967 return (val >= COIN_DBL_MAX);
3985 const char* filename
3990 f = fopen(filename,
"r");
4022 if ( lpi->
clp->readMps(fname,
true,
false) )
4047 if ( lpi->
clp->writeMps(fname, 0, 2, lpi->
clp->optimizationDirection()) )
void SCIPdecodeDualBit(const SCIP_DUALPACKET *inp, int *out, int count)
void SCIPencodeDualBit(const int *inp, SCIP_DUALPACKET *out, int count)
packing single and dual bit values
unsigned int SCIP_DUALPACKET
static SCIP_RETCODE lpiStrongbranches(SCIP_LPI *lpi, int *cols, int ncols, SCIP_Real *psols, int itlim, SCIP_Real *down, SCIP_Real *up, SCIP_Bool *downvalid, SCIP_Bool *upvalid, int *iter)
SCIP_RETCODE SCIPlpiChgSides(SCIP_LPI *lpi, int nrows, const int *ind, const SCIP_Real *lhs, const SCIP_Real *rhs)
SCIP_RETCODE SCIPlpiSetState(SCIP_LPI *lpi, BMS_BLKMEM *blkmem, const SCIP_LPISTATE *lpistate)
SCIP_RETCODE SCIPlpiGetBInvACol(SCIP_LPI *lpi, int c, SCIP_Real *coef, int *inds, int *ninds)
SCIP_RETCODE SCIPlpiGetRealpar(SCIP_LPI *lpi, SCIP_LPPARAM type, SCIP_Real *dval)
SCIP_Real SCIPlpiInfinity(SCIP_LPI *lpi)
SCIP_Bool SCIPlpiIsObjlimExc(SCIP_LPI *lpi)
SCIP_RETCODE SCIPlpiChgObjsen(SCIP_LPI *lpi, SCIP_OBJSEN objsen)
SCIP_Bool SCIPlpiIsInfinity(SCIP_LPI *lpi, SCIP_Real val)
SCIP_RETCODE SCIPlpiClear(SCIP_LPI *lpi)
SCIP_RETCODE SCIPlpiClearState(SCIP_LPI *lpi)
SCIP_Bool SCIPlpiExistsDualRay(SCIP_LPI *lpi)
SCIP_Bool SCIPlpiExistsPrimalRay(SCIP_LPI *lpi)
SCIP_RETCODE SCIPlpiGetBase(SCIP_LPI *lpi, int *cstat, int *rstat)
SCIP_RETCODE SCIPlpiReadState(SCIP_LPI *lpi, const char *fname)
SCIP_RETCODE SCIPlpiAddRows(SCIP_LPI *lpi, int nrows, const SCIP_Real *lhs, const SCIP_Real *rhs, char **rownames, int nnonz, const int *beg, const int *ind, const SCIP_Real *val)
SCIP_RETCODE SCIPlpiGetPrimalRay(SCIP_LPI *lpi, SCIP_Real *ray)
SCIP_RETCODE SCIPlpiGetIntpar(SCIP_LPI *lpi, SCIP_LPPARAM type, int *ival)
SCIP_RETCODE SCIPlpiWriteLP(SCIP_LPI *lpi, const char *fname)
SCIP_RETCODE SCIPlpiSetIntegralityInformation(SCIP_LPI *lpi, int ncols, int *intInfo)
SCIP_Bool SCIPlpiIsDualInfeasible(SCIP_LPI *lpi)
SCIP_RETCODE SCIPlpiSetRealpar(SCIP_LPI *lpi, SCIP_LPPARAM type, SCIP_Real dval)
SCIP_RETCODE SCIPlpiStrongbranchFrac(SCIP_LPI *lpi, int col, SCIP_Real psol, int itlim, SCIP_Real *down, SCIP_Real *up, SCIP_Bool *downvalid, SCIP_Bool *upvalid, int *iter)
SCIP_RETCODE SCIPlpiSetNorms(SCIP_LPI *lpi, BMS_BLKMEM *blkmem, const SCIP_LPINORMS *lpinorms)
SCIP_RETCODE SCIPlpiGetNNonz(SCIP_LPI *lpi, int *nnonz)
SCIP_Bool SCIPlpiHasPrimalSolve(void)
SCIP_RETCODE SCIPlpiStrongbranchInt(SCIP_LPI *lpi, int col, SCIP_Real psol, int itlim, SCIP_Real *down, SCIP_Real *up, SCIP_Bool *downvalid, SCIP_Bool *upvalid, int *iter)
SCIP_RETCODE SCIPlpiGetBounds(SCIP_LPI *lpi, int firstcol, int lastcol, SCIP_Real *lbs, SCIP_Real *ubs)
SCIP_Bool SCIPlpiHasBarrierSolve(void)
SCIP_RETCODE SCIPlpiGetDualfarkas(SCIP_LPI *lpi, SCIP_Real *dualfarkas)
SCIP_RETCODE SCIPlpiGetObjval(SCIP_LPI *lpi, SCIP_Real *objval)
SCIP_RETCODE SCIPlpiScaleCol(SCIP_LPI *lpi, int col, SCIP_Real scaleval)
int SCIPlpiGetInternalStatus(SCIP_LPI *lpi)
SCIP_RETCODE SCIPlpiStartStrongbranch(SCIP_LPI *lpi)
SCIP_RETCODE SCIPlpiGetSolFeasibility(SCIP_LPI *lpi, SCIP_Bool *primalfeasible, SCIP_Bool *dualfeasible)
SCIP_RETCODE SCIPlpiFreeNorms(SCIP_LPI *lpi, BMS_BLKMEM *blkmem, SCIP_LPINORMS **lpinorms)
SCIP_Bool SCIPlpiIsIterlimExc(SCIP_LPI *lpi)
SCIP_RETCODE SCIPlpiChgBounds(SCIP_LPI *lpi, int ncols, const int *ind, const SCIP_Real *lb, const SCIP_Real *ub)
SCIP_Bool SCIPlpiIsPrimalUnbounded(SCIP_LPI *lpi)
SCIP_RETCODE SCIPlpiIgnoreInstability(SCIP_LPI *lpi, SCIP_Bool *success)
SCIP_RETCODE SCIPlpiWriteState(SCIP_LPI *lpi, const char *fname)
SCIP_RETCODE SCIPlpiFree(SCIP_LPI **lpi)
SCIP_RETCODE SCIPlpiStrongbranchesFrac(SCIP_LPI *lpi, int *cols, int ncols, SCIP_Real *psols, int itlim, SCIP_Real *down, SCIP_Real *up, SCIP_Bool *downvalid, SCIP_Bool *upvalid, int *iter)
SCIP_RETCODE SCIPlpiGetCoef(SCIP_LPI *lpi, int row, int col, SCIP_Real *val)
SCIP_Bool SCIPlpiIsPrimalFeasible(SCIP_LPI *lpi)
SCIP_RETCODE SCIPlpiReadLP(SCIP_LPI *lpi, const char *fname)
SCIP_RETCODE SCIPlpiGetRealSolQuality(SCIP_LPI *lpi, SCIP_LPSOLQUALITY qualityindicator, SCIP_Real *quality)
SCIP_Bool SCIPlpiIsDualFeasible(SCIP_LPI *lpi)
static SCIP_RETCODE lpiStrongbranch(SCIP_LPI *lpi, int col, SCIP_Real psol, int itlim, SCIP_Real *down, SCIP_Real *up, SCIP_Bool *downvalid, SCIP_Bool *upvalid, int *iter)
SCIP_RETCODE SCIPlpiGetNorms(SCIP_LPI *lpi, BMS_BLKMEM *blkmem, SCIP_LPINORMS **lpinorms)
SCIP_Bool SCIPlpiIsTimelimExc(SCIP_LPI *lpi)
SCIP_Bool SCIPlpiHasStateBasis(SCIP_LPI *lpi, SCIP_LPISTATE *lpistate)
SCIP_RETCODE SCIPlpiSetIntpar(SCIP_LPI *lpi, SCIP_LPPARAM type, int ival)
const char * SCIPlpiGetSolverName(void)
SCIP_RETCODE SCIPlpiSetBase(SCIP_LPI *lpi, const int *cstat, const int *rstat)
SCIP_Bool SCIPlpiHasPrimalRay(SCIP_LPI *lpi)
SCIP_RETCODE SCIPlpiGetBInvRow(SCIP_LPI *lpi, int r, SCIP_Real *coef, int *inds, int *ninds)
SCIP_RETCODE SCIPlpiDelRows(SCIP_LPI *lpi, int firstrow, int lastrow)
SCIP_RETCODE SCIPlpiGetCols(SCIP_LPI *lpi, int firstcol, int lastcol, SCIP_Real *lb, SCIP_Real *ub, int *nnonz, int *beg, int *ind, SCIP_Real *val)
SCIP_RETCODE SCIPlpiGetBInvCol(SCIP_LPI *lpi, int c, SCIP_Real *coef, int *inds, int *ninds)
SCIP_RETCODE SCIPlpiGetColNames(SCIP_LPI *lpi, int firstcol, int lastcol, char **colnames, char *namestorage, int namestoragesize, int *storageleft)
SCIP_RETCODE SCIPlpiGetBInvARow(SCIP_LPI *lpi, int r, const SCIP_Real *binvrow, SCIP_Real *coef, int *inds, int *ninds)
SCIP_RETCODE SCIPlpiGetRows(SCIP_LPI *lpi, int firstrow, int lastrow, SCIP_Real *lhs, SCIP_Real *rhs, int *nnonz, int *beg, int *ind, SCIP_Real *val)
SCIP_Bool SCIPlpiWasSolved(SCIP_LPI *lpi)
const char * SCIPlpiGetSolverDesc(void)
SCIP_RETCODE SCIPlpiSolveBarrier(SCIP_LPI *lpi, SCIP_Bool crossover)
SCIP_Bool SCIPlpiIsOptimal(SCIP_LPI *lpi)
SCIP_RETCODE SCIPlpiGetRowNames(SCIP_LPI *lpi, int firstrow, int lastrow, char **rownames, char *namestorage, int namestoragesize, int *storageleft)
SCIP_Bool SCIPlpiHasDualSolve(void)
SCIP_RETCODE SCIPlpiEndStrongbranch(SCIP_LPI *lpi)
SCIP_RETCODE SCIPlpiGetSides(SCIP_LPI *lpi, int firstrow, int lastrow, SCIP_Real *lhss, SCIP_Real *rhss)
SCIP_RETCODE SCIPlpiStrongbranchesInt(SCIP_LPI *lpi, int *cols, int ncols, SCIP_Real *psols, int itlim, SCIP_Real *down, SCIP_Real *up, SCIP_Bool *downvalid, SCIP_Bool *upvalid, int *iter)
SCIP_RETCODE SCIPlpiGetSol(SCIP_LPI *lpi, SCIP_Real *objval, SCIP_Real *primsol, SCIP_Real *dualsol, SCIP_Real *activity, SCIP_Real *redcost)
SCIP_Bool SCIPlpiHasDualRay(SCIP_LPI *lpi)
SCIP_RETCODE SCIPlpiDelColset(SCIP_LPI *lpi, int *dstat)
SCIP_RETCODE SCIPlpiGetObj(SCIP_LPI *lpi, int firstcol, int lastcol, SCIP_Real *vals)
SCIP_RETCODE SCIPlpiFreeState(SCIP_LPI *lpi, BMS_BLKMEM *blkmem, SCIP_LPISTATE **lpistate)
SCIP_Bool SCIPlpiIsPrimalInfeasible(SCIP_LPI *lpi)
SCIP_RETCODE SCIPlpiSolveDual(SCIP_LPI *lpi)
SCIP_RETCODE SCIPlpiAddCols(SCIP_LPI *lpi, int ncols, const SCIP_Real *obj, const SCIP_Real *lb, const SCIP_Real *ub, char **colnames, int nnonz, const int *beg, const int *ind, const SCIP_Real *val)
SCIP_RETCODE SCIPlpiSolvePrimal(SCIP_LPI *lpi)
SCIP_RETCODE SCIPlpiLoadColLP(SCIP_LPI *lpi, SCIP_OBJSEN objsen, int ncols, const SCIP_Real *obj, const SCIP_Real *lb, const SCIP_Real *ub, char **colnames, int nrows, const SCIP_Real *lhs, const SCIP_Real *rhs, char **rownames, int nnonz, const int *beg, const int *ind, const SCIP_Real *val)
SCIP_Bool SCIPlpiIsDualUnbounded(SCIP_LPI *lpi)
SCIP_RETCODE SCIPlpiGetIterations(SCIP_LPI *lpi, int *iterations)
SCIP_RETCODE SCIPlpiGetBasisInd(SCIP_LPI *lpi, int *bind)
SCIP_RETCODE SCIPlpiCreate(SCIP_LPI **lpi, SCIP_MESSAGEHDLR *messagehdlr, const char *name, SCIP_OBJSEN objsen)
void * SCIPlpiGetSolverPointer(SCIP_LPI *lpi)
SCIP_RETCODE SCIPlpiChgObj(SCIP_LPI *lpi, int ncols, const int *ind, const SCIP_Real *obj)
SCIP_RETCODE SCIPlpiGetObjsen(SCIP_LPI *lpi, SCIP_OBJSEN *objsen)
SCIP_Bool SCIPlpiIsStable(SCIP_LPI *lpi)
SCIP_RETCODE SCIPlpiGetNCols(SCIP_LPI *lpi, int *ncols)
SCIP_RETCODE SCIPlpiInterrupt(SCIP_LPI *lpi, SCIP_Bool interrupt)
SCIP_RETCODE SCIPlpiDelCols(SCIP_LPI *lpi, int firstcol, int lastcol)
SCIP_RETCODE SCIPlpiDelRowset(SCIP_LPI *lpi, int *dstat)
SCIP_RETCODE SCIPlpiScaleRow(SCIP_LPI *lpi, int row, SCIP_Real scaleval)
SCIP_RETCODE SCIPlpiGetNRows(SCIP_LPI *lpi, int *nrows)
SCIP_RETCODE SCIPlpiGetState(SCIP_LPI *lpi, BMS_BLKMEM *blkmem, SCIP_LPISTATE **lpistate)
SCIP_RETCODE SCIPlpiChgCoef(SCIP_LPI *lpi, int row, int col, SCIP_Real newval)
assert(minobj< SCIPgetCutoffbound(scip))
interface methods for specific LP solvers
static void lpistatePack(SCIP_LPISTATE *lpistate, const int *cstat, const int *rstat)
static void lpistateUnpack(const SCIP_LPISTATE *lpistate, int *cstat, int *rstat)
static SCIP_Bool fileExists(const char *filename)
static int rowpacketNum(int nrows)
SCIP_DUALPACKET ROWPACKET
static SCIP_RETCODE ensureCstatMem(SCIP_LPI *lpi, int num)
static void lpistateFree(SCIP_LPISTATE **lpistate, BMS_BLKMEM *blkmem)
SCIP_DUALPACKET COLPACKET
static void unsetFastmipClpParameters(SCIP_LPI *lpi)
static void setFactorizationFrequency(SCIP_LPI *lpi)
static SCIP_RETCODE ensureRstatMem(SCIP_LPI *lpi, int num)
static int colpacketNum(int ncols)
static void setFastmipClpParameters(SCIP_LPI *lpi)
static SCIP_RETCODE lpistateCreate(SCIP_LPISTATE **lpistate, BMS_BLKMEM *blkmem, int ncols, int nrows)
static void invalidateSolution(SCIP_LPI *lpi)
#define BMSfreeMemory(ptr)
#define BMSfreeBlockMemory(mem, ptr)
#define BMSallocBlockMemory(mem, ptr)
#define BMSreallocMemoryArray(ptr, num)
#define BMSallocMemoryArray(ptr, num)
#define BMSfreeMemoryArray(ptr)
#define BMSallocBlockMemoryArray(mem, ptr, num)
#define BMScopyMemoryArray(ptr, source, num)
#define BMSfreeBlockMemoryArray(mem, ptr, num)
struct BMS_BlkMem BMS_BLKMEM
#define BMSfreeMemoryArrayNull(ptr)
#define BMSallocMemory(ptr)
public methods for message output
bool setFactorizationFrequency
@ SCIP_PRICING_STEEPQSTART
@ SCIP_PRICING_LPIDEFAULT
enum SCIP_Pricing SCIP_PRICING
enum SCIP_LPParam SCIP_LPPARAM
struct SCIP_LPiState SCIP_LPISTATE
struct SCIP_LPiNorms SCIP_LPINORMS
@ SCIP_LPPAR_BARRIERCONVTOL
enum SCIP_LPSolQuality SCIP_LPSOLQUALITY
enum SCIP_ObjSen SCIP_OBJSEN
struct SCIP_Messagehdlr SCIP_MESSAGEHDLR
enum SCIP_Retcode SCIP_RETCODE