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
91#if defined(_WIN32) || defined(_WIN64)
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);
847 assert(0 <= firstcol && firstcol <= lastcol && lastcol < lpi->clp->numberColumns());
852 int num = lastcol-firstcol+1;
857 for (
int j = firstcol; j <= lastcol; ++j)
858 which[j - firstcol] = j;
860 lpi->
clp->deleteColumns(num, which);
884 int ncols = lpi->
clp->getNumCols();
888 for (
int j = 0; j < ncols; ++j)
893 lpi->
clp->deleteColumns(cnt, which);
898 for (
int j = 0; j < ncols; ++j)
939 int numRows = lpi->
clp->getNumRows();
948 int ncols = lpi->
clp->getNumCols();
949 for (
int j = 0; j < nnonz; ++j)
952 assert( 0 <= ind[j] && ind[j] < ncols );
958 mybeg[nrows] = nnonz;
961 lpi->
clp->addRows(nrows, lhs, rhs, mybeg, ind, val);
966 for (
int i = 0;
i <= nrows; ++
i)
968 lpi->
clp->addRows(nrows, lhs, rhs, mybeg, 0, 0);
975 std::vector<std::string> rowNames(nrows);
976 for (
int j = 0; j < nrows; ++j)
977 rowNames[j].assign(rownames[j]);
978 lpi->
clp->copyRowNames(rowNames, numRows, numRows + nrows);
992 SCIPdebugMessage(
"calling SCIPlpiDelRows() (number: %d)\n", lastrow-firstrow+1);
996 assert(0 <= firstrow && firstrow <= lastrow && lastrow < lpi->clp->numberRows());
1001 int num = lastrow-firstrow+1;
1006 for (
int i = firstrow;
i <= lastrow; ++
i)
1007 which[
i - firstrow] =
i;
1009 lpi->
clp->deleteRows(num, which);
1034 int nrows = lpi->
clp->getNumRows();
1038 for (
int i = 0;
i < nrows; ++
i)
1040 if ( dstat[
i] == 1 )
1043 lpi->
clp->deleteRows(cnt, which);
1048 for (
int i = 0;
i < nrows; ++
i)
1050 if ( dstat[
i] == 1 )
1077 lpi->
clp->resize(0,0);
1102 ClpSimplex* clp = lpi->
clp;
1104#if SCIP_DISABLED_CODE
1107 double*
sol = lpi->
clp->primalColumnSolution();
1108 const double* colLower = lpi->
clp->getColLower();
1109 const double* colUpper = lpi->
clp->getColUpper();
1112 for (
int j = 0; j < ncols; ++j)
1116 SCIPerrorMessage(
"LP Error: fixing lower bound for variable %d to infinity.\n", ind[j]);
1121 SCIPerrorMessage(
"LP Error: fixing upper bound for variable %d to -infinity.\n", ind[j]);
1125 clp->setColumnBounds(ind[j], lb[j], ub[j]);
1127#if SCIP_DISABLED_CODE
1131 if( clp->statusExists() )
1136 switch ( clp->getColumnStatus(k) )
1138 case ClpSimplex::isFree:
1139 case ClpSimplex::superBasic:
1142 case ClpSimplex::atUpperBound:
1143 sol[k] = colUpper[k];
1144 assert( colUpper[k] == ub[j] );
1146 case ClpSimplex::isFixed:
1147 case ClpSimplex::atLowerBound:
1148 sol[k] = colLower[k];
1149 assert( colLower[k] == lb[j] );
1187 ClpSimplex* clp = lpi->
clp;
1189 for (
int i = 0;
i < nrows; ++
i)
1190 clp->setRowBounds(ind[
i], lhs[
i], rhs[
i]);
1208 assert(0 <= row && row < lpi->clp->numberRows());
1209 assert(0 <= col && col < lpi->clp->numberColumns());
1213 lpi->
clp->matrix()->modifyCoefficient(row, col, newval);
1233 lpi->
clp->setOptimizationDirection(objsen);
1256 ClpSimplex* clp = lpi->
clp;
1259 for(
int j = 0; j < ncols; ++j )
1260 clp->setObjCoeff(ind[j],
obj[j]);
1278 assert(0 <= row && row <= lpi->clp->numberRows() );
1286 ClpSimplex* clp = lpi->
clp;
1289 double* lhs = clp->rowLower();
1290 double* rhs = clp->rowUpper();
1292 double lhsval = lhs[row];
1293 if( lhsval > -COIN_DBL_MAX )
1295 else if( scaleval < 0.0 )
1296 lhsval = COIN_DBL_MAX;
1297 double rhsval = rhs[row];
1298 if( rhsval < COIN_DBL_MAX)
1300 else if( scaleval < 0.0 )
1301 rhsval = -COIN_DBL_MAX;
1302 if( scaleval < 0.0 )
1316 CoinPackedMatrix* M = clp->matrix();
1317 assert( M->getNumCols() == clp->numberColumns() );
1319 const CoinBigIndex* beg = M->getVectorStarts();
1320 const int* length = M->getVectorLengths();
1321 const int* ind = M->getIndices();
1322 double* val = M->getMutableElements();
1324 for (
int j = 0; j < M->getNumCols(); ++j)
1326 for (CoinBigIndex k = beg[j]; k < beg[j] + length[j]; ++k)
1351 assert(0 <= col && col <= lpi->clp->numberColumns() );
1359 ClpSimplex* clp = lpi->
clp;
1362 double* objvec = clp->objective();
1363 objvec[col] *= scaleval;
1366 double* lb = clp->columnLower();
1367 double* ub = clp->columnUpper();
1368 double lbval = lb[col];
1369 double ubval = ub[col];
1371 if( lbval > -COIN_DBL_MAX )
1373 else if( scaleval < 0.0 )
1374 lbval = COIN_DBL_MAX;
1375 if( ubval < COIN_DBL_MAX )
1377 else if( scaleval < 0.0 )
1378 ubval = -COIN_DBL_MAX;
1379 if( scaleval < 0.0 )
1390 CoinPackedMatrix* M = clp->matrix();
1391 assert( M->getNumCols() == clp->numberColumns() );
1393 const CoinBigIndex* beg = M->getVectorStarts();
1394 const int* length = M->getVectorLengths();
1395 double* val = M->getMutableElements();
1396 for (CoinBigIndex k = beg[col]; k < beg[col] + length[col]; ++k)
1428 *nrows = lpi->
clp->numberRows();
1446 *ncols = lpi->
clp->numberColumns();
1464 *nnonz = lpi->
clp->getNumElements();
1490 assert(0 <= firstcol && firstcol <= lastcol && lastcol < lpi->clp->numberColumns());
1494 ClpSimplex* clp = lpi->
clp;
1499 const double* colLower = clp->getColLower();
1500 const double* colUpper = clp->getColUpper();
1506 if ( nnonz !=
NULL )
1508 CoinPackedMatrix* M = clp->matrix();
1510 assert( M->getNumCols() == clp->numberColumns() );
1512 const CoinBigIndex* Mbeg = M->getVectorStarts();
1513 const int* Mlength = M->getVectorLengths();
1514 const int* Mind = M->getIndices();
1515 const double* Mval = M->getElements();
1519 for (
int j = firstcol; j <= lastcol; ++j)
1521 beg[j-firstcol] = *nnonz;
1526 (*nnonz) += Mlength[j];
1554 assert(0 <= firstrow && firstrow <= lastrow && lastrow < lpi->clp->numberRows());
1558 ClpSimplex* clp = lpi->
clp;
1561 const double* rowLower = clp->getRowLower();
1562 const double* rowUpper = clp->getRowUpper();
1568 if ( nnonz !=
NULL )
1570 ClpMatrixBase* M = clp->rowCopy();
1572 M = clp->clpMatrix()->reverseOrderedCopy();
1574 assert( M->getNumRows() == clp->numberRows() );
1576 const CoinBigIndex* Mbeg = M->getVectorStarts();
1577 const int* Mlength = M->getVectorLengths();
1578 const int* Mind = M->getIndices();
1579 const double* Mval = M->getElements();
1582 for(
int i = firstrow;
i <= lastrow; ++
i )
1584 beg[
i-firstrow] = *nnonz;
1585 for( CoinBigIndex k = Mbeg[
i]; k < Mbeg[
i] + Mlength[
i]; ++k )
1587 ind[*nnonz] = Mind[k];
1588 val[*nnonz] = Mval[k];
1605 int namestoragesize,
1611 assert(colnames !=
NULL || namestoragesize == 0);
1612 assert(namestorage !=
NULL || namestoragesize == 0);
1613 assert(namestoragesize >= 0);
1629 int namestoragesize,
1635 assert(rownames !=
NULL || namestoragesize == 0);
1636 assert(namestorage !=
NULL || namestoragesize == 0);
1637 assert(namestoragesize >= 0);
1676 if ( lpi->
clp->getObjSense() < 0 )
1697 assert(0 <= firstcol && firstcol <= lastcol && lastcol < lpi->clp->numberColumns());
1700 const double*
obj = lpi->
clp->getObjCoefficients();
1721 assert(0 <= firstcol && firstcol <= lastcol && lastcol < lpi->clp->numberColumns());
1725 const double* colLower = lpi->
clp->getColLower();
1731 const double* colUpper = lpi->
clp->getColUpper();
1752 assert(0 <= firstrow && firstrow <= lastrow && lastrow < lpi->clp->numberRows());
1756 const double* rowLower = lpi->
clp->getRowLower();
1762 const double* rowUpper = lpi->
clp->getRowUpper();
1782 assert(0 <= col && col < lpi->clp->numberColumns());
1783 assert(0 <= row && row < lpi->clp->numberRows());
1786 *val = lpi->
clp->matrix()->getCoefficient(row, col);
1812 SCIPdebugMessage(
"calling Clp primal(): %d cols, %d rows\n", lpi->
clp->numberColumns(), lpi->
clp->numberRows());
1814#ifdef LPI_CLP_DEBUG_WRITE_FILES
1816 snprintf(filename, 255,
"debug_p_%d.mps", fileNr);
1817 fileNr = fileNr % 2;
1830 lpi->
clp->allSlackBasis(
true);
1841 int startFinishOptions = 1;
1843 startFinishOptions = startFinishOptions | 2;
1846 int status = lpi->
clp->primal(0, startFinishOptions);
1848#ifdef LPI_CLP_DEBUG_WRITE_FILES
1849 char basisname[255];
1850 snprintf(basisname, 255,
"debug_p_%d.bas", fileNr);
1854 fileNr = fileNr % 2;
1872 if ( status == 4 || status == 5 || status == -1 )
1887 SCIPdebugMessage(
"calling Clp dual(): %d cols, %d rows\n", lpi->
clp->numberColumns(), lpi->
clp->numberRows());
1889#ifdef LPI_CLP_DEBUG_WRITE_FILES
1891 snprintf(filename, 255,
"debug_d_%d.mps", fileNr);
1894 snprintf(filename, 255,
"debug_d_%d.sav", fileNr);
1907 lpi->
clp->allSlackBasis(
true);
1918 int startFinishOptions = 1;
1920 startFinishOptions = startFinishOptions | 2;
1923 int status = lpi->
clp->dual(0, startFinishOptions);
1925#ifdef LPI_CLP_DEBUG_WRITE_FILES
1926 char basisname[255];
1927 snprintf(basisname, 255,
"debug_d_%d.bas", fileNr);
1931 fileNr = fileNr % 2;
1949 if ( status == 4 || status == 5 || status == -1 )
1965 SCIPdebugMessage(
"calling Clp barrier(): %d cols, %d rows; crossover: %u\n", lpi->
clp->numberColumns(), lpi->
clp->numberRows(), crossover);
1976#if (CLP_VERSION_MAJOR >= 1 && CLP_VERSION_MINOR > 17) || CLP_VERSION_MAJOR >= 2
1977 int startFinishOptions = 1;
1978 int status = lpi->
clp->barrier(crossover, startFinishOptions);
1980 int status = lpi->
clp->barrier(crossover);
1999 if ( status == 4 || status == 5 || status == -1 )
2045 SCIPdebugMessage(
"calling SCIPlpiStrongbranch() on variable %d (%d iterations)\n", col, itlim);
2054 ClpSimplex* clp = lpi->
clp;
2057 int ncols = clp->numberColumns();
2058 assert( 0 <= col && col < ncols );
2059 double** outputSolution =
NULL;
2064 int* outputStatus =
NULL;
2067 int* outputIterations =
NULL;
2071 int iterlimit = clp->maximumIterations();
2072 clp->setMaximumIterations(itlim);
2075 double objval = clp->objectiveValue();
2078 int specialoptions = clp->specialOptions();
2082 lpi->
clp->setSpecialOptions(32|64|128|512|1024|2048|4096|32768|262144|2097152|0x2000000);
2092 int startFinishOptions = 1;
2094 startFinishOptions = startFinishOptions | 2;
2097 *down =
EPSCEIL(psol - 1.0, 1e-06);
2115 int res = clp->strongBranching(1, &col, up, down, outputSolution, outputStatus, outputIterations,
false,
true, startFinishOptions);
2118 clp->setSpecialOptions(specialoptions);
2131 *iter = outputIterations[0] + outputIterations[1];
2134 clp->setMaximumIterations(iterlimit);
2166 SCIPdebugMessage(
"calling SCIPlpiStrongbranches() on %d variables (%d iterations)\n", ncols, itlim);
2177 ClpSimplex* clp = lpi->
clp;
2180 int n = clp->numberColumns();
2181 assert( 0 < ncols && ncols <= n );
2182 double** outputSolution =
NULL;
2184 for (
int j = 0; j < 2*ncols; ++j)
2189 int* outputStatus =
NULL;
2192 int* outputIterations =
NULL;
2196 int iterlimit = clp->maximumIterations();
2197 clp->setMaximumIterations(itlim);
2200 double objval = clp->objectiveValue();
2203 int specialoptions = clp->specialOptions();
2207 lpi->
clp->setSpecialOptions(32|64|128|512|1024|2048|4096|32768|262144|2097152|0x2000000);
2217 int startFinishOptions = 1;
2219 startFinishOptions = startFinishOptions | 2;
2222 for (
int j = 0; j < ncols; ++j)
2224 assert( 0 <= cols[j] && cols[j] < n );
2225 down[j] =
EPSCEIL(psols[j] - 1.0, 1e-06);
2226 up[j] =
EPSFLOOR(psols[j] + 1.0, 1e-06);
2229 downvalid[j] =
TRUE;
2248 int res = clp->strongBranching(ncols, cols, up, down, outputSolution, outputStatus, outputIterations,
false,
true, startFinishOptions);
2251 clp->setSpecialOptions(specialoptions);
2255 for (
int j = 0; j < ncols; ++j)
2262 *iter += outputIterations[2*j] + outputIterations[2*j+1];
2269 clp->setMaximumIterations(iterlimit);
2418 if ( lpi->
clp->primalFeasible() )
2419 *primalfeasible =
TRUE;
2421 *primalfeasible =
FALSE;
2423 if ( lpi->
clp->dualFeasible() )
2424 *dualfeasible =
TRUE;
2426 *dualfeasible =
FALSE;
2429 if (lpi->
clp->status()==0 && ( ! (*primalfeasible) || ! (*dualfeasible)) )
2431 if ( !(*primalfeasible) && lpi->
clp->sumPrimalInfeasibilities() <
SUMINFEASBOUND )
2433 lpi->
clp->setNumberPrimalInfeasibilities(0);
2434 *primalfeasible =
TRUE;
2438 lpi->
clp->setNumberDualInfeasibilities(0);
2439 *dualfeasible =
TRUE;
2461 return ( lpi->
clp->status() == 2 );
2479 if ( lpi->
clp->rayExists() )
2481 return ( lpi->
clp->status() == 2 );
2497 return ( lpi->
clp->isProvenDualInfeasible() && lpi->
clp->primalFeasible() );
2516 return ( lpi->
clp->status() == 1 && (lpi->
clp->secondaryStatus() == 0 || lpi->
clp->secondaryStatus() == 6) );
2530 return ( lpi->
clp->primalFeasible() );
2549 return ( lpi->
clp->status() == 1 && lpi->
clp->secondaryStatus() == 0 && lpi->
clp->rayExists() );
2567 if ( lpi->
clp->rayExists() )
2569 if ( lpi->
clp->status() == 1 && lpi->
clp->secondaryStatus() == 0 )
2590 return ( lpi->
clp->status() == 1 && lpi->
clp->secondaryStatus() == 0 && lpi->
clp->dualFeasible() );
2604 return ( lpi->
clp->isProvenDualInfeasible() );
2618 return ( lpi->
clp->dualFeasible() );
2636 return( lpi->
clp->isProvenOptimal() && (lpi->
clp->secondaryStatus() == 0 || lpi->
clp->secondaryStatus() == 6));
2683 assert( 0 <= lpi->
clp->status() && lpi->
clp->status() <= 5 );
2685 return( (lpi->
clp->status() <= 3) && (lpi->
clp->secondaryStatus() <= 1 || lpi->
clp->secondaryStatus() == 6 || lpi->
clp->secondaryStatus() == 9) );
2700 if ( lpi->
clp->status() == 1 )
2702 if ( lpi->
clp->secondaryStatus() == 1 )
2708 return ( lpi->
clp->isObjectiveLimitTestValid() && lpi->
clp->isDualObjectiveLimitReached() );
2731 return ( lpi->
clp->status() == 3 && lpi->
clp->secondaryStatus() != 9 );
2747 return ( lpi->
clp->status() == 3 && lpi->
clp->secondaryStatus() == 9 );
2761 return lpi->
clp->status();
2802 ClpSimplex* clp = lpi->
clp;
2804 *
objval = clp->objectiveValue();
2808 const double*
sol = clp->getColSolution();
2811 if( dualsol !=
NULL )
2813 const double* dsol = clp->getRowPrice();
2816 if( activity !=
NULL )
2818 const double* act = clp->getRowActivity();
2821 if( redcost !=
NULL )
2823 const double* red = clp->getReducedCost();
2844 const double* clpray = lpi->
clp->unboundedRay();
2846 if ( clpray ==
NULL )
2869 const double* dualray = lpi->
clp->infeasibilityRay();
2871 if ( dualray ==
NULL )
2877 double maxabsvalue = 0.0;
2878 double feastol = lpi->
clp->primalTolerance();
2879 for (
int j = 0; j < lpi->
clp->numberRows(); ++j)
2881 double val = fabs(dualray[j]);
2884 if ( val >= feastol )
2886 if ( val > maxabsvalue )
2888 if ( val < minabsvalue )
2894 if ( maxabsvalue > 0.0 )
2896 assert( 0.0 < minabsvalue && minabsvalue <= maxabsvalue );
2900 double scalingfactor = maxabsvalue;
2901 if ( minabsvalue / scalingfactor < feastol )
2902 scalingfactor = minabsvalue / feastol;
2904 for (
int j = 0; j < lpi->
clp->numberRows(); ++j)
2905 dualfarkas[j] = -dualray[j]/scalingfactor;
2910 for (
int j = 0; j < lpi->
clp->numberRows(); ++j)
2911 dualfarkas[j] = -dualray[j];
2930 *iterations = lpi->
clp->numberIterations();
2978 ClpSimplex* clp = lpi->
clp;
2982 for(
int i = 0;
i < clp->numberRows(); ++
i )
2984 switch ( clp->getRowStatus(
i) )
2986 case ClpSimplex::isFree:
2989 case ClpSimplex::basic:
2992 case ClpSimplex::atUpperBound:
2995 case ClpSimplex::atLowerBound:
2998 case ClpSimplex::superBasic:
3001 case ClpSimplex::isFixed:
3002 if (clp->getRowPrice()[
i] > 0.0)
3018 const double* lb = clp->getColLower();
3019 const double* ub = clp->getColUpper();
3022 for(
int j = 0; j < clp->numberColumns(); ++j )
3024 switch ( clp->getColumnStatus(j) )
3026 case ClpSimplex::isFree:
3029 case ClpSimplex::basic:
3032 case ClpSimplex::atUpperBound:
3034 assert( ub[j] < COIN_DBL_MAX );
3036 case ClpSimplex::atLowerBound:
3038 assert( lb[j] > -COIN_DBL_MAX );
3040 case ClpSimplex::superBasic:
3043 case ClpSimplex::isFixed:
3044 if (clp->getReducedCost()[j] > 0.0)
3047 assert( lb[j] > -COIN_DBL_MAX );
3052 assert( ub[j] < COIN_DBL_MAX );
3091 ClpSimplex* clp = lpi->
clp;
3092 clp->createStatus();
3094 const double* lhs = clp->getRowLower();
3095 const double* rhs = clp->getRowUpper();
3097 for(
int i = 0;
i < clp->numberRows(); ++
i )
3099 int status = rstat[
i];
3100 assert( 0 <= status && status <= 3 );
3107 if ( lhs[
i] <= -COIN_DBL_MAX && rhs[
i] >= COIN_DBL_MAX )
3108 clp->setRowStatus(
i, ClpSimplex::isFree);
3110 clp->setRowStatus(
i, ClpSimplex::superBasic);
3113 clp->setRowStatus(
i, ClpSimplex::basic);
3116 clp->setRowStatus(
i, ClpSimplex::atUpperBound);
3119 if (
EPSEQ(rhs[
i], lhs[
i], 1e-6) )
3120 clp->setRowStatus(
i, ClpSimplex::isFixed);
3122 clp->setRowStatus(
i, ClpSimplex::atLowerBound);
3131 const double* lb = clp->getColLower();
3132 const double* ub = clp->getColUpper();
3134 for(
int j = 0; j < clp->numberColumns(); ++j )
3136 int status = cstat[j];
3137 assert( 0 <= status && status <= 3 );
3144 if ( lb[j] <= -COIN_DBL_MAX && ub[j] >= COIN_DBL_MAX )
3145 clp->setColumnStatus(j, ClpSimplex::isFree);
3147 clp->setColumnStatus(j, ClpSimplex::superBasic);
3150 clp->setColumnStatus(j, ClpSimplex::basic);
3153 clp->setColumnStatus(j, ClpSimplex::atUpperBound);
3156 if (
EPSEQ(ub[j], lb[j], 1e-6) )
3157 clp->setColumnStatus(j, ClpSimplex::isFixed);
3159 clp->setColumnStatus(j, ClpSimplex::atLowerBound);
3182 clp->setWhatsChanged(clp->whatsChanged() & (~512));
3200 ClpSimplex* clp = lpi->
clp;
3201 int nrows = clp->numberRows();
3202 int ncols = clp->numberColumns();
3210 if ( clp->secondaryStatus() == 6 )
3212 assert( clp->getNumElements() == 0 );
3213 for (
int i = 0;
i < nrows; ++
i)
3217 clp->getBasics(idx);
3219 for (
int i = 0;
i < nrows; ++
i)
3221 if ( idx[
i] < ncols )
3224 bind[
i] = -1 - (idx[
i] - ncols);
3258 if ( ninds !=
NULL )
3261 ClpSimplex* clp = lpi->
clp;
3262 clp->getBInvRow(
r, coef);
3297 if ( ninds !=
NULL )
3300 ClpSimplex* clp = lpi->
clp;
3301 clp->getBInvCol(
c, coef);
3332 if ( ninds !=
NULL )
3335 ClpSimplex* clp = lpi->
clp;
3336 clp->getBInvARow(
r, coef, 0);
3366 if ( ninds !=
NULL )
3369 ClpSimplex* clp = lpi->
clp;
3370 clp->getBInvACol(
c, coef);
3402 int ncols = lpi->
clp->numberColumns();
3403 int nrows = lpi->
clp->numberRows();
3418 (*lpistate)->ncols = ncols;
3419 (*lpistate)->nrows = nrows;
3446 if( lpistate ==
NULL )
3449 lpncols = lpi->
clp->numberColumns();
3450 lpnrows = lpi->
clp->numberRows();
3462 for(
i = lpistate->
ncols;
i < lpncols; ++
i )
3468 bnd = (lpi->
clp->getColUpper())[
i];
3477 for(
i = lpistate->
nrows;
i < lpnrows; ++
i )
3496 lpi->
clp->allSlackBasis(
true);
3515 if ( *lpistate !=
NULL )
3528 return (lpistate !=
NULL);
3545 if ( lpi->
clp->readBasis(fname) < 0 )
3571 if ( lpi->
clp->writeBasis(fname,
false, 0) )
3666 if( lpi->
clp->scalingFlag() != 0 )
3678 *ival = lpi->
clp->maximumIterations();
3726 primalmode = 3; dualmode = 3;
break;
3728 primalmode = 0; dualmode = 1;
break;
3731 primalmode = 1; dualmode = 0;
break;
3733 primalmode = 1; dualmode = 2;
break;
3735 primalmode = 2; dualmode = 3;
break;
3741 ClpPrimalColumnSteepest primalpivot(primalmode);
3742 lpi->
clp->setPrimalColumnPivotAlgorithm(primalpivot);
3743 ClpDualRowSteepest dualpivot(dualmode);
3744 lpi->
clp->setDualRowPivotAlgorithm(dualpivot);
3754 lpi->
clp->scaling((ival > 0) ? 3 : 0);
3771 lpi->
clp->setLogLevel(2);
3773 lpi->
clp->setLogLevel(0);
3778 lpi->
clp->setMaximumIterations(ival);
3811 *dval = lpi->
clp->primalTolerance();
3814 *dval = lpi->
clp->dualTolerance();
3820 *dval = lpi->
clp->dualObjectiveLimit();
3823 *dval = lpi->
clp->maximumSeconds();
3856 lpi->
clp->setPrimalTolerance(dval);
3867 lpi->
clp->setDualTolerance(dval);
3875 lpi->
clp->setDualObjectiveLimit(dval);
3885 lpi->
clp->setMaximumSeconds(dval);
3926 return COIN_DBL_MAX;
3939 return (val >= COIN_DBL_MAX);
3957 const char* filename
3962 f = fopen(filename,
"r");
3994 if ( lpi->
clp->readMps(fname,
true,
false) )
4019 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