59 #include <ClpSimplex.hpp> 60 #include <ClpPrimalColumnSteepest.hpp> 61 #include <ClpDualRowSteepest.hpp> 62 #include <CoinIndexedVector.hpp> 63 #include <ClpConfig.h> 65 #include <config_clp.h> 66 #define CLP_VERSION VERSION 80 #if defined(_WIN32) || defined(_WIN64) 81 #define snprintf _snprintf 85 #ifdef LPI_CLP_DEBUG_WRITE_FILES 86 static int fileNr = 0;
90 #define SUMINFEASBOUND 1.0e-3 115 #define COLS_PER_PACKET SCIP_DUALPACKETSIZE 117 #define ROWS_PER_PACKET SCIP_DUALPACKETSIZE 212 assert(lpistate != 0);
228 assert(lpistate != 0);
245 assert(lpistate != 0);
265 assert(lpistate != 0);
266 assert(*lpistate != 0);
301 lpi->
clp->defaultFactorizationFrequency();
323 lpi->
clp->setPerturbation(50);
387 lpi->
clp->setSpecialOptions(32|64|512|1024|32768);
389 lpi->
clp->setSpecialOptions(32|64|128|512|1024|4096|32768);
393 lpi->
clp->setMoreSpecialOptions(8192 | lpi->
clp->moreSpecialOptions());
409 lpi->
clp->setPerturbation(100);
412 lpi->
clp->setSpecialOptions(0);
415 lpi->
clp->setPersistenceFlag(0);
445 return "COIN-OR Linear Programming Solver developed by J. Forrest et.al. (projects.coin-or.org/Clp)";
453 return (
void*) lpi->
clp;
463 SCIPerrorMessage(
"SCIPlpiSetIntegralityInformation() has not been implemented yet.\n");
493 (*lpi)->clp =
new ClpSimplex();
496 (*lpi)->cstatsize = 0;
497 (*lpi)->rstatsize = 0;
498 (*lpi)->startscratch =
true;
500 (*lpi)->validFactorization =
false;
501 (*lpi)->setFactorizationFrequency =
false;
502 (*lpi)->fastmip =
FALSE;
517 ClpPrimalColumnSteepest primalSteepest;
518 (*lpi)->clp->setPrimalColumnPivotAlgorithm(primalSteepest);
526 ClpDualRowSteepest dualSteepest;
527 (*lpi)->clp->setDualRowPivotAlgorithm(dualSteepest);
530 (*lpi)->clp->setStrParam(ClpProbName, std::string(name) );
533 (*lpi)->clp->setOptimizationDirection(objsen);
536 (*lpi)->clp->setLogLevel(0);
539 (*lpi)->clp->scaling(0);
555 assert((*lpi)->clp != 0);
604 assert(lpi->
clp != 0);
607 assert( nnonz > beg[ncols-1] );
611 ClpSimplex*
clp = lpi->
clp;
617 mybeg[
ncols] = nnonz;
620 clp->loadProblem(ncols, nrows, mybeg, ind, val, lb, ub, obj, lhs, rhs);
624 clp->setOptimizationDirection(objsen);
627 if ( colnames || rownames )
629 std::vector<std::string> columnNames(ncols);
630 std::vector<std::string> rowNames(nrows);
633 for (
int j = 0; j <
ncols; ++j)
634 columnNames[j].assign(colnames[j]);
638 for (
int i = 0; i <
ncols; ++i)
639 rowNames[i].assign(rownames[i]);
641 clp->copyNames(rowNames, columnNames);
665 assert(lpi->
clp != 0);
669 assert(nnonz == 0 || beg != 0);
670 assert(nnonz == 0 || ind != 0);
671 assert(nnonz == 0 || val != 0);
678 int numCols = lpi->
clp->getNumCols();
688 mybeg[
ncols] = nnonz;
691 lpi->
clp->addColumns(ncols, lb, ub, obj, mybeg, ind, val);
695 for (
int j = 0; j <=
ncols; ++j)
698 lpi->
clp->addColumns(ncols, lb, ub, obj, mybeg, 0, 0);
705 std::vector<std::string> columnNames(ncols);
706 for (
int j = 0; j <
ncols; ++j)
707 columnNames[j].assign(colnames[j]);
708 lpi->
clp->copyColumnNames(columnNames, numCols, numCols + ncols);
725 assert(lpi->
clp != 0);
726 assert(0 <= firstcol && firstcol <= lastcol && lastcol < lpi->
clp->numberColumns());
731 int num = lastcol-firstcol+1;
736 for (
int j = firstcol; j <= lastcol; ++j)
737 which[j - firstcol] = j;
739 lpi->
clp->deleteColumns(num, which);
757 assert(lpi->
clp != 0);
767 for (
int j = 0; j <
ncols; ++j)
772 lpi->
clp->deleteColumns(cnt, which);
777 for (
int j = 0; j <
ncols; ++j)
808 assert(lpi->
clp != 0);
811 assert(nnonz == 0 || beg != 0);
812 assert(nnonz == 0 || ind != 0);
813 assert(nnonz == 0 || val != 0);
818 int numRows = lpi->
clp->getNumRows();
827 mybeg[
nrows] = nnonz;
830 lpi->
clp->addRows(nrows, lhs, rhs, mybeg, ind, val);
835 for (
int i = 0; i <=
nrows; ++i)
837 lpi->
clp->addRows(nrows, lhs, rhs, mybeg, 0, 0);
844 std::vector<std::string> rowNames(nrows);
845 for (
int j = 0; j <
nrows; ++j)
846 rowNames[j].assign(rownames[j]);
847 lpi->
clp->copyRowNames(rowNames, numRows, numRows + nrows);
861 SCIPdebugMessage(
"calling SCIPlpiDelRows() (number: %d)\n", lastrow-firstrow+1);
864 assert(lpi->
clp != 0);
865 assert(0 <= firstrow && firstrow <= lastrow && lastrow < lpi->
clp->numberRows());
870 int num = lastrow-firstrow+1;
875 for (
int i = firstrow; i <= lastrow; ++i)
876 which[i - firstrow] = i;
878 lpi->
clp->deleteRows(num, which);
897 assert(lpi->
clp != 0);
907 for (
int i = 0; i <
nrows; ++i)
912 lpi->
clp->deleteRows(cnt, which);
917 for (
int i = 0; i <
nrows; ++i)
940 assert(lpi->
clp != 0);
945 lpi->
clp->resize(0,0);
961 assert(lpi->
clp != 0);
962 assert(ncols == 0 || (ind != 0 && lb != 0 && ub != 0));
968 ClpSimplex*
clp = lpi->
clp;
972 double* sol = lpi->
clp->primalColumnSolution();
973 const double* colLower = lpi->
clp->getColLower();
974 const double* colUpper = lpi->
clp->getColUpper();
976 for (
int j = 0; j <
ncols; ++j)
980 SCIPerrorMessage(
"LP Error: fixing lower bound for variable %d to infinity.\n", ind[j]);
985 SCIPerrorMessage(
"LP Error: fixing upper bound for variable %d to -infinity.\n", ind[j]);
989 clp->setColumnBounds(ind[j], lb[j], ub[j]);
993 if( clp->statusExists() )
995 assert( colLower != 0 );
996 assert( colUpper != 0 );
998 switch ( clp->getColumnStatus(k) )
1000 case ClpSimplex::isFree:
1001 case ClpSimplex::superBasic:
1004 case ClpSimplex::atUpperBound:
1005 sol[k] = colUpper[k];
1006 assert( colUpper[k] == ub[j] );
1008 case ClpSimplex::isFixed:
1009 case ClpSimplex::atLowerBound:
1010 sol[k] = colLower[k];
1011 assert( colLower[k] == lb[j] );
1039 assert(lpi->
clp != 0);
1046 ClpSimplex*
clp = lpi->
clp;
1048 for (
int i = 0; i <
nrows; ++i)
1049 clp->setRowBounds(ind[i], lhs[i], rhs[i]);
1066 assert(lpi->
clp != 0);
1067 assert(0 <= row && row < lpi->
clp->numberRows());
1068 assert(0 <= col && col < lpi->
clp->numberColumns());
1072 lpi->
clp->matrix()->modifyCoefficient(row, col, newval);
1087 assert(lpi->
clp != 0);
1092 lpi->
clp->setOptimizationDirection(objsen);
1109 assert(lpi->
clp != 0);
1115 ClpSimplex*
clp = lpi->
clp;
1118 for(
int j = 0; j <
ncols; ++j )
1119 clp->setObjCoeff(ind[j], obj[j]);
1135 assert(lpi->
clp != 0);
1136 assert(scaleval != 0.0);
1137 assert(0 <= row && row <= lpi->
clp->numberRows() );
1145 ClpSimplex*
clp = lpi->
clp;
1148 double* lhs = clp->rowLower();
1149 double* rhs = clp->rowUpper();
1151 double lhsval = lhs[row];
1152 if( lhsval > -COIN_DBL_MAX )
1154 else if( scaleval < 0.0 )
1155 lhsval = COIN_DBL_MAX;
1156 double rhsval = rhs[row];
1157 if( rhsval < COIN_DBL_MAX)
1159 else if( scaleval < 0.0 )
1160 rhsval = -COIN_DBL_MAX;
1161 if( scaleval < 0.0 )
1175 CoinPackedMatrix* M = clp->matrix();
1176 assert( M->getNumCols() == clp->numberColumns() );
1178 const CoinBigIndex* beg = M->getVectorStarts();
1179 const int* length = M->getVectorLengths();
1180 const int* ind = M->getIndices();
1181 double* val = M->getMutableElements();
1183 for (
int j = 0; j < M->getNumCols(); ++j)
1185 for (CoinBigIndex k = beg[j]; k < beg[j] + length[j]; ++k)
1208 assert(lpi->
clp != 0);
1209 assert(scaleval != 0.0);
1210 assert(0 <= col && col <= lpi->
clp->numberColumns() );
1218 ClpSimplex*
clp = lpi->
clp;
1221 double* objvec = clp->objective();
1222 objvec[col] *= scaleval;
1225 double* lb = clp->columnLower();
1226 double* ub = clp->columnUpper();
1227 double lbval = lb[col];
1228 double ubval = ub[col];
1230 if( lbval > -COIN_DBL_MAX )
1232 else if( scaleval < 0.0 )
1233 lbval = COIN_DBL_MAX;
1234 if( ubval < COIN_DBL_MAX )
1236 else if( scaleval < 0.0 )
1237 ubval = -COIN_DBL_MAX;
1238 if( scaleval < 0.0 )
1249 CoinPackedMatrix* M = clp->matrix();
1250 assert( M->getNumCols() == clp->numberColumns() );
1252 const CoinBigIndex* beg = M->getVectorStarts();
1253 const int* length = M->getVectorLengths();
1254 double* val = M->getMutableElements();
1255 for (CoinBigIndex k = beg[col]; k < beg[col] + length[col]; ++k)
1284 assert(lpi->
clp != 0);
1287 *nrows = lpi->
clp->numberRows();
1302 assert(lpi->
clp != 0);
1305 *ncols = lpi->
clp->numberColumns();
1320 assert(lpi->
clp != 0);
1323 *nnonz = lpi->
clp->getNumElements();
1348 assert(lpi->
clp != 0);
1349 assert(0 <= firstcol && firstcol <= lastcol && lastcol < lpi->
clp->numberColumns());
1351 ClpSimplex*
clp = lpi->
clp;
1354 assert( (lb != 0 && ub != 0) || (lb == 0 && ub == 0) );
1357 const double* colLower = clp->getColLower();
1358 const double* colUpper = clp->getColUpper();
1364 assert( nnonz != 0 || beg == 0);
1365 assert( nnonz != 0 || ind == 0);
1366 assert( nnonz != 0 || val == 0);
1370 CoinPackedMatrix* M = clp->matrix();
1372 assert( M->getNumCols() == clp->numberColumns() );
1374 const CoinBigIndex* Mbeg = M->getVectorStarts();
1375 const int* Mlength = M->getVectorLengths();
1376 const int* Mind = M->getIndices();
1377 const double* Mval = M->getElements();
1381 for (
int j = firstcol; j <= lastcol; ++j)
1383 beg[j-firstcol] = *nnonz;
1388 (*nnonz) += Mlength[j];
1415 assert(lpi->
clp != 0);
1416 assert(0 <= firstrow && firstrow <= lastrow && lastrow < lpi->
clp->numberRows());
1418 ClpSimplex*
clp = lpi->
clp;
1419 assert( (lhs != 0 && rhs != 0) || (lhs == 0 && rhs == 0) );
1422 const double* rowLower = clp->getRowLower();
1423 const double* rowUpper = clp->getRowUpper();
1429 assert( nnonz != 0 || beg == 0);
1430 assert( nnonz != 0 || ind == 0);
1431 assert( nnonz != 0 || val == 0);
1435 ClpMatrixBase* M = clp->rowCopy();
1437 M = clp->clpMatrix()->reverseOrderedCopy();
1439 assert( M->getNumRows() == clp->numberRows() );
1441 const CoinBigIndex* Mbeg = M->getVectorStarts();
1442 const int* Mlength = M->getVectorLengths();
1443 const int* Mind = M->getIndices();
1444 const double* Mval = M->getElements();
1447 for(
int i = firstrow; i <= lastrow; ++i )
1449 beg[i-firstrow] = *nnonz;
1450 for( CoinBigIndex k = Mbeg[i]; k < Mbeg[i] + Mlength[i]; ++k )
1452 ind[*nnonz] = Mind[k];
1453 val[*nnonz] = Mval[k];
1470 int namestoragesize,
1486 int namestoragesize,
1503 assert(lpi !=
NULL);
1519 assert( lpi !=
NULL );
1521 assert( objsen !=
NULL );
1524 if ( lpi->
clp->getObjSense() < 0 )
1544 assert(lpi->
clp != 0);
1545 assert(0 <= firstcol && firstcol <= lastcol && lastcol < lpi->
clp->numberColumns());
1548 const double* obj = lpi->
clp->getObjCoefficients();
1568 assert(lpi->
clp != 0);
1569 assert(0 <= firstcol && firstcol <= lastcol && lastcol < lpi->
clp->numberColumns());
1573 const double* colLower = lpi->
clp->getColLower();
1579 const double* colUpper = lpi->
clp->getColUpper();
1599 assert(lpi->
clp != 0);
1600 assert(0 <= firstrow && firstrow <= lastrow && lastrow < lpi->
clp->numberRows());
1604 const double* rowLower = lpi->
clp->getRowLower();
1610 const double* rowUpper = lpi->
clp->getRowUpper();
1629 assert(lpi->
clp != 0);
1630 assert(0 <= col && col < lpi->
clp->numberColumns());
1631 assert(0 <= row && row < lpi->
clp->numberRows());
1634 *val = lpi->
clp->matrix()->getCoefficient(row, col);
1658 assert(lpi->
clp != 0);
1660 SCIPdebugMessage(
"calling Clp primal(): %d cols, %d rows\n", lpi->
clp->numberColumns(), lpi->
clp->numberRows());
1662 #ifdef LPI_CLP_DEBUG_WRITE_FILES 1664 snprintf(filename, 255,
"debug_p_%d.mps", fileNr);
1665 fileNr = fileNr % 2;
1678 lpi->
clp->allSlackBasis(
true);
1689 int startFinishOptions = 1;
1691 startFinishOptions = startFinishOptions | 2;
1694 int status = lpi->
clp->primal(0, startFinishOptions);
1696 #ifdef LPI_CLP_DEBUG_WRITE_FILES 1697 char basisname[255];
1698 snprintf(basisname, 255,
"debug_p_%d.bas", fileNr);
1702 fileNr = fileNr % 2;
1716 assert( status != -1 );
1717 assert( status != 5 );
1718 if ( status == 4 || status == 5 || status == -1 )
1731 assert(lpi->
clp != 0);
1733 SCIPdebugMessage(
"calling Clp dual(): %d cols, %d rows\n", lpi->
clp->numberColumns(), lpi->
clp->numberRows());
1735 #ifdef LPI_CLP_DEBUG_WRITE_FILES 1737 snprintf(filename, 255,
"debug_d_%d.mps", fileNr);
1740 snprintf(filename, 255,
"debug_d_%d.sav", fileNr);
1753 lpi->
clp->allSlackBasis(
true);
1764 int startFinishOptions = 1;
1766 startFinishOptions = startFinishOptions | 2;
1769 int status = lpi->
clp->dual(0, startFinishOptions);
1771 #ifdef LPI_CLP_DEBUG_WRITE_FILES 1772 char basisname[255];
1773 snprintf(basisname, 255,
"debug_d_%d.bas", fileNr);
1777 fileNr = fileNr % 2;
1791 assert( status != -1 );
1792 assert( status != 5 );
1793 if ( status == 4 || status == 5 || status == -1 )
1807 assert(lpi->
clp != 0);
1809 SCIPdebugMessage(
"calling Clp barrier(): %d cols, %d rows\n", lpi->
clp->numberColumns(), lpi->
clp->numberRows());
1820 int status = lpi->
clp->barrier(crossover);
1833 assert( status != -1 );
1834 assert( status != 5 );
1835 if ( status == 4 || status == 5 || status == -1 )
1875 SCIPdebugMessage(
"calling SCIPlpiStrongbranch() on variable %d (%d iterations)\n", col, itlim);
1878 assert(lpi->
clp != 0);
1881 assert(downvalid != 0);
1882 assert(upvalid != 0);
1884 ClpSimplex*
clp = lpi->
clp;
1887 int ncols = clp->numberColumns();
1888 assert( 0 <= col && col < ncols );
1889 double** outputSolution =
NULL;
1894 int* outputStatus =
NULL;
1897 int* outputIterations =
NULL;
1901 int iterlimit = clp->maximumIterations();
1902 clp->setMaximumIterations(itlim);
1905 double objval = clp->objectiveValue();
1908 int specialoptions = clp->specialOptions();
1947 clp->setSpecialOptions(64|512|1024);
1949 clp->setSpecialOptions(64|128|512|1024|4096);
1960 int startFinishOptions = 1;
1962 startFinishOptions = startFinishOptions | 2;
1965 *down =
EPSCEIL(psol - 1.0, 1e-06);
1984 int res = clp->strongBranching(1, &col, up, down, outputSolution, outputStatus, outputIterations,
false,
true, startFinishOptions);
1987 clp->setSpecialOptions(specialoptions);
2000 *iter = outputIterations[0] + outputIterations[1];
2003 clp->setMaximumIterations(iterlimit);
2035 SCIPdebugMessage(
"calling SCIPlpiStrongbranches() on %d variables (%d iterations)\n", ncols, itlim);
2038 assert( lpi->
clp != 0 );
2039 assert( cols != 0 );
2040 assert( psols != 0 );
2041 assert( down != 0 );
2043 assert( downvalid != 0 );
2044 assert( upvalid != 0 );
2046 ClpSimplex*
clp = lpi->
clp;
2049 int n = clp->numberColumns();
2050 assert( 0 < ncols && ncols <= n );
2051 double** outputSolution =
NULL;
2053 for (
int j = 0; j < 2*
ncols; ++j)
2058 int* outputStatus =
NULL;
2061 int* outputIterations =
NULL;
2065 int iterlimit = clp->maximumIterations();
2066 clp->setMaximumIterations(itlim);
2069 double objval = clp->objectiveValue();
2072 int specialoptions = clp->specialOptions();
2111 clp->setSpecialOptions(64|512|1024);
2113 clp->setSpecialOptions(64|128|512|1024|4096);
2124 int startFinishOptions = 1;
2126 startFinishOptions = startFinishOptions | 2;
2129 for (
int j = 0; j <
ncols; ++j)
2131 assert( 0 <= cols[j] && cols[j] < n );
2132 down[j] =
EPSCEIL(psols[j] - 1.0, 1e-06);
2133 up[j] =
EPSFLOOR(psols[j] + 1.0, 1e-06);
2136 downvalid[j] =
TRUE;
2155 int res = clp->strongBranching(ncols, cols, up, down, outputSolution, outputStatus, outputIterations,
false,
true, startFinishOptions);
2158 clp->setSpecialOptions(specialoptions);
2162 for (
int j = 0; j <
ncols; ++j)
2169 *iter += outputIterations[2*j] + outputIterations[2*j+1];
2176 clp->setMaximumIterations(iterlimit);
2296 assert(lpi !=
NULL);
2311 assert(lpi->
clp != 0);
2312 assert(primalfeasible != 0);
2313 assert(dualfeasible != 0);
2315 if ( lpi->
clp->primalFeasible() )
2316 *primalfeasible =
TRUE;
2318 *primalfeasible =
FALSE;
2320 if ( lpi->
clp->dualFeasible() )
2321 *dualfeasible =
TRUE;
2323 *dualfeasible =
FALSE;
2326 if (lpi->
clp->status()==0 && ( ! (*primalfeasible) || ! (*dualfeasible)) )
2328 if ( !(*primalfeasible) && lpi->
clp->sumPrimalInfeasibilities() <
SUMINFEASBOUND )
2330 lpi->
clp->setNumberPrimalInfeasibilities(0);
2331 *primalfeasible =
TRUE;
2335 lpi->
clp->setNumberDualInfeasibilities(0);
2336 *dualfeasible =
TRUE;
2354 assert(lpi->
clp != 0);
2358 return ( lpi->
clp->status() == 2 );
2372 assert(lpi->
clp != 0);
2376 return ( lpi->
clp->status() == 2 );
2388 assert(lpi->
clp != 0);
2390 return ( lpi->
clp->isProvenDualInfeasible() && lpi->
clp->primalFeasible() );
2402 assert(lpi->
clp != 0);
2409 return ( lpi->
clp->status() == 1 && (lpi->
clp->secondaryStatus() == 0 || lpi->
clp->secondaryStatus() == 6) );
2421 assert(lpi->
clp != 0);
2423 return ( lpi->
clp->primalFeasible() );
2437 assert(lpi->
clp != 0);
2441 return ( lpi->
clp->status() == 1 && lpi->
clp->secondaryStatus() == 0 && lpi->
clp->algorithm() < 0 );
2455 assert(lpi->
clp != 0);
2459 if ( lpi->
clp->rayExists() )
2461 if ( lpi->
clp->status() == 1 && lpi->
clp->secondaryStatus() == 0 && lpi->
clp->algorithm() < 0)
2465 if ( lpi->
clp->status() != 2 || lpi->
clp->algorithm() <= 0 )
2466 lpi->
clp->deleteRay();
2483 assert(lpi->
clp != 0);
2488 return ( lpi->
clp->status() == 1 && lpi->
clp->secondaryStatus() == 0 && lpi->
clp->dualFeasible() );
2500 assert(lpi->
clp != 0);
2502 return ( lpi->
clp->isProvenDualInfeasible() );
2514 assert(lpi->
clp != 0);
2516 return ( lpi->
clp->dualFeasible() );
2528 assert(lpi->
clp != 0);
2534 return( lpi->
clp->isProvenOptimal() && (lpi->
clp->secondaryStatus() == 0 || lpi->
clp->secondaryStatus() == 6));
2546 assert(lpi->
clp != 0);
2571 assert( 0 <= lpi->
clp->status() && lpi->
clp->status() <= 5 );
2572 return( (lpi->
clp->status() <= 3) && (lpi->
clp->secondaryStatus() <= 1 || lpi->
clp->secondaryStatus() == 6 || lpi->
clp->secondaryStatus() == 9) );
2584 assert(lpi->
clp != 0);
2587 if ( lpi->
clp->status() == 1 )
2589 if ( lpi->
clp->secondaryStatus() == 1 )
2595 return ( lpi->
clp->isObjectiveLimitTestValid() && (lpi->
clp->isPrimalObjectiveLimitReached() || lpi->
clp->isDualObjectiveLimitReached()) );
2614 assert(lpi->
clp != 0);
2618 return ( lpi->
clp->status() == 3 && lpi->
clp->secondaryStatus() != 9 );
2630 assert(lpi->
clp != 0);
2634 return ( lpi->
clp->status() == 3 && lpi->
clp->secondaryStatus() == 9 );
2646 assert(lpi->
clp != 0);
2648 return lpi->
clp->status();
2661 assert(lpi->
clp != 0);
2662 assert(objval != 0);
2664 *objval = lpi->
clp->objectiveValue();
2683 assert(lpi->
clp != 0);
2685 ClpSimplex*
clp = lpi->
clp;
2687 *objval = clp->objectiveValue();
2691 const double* sol = clp->getColSolution();
2696 const double* dsol = clp->getRowPrice();
2701 const double* act = clp->getRowActivity();
2706 const double* red = clp->getReducedCost();
2723 assert(lpi->
clp != 0);
2727 const double* clpray = lpi->
clp->unboundedRay();
2748 assert(lpi->
clp != 0);
2749 assert(dualfarkas != 0);
2752 const double* dualray = lpi->
clp->infeasibilityRay();
2778 assert(iterations != 0);
2780 *iterations = lpi->
clp->numberIterations();
2796 assert(lpi !=
NULL);
2797 assert(quality !=
NULL);
2826 assert(lpi->
clp != 0);
2828 ClpSimplex*
clp = lpi->
clp;
2833 for(
int i = 0; i < clp->numberRows(); ++i )
2835 switch ( clp->getRowStatus(i) )
2837 case ClpSimplex::isFree:
2840 case ClpSimplex::basic:
2843 case ClpSimplex::atUpperBound:
2846 case ClpSimplex::atLowerBound:
2849 case ClpSimplex::superBasic:
2852 case ClpSimplex::isFixed:
2853 if (clp->getRowPrice()[i] > 0.0)
2868 for(
int j = 0; j < clp->numberColumns(); ++j )
2870 switch ( clp->getColumnStatus(j) )
2872 case ClpSimplex::isFree:
2875 case ClpSimplex::basic:
2878 case ClpSimplex::atUpperBound:
2881 case ClpSimplex::atLowerBound:
2884 case ClpSimplex::superBasic:
2887 case ClpSimplex::isFixed:
2888 if (clp->getReducedCost()[j] > 0.0)
2914 assert(lpi->
clp != 0);
2920 ClpSimplex*
clp = lpi->
clp;
2921 clp->createStatus();
2923 const double* lhs = clp->getRowLower();
2924 const double* rhs = clp->getRowUpper();
2926 assert( rstat != 0 || clp->numberRows() == 0 );
2927 for(
int i = 0; i < clp->numberRows(); ++i )
2929 int status = rstat[i];
2930 assert( 0 <= status && status <= 3 );
2937 if (lhs[i] <= -COIN_DBL_MAX && rhs[i] >= COIN_DBL_MAX)
2938 clp->setRowStatus(i, ClpSimplex::isFree);
2940 clp->setRowStatus(i, ClpSimplex::superBasic);
2943 clp->setRowStatus(i, ClpSimplex::basic);
2946 clp->setRowStatus(i, ClpSimplex::atUpperBound);
2949 if (
EPSEQ(rhs[i], lhs[i], 1e-6) )
2950 clp->setRowStatus(i, ClpSimplex::isFixed);
2952 clp->setRowStatus(i, ClpSimplex::atLowerBound);
2961 const double* lb = clp->getColLower();
2962 const double* ub = clp->getColUpper();
2964 assert( cstat != 0 || clp->numberColumns() == 0 );
2965 for(
int j = 0; j < clp->numberColumns(); ++j )
2967 int status = cstat[j];
2968 assert( 0 <= status && status <= 3 );
2975 if (lb[j] <= -COIN_DBL_MAX && ub[j] >= COIN_DBL_MAX)
2976 clp->setColumnStatus(j, ClpSimplex::isFree);
2978 clp->setColumnStatus(j, ClpSimplex::superBasic);
2981 clp->setColumnStatus(j, ClpSimplex::basic);
2984 clp->setColumnStatus(j, ClpSimplex::atUpperBound);
2987 if (
EPSEQ(ub[j], lb[j], 1e-6) )
2988 clp->setColumnStatus(j, ClpSimplex::isFixed);
2990 clp->setColumnStatus(j, ClpSimplex::atLowerBound);
3013 clp->setWhatsChanged(clp->whatsChanged() & (~512));
3029 assert(lpi->
clp != 0);
3032 ClpSimplex*
clp = lpi->
clp;
3033 int nrows = clp->numberRows();
3034 int ncols = clp->numberColumns();
3042 if ( clp->secondaryStatus() == 6 )
3044 assert( clp->getNumElements() == 0 );
3045 for (
int i = 0; i <
nrows; ++i)
3049 clp->getBasics(idx);
3051 for (
int i = 0; i <
nrows; ++i)
3053 if ( idx[i] < ncols )
3056 bind[i] = -1 - (idx[i] -
ncols);
3085 assert( lpi->
clp != 0 );
3086 assert( coef != 0 );
3087 assert( 0 <= r && r <= lpi->
clp->numberRows() );
3090 if ( ninds !=
NULL )
3093 ClpSimplex*
clp = lpi->
clp;
3094 clp->getBInvRow(r, coef);
3124 assert( lpi->
clp != 0 );
3125 assert( coef != 0 );
3126 assert( 0 <= c && c <= lpi->
clp->numberRows() );
3129 if ( ninds !=
NULL )
3132 ClpSimplex*
clp = lpi->
clp;
3133 clp->getBInvCol(c, coef);
3159 assert( lpi->
clp != 0 );
3160 assert( coef != 0 );
3161 assert( 0 <= r && r <= lpi->
clp->numberRows() );
3164 if ( ninds !=
NULL )
3167 ClpSimplex*
clp = lpi->
clp;
3168 clp->getBInvARow(r, coef, 0);
3193 assert( lpi->
clp != 0 );
3194 assert( coef != 0 );
3195 assert( 0 <= c && c <= lpi->
clp->numberColumns() );
3198 if ( ninds !=
NULL )
3201 ClpSimplex*
clp = lpi->
clp;
3202 clp->getBInvACol(c, coef);
3229 assert(blkmem != 0);
3231 assert(lpi->
clp != 0);
3232 assert(lpistate != 0);
3234 int ncols = lpi->
clp->numberColumns();
3235 int nrows = lpi->
clp->numberRows();
3250 (*lpistate)->ncols =
ncols;
3251 (*lpistate)->nrows =
nrows;
3274 assert(lpi->
clp != 0);
3275 assert(lpistate != 0);
3277 lpncols = lpi->
clp->numberColumns();
3278 lpnrows = lpi->
clp->numberRows();
3279 assert(lpistate->
ncols <= lpncols);
3280 assert(lpistate->
nrows <= lpnrows);
3290 for( i = lpistate->
ncols; i < lpncols; ++i )
3296 bnd = (lpi->
clp->getColUpper())[i];
3305 for( i = lpistate->
nrows; i < lpnrows; ++i )
3322 assert(lpi->
clp != 0);
3324 lpi->
clp->allSlackBasis(
true);
3340 assert(lpistate !=
NULL);
3342 if ( *lpistate !=
NULL )
3354 return (lpistate !=
NULL);
3368 if ( lpi->
clp->readBasis(fname) < 0 )
3391 if ( lpi->
clp->writeBasis(fname,
false, 0) )
3418 assert(lpinorms !=
NULL);
3434 assert(lpinorms ==
NULL);
3447 assert(lpinorms ==
NULL);
3475 assert(lpi->
clp != 0);
3484 if( lpi->
clp->scalingFlag() != 0 )
3496 *ival = lpi->
clp->maximumIterations();
3519 assert(lpi->
clp != 0);
3544 primalmode = 3; dualmode = 3;
break;
3546 primalmode = 0; dualmode = 1;
break;
3549 primalmode = 1; dualmode = 0;
break;
3551 primalmode = 1; dualmode = 2;
break;
3553 primalmode = 2; dualmode = 3;
break;
3559 ClpPrimalColumnSteepest primalpivot(primalmode);
3560 lpi->
clp->setPrimalColumnPivotAlgorithm(primalpivot);
3561 ClpDualRowSteepest dualpivot(dualmode);
3562 lpi->
clp->setDualRowPivotAlgorithm(dualpivot);
3572 lpi->
clp->scaling((ival > 0) ? 3 : 0);
3589 lpi->
clp->setLogLevel(2);
3591 lpi->
clp->setLogLevel(0);
3594 lpi->
clp->setMaximumIterations(ival);
3621 assert(lpi->
clp != 0);
3627 *dval = lpi->
clp->primalTolerance();
3630 *dval = lpi->
clp->dualTolerance();
3636 if ( lpi->
clp->optimizationDirection() > 0 )
3637 *dval = lpi->
clp->primalObjectiveLimit();
3639 *dval = lpi->
clp->dualObjectiveLimit();
3642 if ( lpi->
clp->optimizationDirection() > 0 )
3643 *dval = lpi->
clp->dualObjectiveLimit();
3645 *dval = lpi->
clp->primalObjectiveLimit();
3648 *dval = lpi->
clp->maximumSeconds();
3667 assert(lpi->
clp != 0);
3672 lpi->
clp->setPrimalTolerance(dval);
3675 lpi->
clp->setDualTolerance(dval);
3681 if ( lpi->
clp->optimizationDirection() > 0 )
3682 lpi->
clp->setPrimalObjectiveLimit(dval);
3684 lpi->
clp->setDualObjectiveLimit(dval);
3687 if ( lpi->
clp->optimizationDirection() > 0 )
3688 lpi->
clp->setDualObjectiveLimit(dval);
3690 lpi->
clp->setPrimalObjectiveLimit(dval);
3693 lpi->
clp->setMaximumSeconds(dval);
3721 return COIN_DBL_MAX;
3733 return (val >= COIN_DBL_MAX);
3751 const char* filename
3756 f = fopen(filename,
"r");
3774 assert(lpi->
clp != 0);
3787 if ( lpi->
clp->readMps(fname,
true,
false) )
3802 assert(lpi->
clp != 0);
3811 if ( lpi->
clp->writeMps(fname, 0, 2, lpi->
clp->optimizationDirection()) )
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_Bool SCIPlpiIsObjlimExc(SCIP_LPI *lpi)
SCIP_RETCODE SCIPlpiSetIntegralityInformation(SCIP_LPI *lpi, int ncols, int *intInfo)
SCIP_RETCODE SCIPlpiWriteLP(SCIP_LPI *lpi, const char *fname)
enum SCIP_LPSolQuality SCIP_LPSOLQUALITY
SCIP_RETCODE SCIPlpiSolveDual(SCIP_LPI *lpi)
SCIP_RETCODE SCIPlpiGetPrimalRay(SCIP_LPI *lpi, SCIP_Real *ray)
#define BMSfreeMemoryArrayNull(ptr)
SCIP_Bool SCIPlpiHasPrimalRay(SCIP_LPI *lpi)
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 SCIPlpiExistsPrimalRay(SCIP_LPI *lpi)
SCIP_RETCODE SCIPlpiGetIntpar(SCIP_LPI *lpi, SCIP_LPPARAM type, int *ival)
SCIP_Bool SCIPlpiIsStable(SCIP_LPI *lpi)
enum SCIP_ObjSen SCIP_OBJSEN
SCIP_RETCODE SCIPlpiGetNCols(SCIP_LPI *lpi, int *ncols)
void SCIPdecodeDualBit(const SCIP_DUALPACKET *inp, int *out, int count)
SCIP_RETCODE SCIPlpiGetColNames(SCIP_LPI *lpi, int firstcol, int lastcol, char **colnames, char *namestorage, int namestoragesize, int *storageleft)
interface methods for specific LP solvers
SCIP_RETCODE SCIPlpiSetIntpar(SCIP_LPI *lpi, SCIP_LPPARAM type, int ival)
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)
static SCIP_RETCODE ensureRstatMem(SCIP_LPI *lpi, int num)
enum SCIP_Retcode SCIP_RETCODE
SCIP_RETCODE SCIPlpiSetNorms(SCIP_LPI *lpi, BMS_BLKMEM *blkmem, const SCIP_LPINORMS *lpinorms)
static void lpistateFree(SCIP_LPISTATE **lpistate, BMS_BLKMEM *blkmem)
SCIP_RETCODE SCIPlpiChgObj(SCIP_LPI *lpi, int ncols, const int *ind, const SCIP_Real *obj)
enum SCIP_LPParam SCIP_LPPARAM
#define BMSallocMemoryArray(ptr, num)
SCIP_RETCODE SCIPlpiReadLP(SCIP_LPI *lpi, const char *fname)
#define BMSfreeMemory(ptr)
enum SCIP_Pricing SCIP_PRICING
SCIP_RETCODE SCIPlpiChgObjsen(SCIP_LPI *lpi, SCIP_OBJSEN objsen)
SCIP_RETCODE SCIPlpiGetObjsen(SCIP_LPI *lpi, SCIP_OBJSEN *objsen)
int SCIPlpiGetInternalStatus(SCIP_LPI *lpi)
SCIP_RETCODE SCIPlpiGetRealSolQuality(SCIP_LPI *lpi, SCIP_LPSOLQUALITY qualityindicator, SCIP_Real *quality)
SCIP_Bool SCIPlpiIsDualUnbounded(SCIP_LPI *lpi)
SCIP_DUALPACKET COLPACKET
SCIP_RETCODE SCIPlpiSolveBarrier(SCIP_LPI *lpi, SCIP_Bool crossover)
SCIP_Bool SCIPlpiHasDualRay(SCIP_LPI *lpi)
static void lpistateUnpack(const SCIP_LPISTATE *lpistate, int *cstat, int *rstat)
SCIP_Bool SCIPlpiIsPrimalUnbounded(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 SCIPlpiScaleRow(SCIP_LPI *lpi, int row, SCIP_Real scaleval)
SCIP_Bool SCIPlpiHasStateBasis(SCIP_LPI *lpi, SCIP_LPISTATE *lpistate)
SCIP_RETCODE SCIPlpiCreate(SCIP_LPI **lpi, SCIP_MESSAGEHDLR *messagehdlr, const char *name, SCIP_OBJSEN objsen)
packing single and dual bit values
SCIP_RETCODE SCIPlpiSetState(SCIP_LPI *lpi, BMS_BLKMEM *, const SCIP_LPISTATE *lpistate)
#define BMSfreeMemoryArray(ptr)
SCIP_RETCODE SCIPlpiDelCols(SCIP_LPI *lpi, int firstcol, int lastcol)
SCIP_RETCODE SCIPlpiGetBounds(SCIP_LPI *lpi, int firstcol, int lastcol, SCIP_Real *lbs, SCIP_Real *ubs)
SCIP_RETCODE SCIPlpiReadState(SCIP_LPI *lpi, const char *fname)
SCIP_RETCODE SCIPlpiGetSides(SCIP_LPI *lpi, int firstrow, int lastrow, SCIP_Real *lhss, SCIP_Real *rhss)
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)
static SCIP_RETCODE lpistateCreate(SCIP_LPISTATE **lpistate, BMS_BLKMEM *blkmem, int ncols, int nrows)
SCIP_RETCODE SCIPlpiFree(SCIP_LPI **lpi)
SCIP_RETCODE SCIPlpiIgnoreInstability(SCIP_LPI *lpi, SCIP_Bool *success)
SCIP_DUALPACKET ROWPACKET
SCIP_RETCODE SCIPlpiGetRowNames(SCIP_LPI *lpi, int firstrow, int lastrow, char **rownames, char *namestorage, int namestoragesize, int *storageleft)
SCIP_RETCODE SCIPlpiScaleCol(SCIP_LPI *lpi, int col, SCIP_Real scaleval)
SCIP_RETCODE SCIPlpiEndStrongbranch(SCIP_LPI *lpi)
SCIP_RETCODE SCIPlpiSolvePrimal(SCIP_LPI *lpi)
SCIP_RETCODE SCIPlpiDelRowset(SCIP_LPI *lpi, int *dstat)
SCIP_RETCODE SCIPlpiGetRealpar(SCIP_LPI *lpi, SCIP_LPPARAM type, SCIP_Real *dval)
void * SCIPlpiGetSolverPointer(SCIP_LPI *lpi)
SCIP_RETCODE SCIPlpiGetNorms(SCIP_LPI *lpi, BMS_BLKMEM *blkmem, SCIP_LPINORMS **lpinorms)
const char * SCIPlpiGetSolverDesc(void)
void SCIPencodeDualBit(const int *inp, SCIP_DUALPACKET *out, int count)
#define BMSfreeBlockMemory(mem, ptr)
SCIP_Bool SCIPlpiExistsDualRay(SCIP_LPI *lpi)
SCIP_RETCODE SCIPlpiGetBInvACol(SCIP_LPI *lpi, int c, SCIP_Real *coef, int *inds, int *ninds)
SCIP_RETCODE SCIPlpiGetBInvRow(SCIP_LPI *lpi, int r, SCIP_Real *coef, int *inds, int *ninds)
unsigned int SCIP_DUALPACKET
static SCIP_RETCODE ensureCstatMem(SCIP_LPI *lpi, int num)
SCIP_Bool SCIPlpiIsOptimal(SCIP_LPI *lpi)
#define BMSallocBlockMemoryArray(mem, ptr, num)
SCIP_Bool SCIPlpiWasSolved(SCIP_LPI *lpi)
SCIP_RETCODE SCIPlpiWriteState(SCIP_LPI *lpi, const char *fname)
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 SCIPlpiChgBounds(SCIP_LPI *lpi, int ncols, const int *ind, const SCIP_Real *lb, const SCIP_Real *ub)
#define BMSfreeBlockMemoryArray(mem, ptr, num)
static int colpacketNum(int ncols)
SCIP_RETCODE SCIPlpiChgCoef(SCIP_LPI *lpi, int row, int col, SCIP_Real newval)
static SCIP_Bool fileExists(const char *filename)
SCIP_RETCODE SCIPlpiGetObjval(SCIP_LPI *lpi, SCIP_Real *objval)
SCIP_Real SCIPlpiInfinity(SCIP_LPI *)
SCIP_RETCODE SCIPlpiStartStrongbranch(SCIP_LPI *lpi)
const char * SCIPlpiGetSolverName(void)
#define BMScopyMemoryArray(ptr, source, num)
SCIP_RETCODE SCIPlpiFreeState(SCIP_LPI *lpi, BMS_BLKMEM *blkmem, SCIP_LPISTATE **lpistate)
SCIP_RETCODE SCIPlpiGetBasisInd(SCIP_LPI *lpi, int *bind)
SCIP_Bool SCIPlpiIsIterlimExc(SCIP_LPI *lpi)
static void invalidateSolution(SCIP_LPI *lpi)
SCIP_RETCODE SCIPlpiGetBase(SCIP_LPI *lpi, int *cstat, int *rstat)
SCIP_RETCODE SCIPlpiSetRealpar(SCIP_LPI *lpi, SCIP_LPPARAM type, SCIP_Real dval)
SCIP_RETCODE SCIPlpiGetBInvARow(SCIP_LPI *lpi, int r, const SCIP_Real *binvrow, SCIP_Real *coef, int *inds, int *ninds)
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)
bool setFactorizationFrequency
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 SCIPlpiGetSol(SCIP_LPI *lpi, SCIP_Real *objval, SCIP_Real *primsol, SCIP_Real *dualsol, SCIP_Real *activity, SCIP_Real *redcost)
SCIP_RETCODE SCIPlpiClearState(SCIP_LPI *lpi)
static int rowpacketNum(int nrows)
SCIP_Bool SCIPlpiIsPrimalFeasible(SCIP_LPI *lpi)
SCIP_RETCODE SCIPlpiClear(SCIP_LPI *lpi)
static void setFastmipClpParameters(SCIP_LPI *lpi)
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 SCIPlpiGetBInvCol(SCIP_LPI *lpi, int c, SCIP_Real *coef, int *inds, int *ninds)
SCIP_RETCODE SCIPlpiGetSolFeasibility(SCIP_LPI *lpi, SCIP_Bool *primalfeasible, SCIP_Bool *dualfeasible)
SCIP_Bool SCIPlpiIsDualInfeasible(SCIP_LPI *lpi)
public methods for message output
SCIP_RETCODE SCIPlpiChgSides(SCIP_LPI *lpi, int nrows, const int *ind, const SCIP_Real *lhs, const SCIP_Real *rhs)
SCIP_Bool SCIPlpiIsDualFeasible(SCIP_LPI *lpi)
SCIP_RETCODE SCIPlpiGetIterations(SCIP_LPI *lpi, int *iterations)
SCIP_RETCODE SCIPlpiDelRows(SCIP_LPI *lpi, int firstrow, int lastrow)
SCIP_Bool SCIPlpiIsInfinity(SCIP_LPI *, SCIP_Real val)
SCIP_RETCODE SCIPlpiGetCoef(SCIP_LPI *lpi, int row, int col, SCIP_Real *val)
#define BMSallocMemory(ptr)
#define BMSreallocMemoryArray(ptr, num)
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_MESSAGEHDLR * messagehdlr
SCIP_RETCODE SCIPlpiGetNNonz(SCIP_LPI *lpi, int *nnonz)
SCIP_RETCODE SCIPlpiGetState(SCIP_LPI *lpi, BMS_BLKMEM *blkmem, SCIP_LPISTATE **lpistate)
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)
#define BMSallocBlockMemory(mem, ptr)
SCIP_RETCODE SCIPlpiFreeNorms(SCIP_LPI *lpi, BMS_BLKMEM *blkmem, SCIP_LPINORMS **lpinorms)
struct BMS_BlkMem BMS_BLKMEM
SCIP_RETCODE SCIPlpiGetDualfarkas(SCIP_LPI *lpi, SCIP_Real *dualfarkas)
static void unsetFastmipClpParameters(SCIP_LPI *lpi)
SCIP_RETCODE SCIPlpiSetBase(SCIP_LPI *lpi, const int *cstat, const int *rstat)
SCIP_Bool SCIPlpiIsTimelimExc(SCIP_LPI *lpi)
SCIP_RETCODE SCIPlpiGetObj(SCIP_LPI *lpi, int firstcol, int lastcol, SCIP_Real *vals)
static void lpistatePack(SCIP_LPISTATE *lpistate, const int *cstat, const int *rstat)
SCIP_RETCODE SCIPlpiGetNRows(SCIP_LPI *lpi, int *nrows)
SCIP_RETCODE SCIPlpiDelColset(SCIP_LPI *lpi, int *dstat)
SCIP_Bool SCIPlpiIsPrimalInfeasible(SCIP_LPI *lpi)