43#define getcwd(X, Y) _getcwd(X, Y)
49#include "scip/scipdefplugins.h"
50#include "scip/reader_lp.h"
51#include "scip/cons_knapsack.h"
52#include "scip/cons_linear.h"
53#include "scip/cons_logicor.h"
54#include "scip/cons_setppc.h"
55#include "scip/cons_varbound.h"
56#include "scip/cons_bounddisjunction.h"
57#include "scip/cons_sos1.h"
58#include "scip/cons_sos2.h"
59#include "scip/pub_misc.h"
86 assert( SCIPvarGetIndex((SCIP_VAR*) key) >= 0 );
87 return (
unsigned int) SCIPvarGetIndex((SCIP_VAR*) key);
91ScipParaInstance::allocateMemoryForOrdinaryConstraints(
170 lConsNames += strlen( SCIPconsGetName(cons) )+ 1;
184 int nvars = SCIPgetNVarsLinear(
scip, cons);
188 SCIP_Real *coefs = SCIPgetValsLinear(
scip, cons);
189 SCIP_VAR **vars = SCIPgetVarsLinear(
scip, cons);
190 for(
int v = 0; v < nvars; ++v)
203 SCIP_VAR **vars = SCIPgetVars(
scip);
212 SCIP_CALL_ABORT( SCIPcreateConsLinear(
scip, &cons,
214 TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE) );
215 SCIP_CALL_ABORT( SCIPaddCons(
scip, cons) );
216 SCIPdebug( SCIP_CALL_ABORT( SCIPprintCons(
scip, cons, NULL) ) );
217 SCIP_CALL_ABORT( SCIPreleaseCons(
scip, &cons) );
218 delete [] varsInCons;
234 int nvars = SCIPgetNVarsSetppc(
scip,cons);
238 SCIP_VAR **vars = SCIPgetVarsSetppc(
scip, cons);
239 for(
int v = 0; v < nvars; ++v)
251 SCIP_VAR **vars = SCIPgetVars(
scip);
262 case SCIP_SETPPCTYPE_PARTITIONING:
263 SCIP_CALL_ABORT( SCIPcreateConsSetpart(
scip, &cons,
265 TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE) );
267 case SCIP_SETPPCTYPE_PACKING:
268 SCIP_CALL_ABORT( SCIPcreateConsSetpack(
scip, &cons,
270 TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE) );
272 case SCIP_SETPPCTYPE_COVERING:
273 SCIP_CALL_ABORT( SCIPcreateConsSetcover(
scip, &cons,
275 TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE) );
280 SCIP_CALL_ABORT( SCIPaddCons(
scip, cons) );
281 SCIPdebug( SCIP_CALL_ABORT( SCIPprintCons(
scip, cons, NULL) ) );
282 SCIP_CALL_ABORT( SCIPreleaseCons(
scip, &cons) );
283 delete [] varsInCons;
299 int nvars = SCIPgetNVarsLogicor(
scip, cons);
303 SCIP_VAR **vars = SCIPgetVarsLogicor(
scip, cons);
304 for(
int v = 0; v < nvars; ++v )
306 if( SCIPvarIsActive(vars[v]) )
308 else if( SCIPvarIsNegated(vars[v]) )
321 SCIP_VAR **vars = SCIPgetVars(
scip);
334 SCIP_CALL_ABORT( SCIPgetNegatedVar(
scip, vars[-(
idxLogicorVars[c][v] + 1)], &varsInCons[v]) );
341 SCIP_CALL_ABORT( SCIPcreateConsLogicor(
scip, &cons,
343 TRUE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE) );
344 SCIP_CALL_ABORT( SCIPaddCons(
scip, cons) );
345 SCIPdebug( SCIP_CALL_ABORT( SCIPprintCons(
scip, cons, NULL) ) );
346 SCIP_CALL_ABORT( SCIPreleaseCons(
scip, &cons) );
348 delete [] varsInCons;
365 int nvars = SCIPgetNVarsKnapsack(
scip, cons);
369 SCIP_Longint *weights = SCIPgetWeightsKnapsack(
scip, cons);
370 SCIP_VAR **vars = SCIPgetVarsKnapsack(
scip,cons);
371 for(
int v = 0; v < nvars; ++v )
385 SCIP_VAR **vars = SCIPgetVars(
scip);
394 SCIP_CALL_ABORT( SCIPcreateConsKnapsack(
scip, &cons,
396 TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE) );
397 SCIP_CALL_ABORT( SCIPaddCons(
scip, cons) );
398 SCIPdebug( SCIP_CALL_ABORT( SCIPprintCons(
scip, cons, NULL) ) );
399 SCIP_CALL_ABORT( SCIPreleaseCons(
scip, &cons) );
400 delete [] varsInCons;
429 SCIP_VAR **vars = SCIPgetVars(
scip);
435 SCIP_CALL_ABORT( SCIPcreateConsVarbound(
scip, &cons,
437 TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE) );
438 SCIP_CALL_ABORT( SCIPaddCons(
scip, cons) );
439 SCIPdebug( SCIP_CALL_ABORT( SCIPprintCons(
scip, cons, NULL) ) );
440 SCIP_CALL_ABORT( SCIPreleaseCons(
scip, &cons) );
460 SCIP_VAR **vars = SCIPgetVarsBounddisjunction (
scip, cons );
461 SCIP_BOUNDTYPE *boundTypes = SCIPgetBoundtypesBounddisjunction(
scip, cons );
462 SCIP_Real *bounds = SCIPgetBoundsBounddisjunction(
scip, cons );
477 SCIP_VAR **vars = SCIPgetVars(
scip);
489 SCIP_CALL_ABORT( SCIPcreateConsBounddisjunction(
scip, &cons,
492 TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE) );
493 SCIP_CALL_ABORT( SCIPaddCons(
scip, cons) );
494 SCIPdebug( SCIP_CALL_ABORT( SCIPprintCons(
scip, cons, NULL) ) );
495 SCIP_CALL_ABORT( SCIPreleaseCons(
scip, &cons) );
511 int nvars = SCIPgetNVarsSOS1(
scip, cons);
515 SCIP_Real *weights = SCIPgetWeightsSOS1(
scip, cons);
516 SCIP_VAR **vars = SCIPgetVarsSOS1(
scip,cons);
517 for(
int v = 0; v < nvars; v++ )
531 SCIP_VAR **vars = SCIPgetVars(
scip);
535 SCIP_VAR **varsInCons =
new SCIP_VAR*[
nSos1Coefs[c]];
540 SCIP_CALL_ABORT( SCIPcreateConsSOS1(
scip, &cons,
542 TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE ) );
543 SCIP_CALL_ABORT( SCIPaddCons(
scip, cons) );
544 SCIPdebug( SCIP_CALL_ABORT( SCIPprintCons(
scip, cons, NULL) ) );
545 SCIP_CALL_ABORT( SCIPreleaseCons(
scip, &cons) );
546 delete [] varsInCons;
560 int nvars = SCIPgetNVarsSOS2(
scip, cons);
564 SCIP_Real *weights = SCIPgetWeightsSOS2(
scip, cons);
565 SCIP_VAR **vars = SCIPgetVarsSOS2(
scip,cons);
566 for(
int v = 0; v < nvars; v++ )
580 SCIP_VAR **vars = SCIPgetVars(
scip);
584 SCIP_VAR **varsInCons =
new SCIP_VAR*[
nSos2Coefs[c]];
589 SCIP_CALL_ABORT( SCIPcreateConsSOS2(
scip, &cons,
591 TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE ) );
592 SCIP_CALL_ABORT( SCIPaddCons(
scip, cons) );
593 SCIPdebug( SCIP_CALL_ABORT( SCIPprintCons(
scip, cons, NULL) ) );
594 SCIP_CALL_ABORT( SCIPreleaseCons(
scip, &cons) );
595 delete [] varsInCons;
609 SCIP_Bool transformed
615 assert(
scip != NULL );
616 assert( vars != NULL );
617 assert( scalars != NULL );
618 assert( nvars != NULL );
619 assert( constant != NULL );
623 SCIP_CALL_ABORT( SCIPgetProbvarLinearSum(
scip, vars, scalars, nvars, *nvars, constant, &requiredsize, TRUE) );
625 if( requiredsize > *nvars )
627 *nvars = requiredsize;
628 SCIP_CALL_ABORT( SCIPreallocBufferArray(
scip, &vars, *nvars ) );
629 SCIP_CALL_ABORT( SCIPreallocBufferArray(
scip, &scalars, *nvars ) );
631 SCIP_CALL_ABORT( SCIPgetProbvarLinearSum(
scip, vars, scalars, nvars, *nvars, constant, &requiredsize, TRUE) );
632 assert( requiredsize <= *nvars );
637 for( v = 0; v < *nvars; ++v )
638 SCIP_CALL_ABORT( SCIPvarGetOrigvarSum(&vars[v], &scalars[v], constant) );
650 int* nAggregatedVars,
651 SCIP_VAR*** aggregatedVars,
652 SCIP_HASHTABLE** varAggregated
658 for (j = 0; j < nvars; ++j)
660 SCIP_VARSTATUS status;
664 status = SCIPvarGetStatus(var);
667 if( status >= SCIP_VARSTATUS_AGGREGATED )
669 assert( status == SCIP_VARSTATUS_AGGREGATED ||
670 status == SCIP_VARSTATUS_MULTAGGR ||
671 status == SCIP_VARSTATUS_NEGATED );
673 if ( ! SCIPhashtableExists(*varAggregated, (
void*) var) )
675 (*aggregatedVars)[(*nAggregatedVars)++] = var;
676 SCIP_CALL_ABORT( SCIPhashtableInsert(*varAggregated, (
void*) var) );
686 const char* constName,
704 for(v = 0; v < nvars - 1; ++v)
719 SCIP_VAR** aggregatedVars
722 SCIP_VAR** activevars;
723 SCIP_Real* activevals;
725 SCIP_Real activeconstant = 0.0;
728 assert(
scip != NULL );
731 SCIP_CALL_ABORT( SCIPallocBufferArray(
scip, &activevars, nvars) );
732 SCIP_CALL_ABORT( SCIPallocBufferArray(
scip, &activevals, nvars) );
737 for(
int j = 0; j < nAggregatedVars; j++ )
740 (void) SCIPsnprintf(consname,
UG::LpMaxNamelen,
"aggr_%s", SCIPvarGetName(aggregatedVars[j]));
744 if( nAggregatedVars )
755 for (
int j = 0; j < nAggregatedVars; ++j)
760 activevars[0] = aggregatedVars[j];
762 activeconstant = 0.0;
767 activevals[nactivevars] = -1.0;
768 activevars[nactivevars] = aggregatedVars[j];
772 (void) SCIPsnprintf(consname,
UG::LpMaxNamelen,
"aggr_%s", SCIPvarGetName(aggregatedVars[j]));
778 SCIPfreeBufferArray(
scip, &activevars);
779 SCIPfreeBufferArray(
scip, &activevals);
787 SCIP_VAR **vars = SCIPgetVars(
scip);
800 TRUE, FALSE, NULL, NULL, NULL, NULL, NULL) );
801 SCIP_CALL_ABORT( SCIPaddVar(
scip, newvar) );
805 varsInCons[v] = newvar;
806 assert( SCIPvarGetProbindex(newvar) == (
nVars + c) );
807 SCIP_CALL_ABORT( SCIPreleaseVar(
scip, &newvar) );
809 SCIP_CALL_ABORT( SCIPcreateConsLinear(
scip, &cons,
811 TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE) );
812 SCIP_CALL_ABORT( SCIPaddCons(
scip, cons) );
813 SCIPdebug( SCIP_CALL_ABORT( SCIPprintCons(
scip, cons, NULL) ) );
814 SCIP_CALL_ABORT( SCIPreleaseCons(
scip, &cons) );
815 delete [] varsInCons;
823 ) : orgScip(0), paraInstanceScip(0), lProbName(0), probName(0), nCopies(0), origObjSense(0), objScale(0.0), objOffset(0.0), nVars(0), varIndexRange(0),
824 varLbs(0), varUbs(0), objCoefs(0), varTypes(0), lVarNames(0), varNames(0),
825 posVarNames(0), mapToOriginalIndecies(0), mapToSolverLocalIndecies(0),
826 nConss(0), lConsNames(0), consNames(0),
827 posConsNames(0), copyIncreasedVariables(false),
828 nLinearConss(0), idxLinearConsNames(0), linearLhss(0),
829 linearRhss(0), nLinearCoefs(0), linearCoefs(0), idxLinearCoefsVars(0),
830 nSetppcConss(0), idxSetppcConsNames(0), nIdxSetppcVars(0), setppcTypes(0),
831 idxSetppcVars(0), nLogicorConss(0), idxLogicorConsNames(0), nIdxLogicorVars(0), idxLogicorVars(0),
832 nKnapsackConss(0), idxKnapsackConsNames(0), capacities(0), nLKnapsackCoefs(0),
833 knapsackCoefs(0), idxKnapsackCoefsVars(0),
834 nVarboundConss(0), idxVarboundConsNames(0), varboundLhss(0),varboundRhss(0), idxVarboundCoefVar1s(0),
835 varboundCoef2s(0), idxVarboundCoefVar2s(0),
836 nVarBoundDisjunctionConss(0), idxBoundDisjunctionConsNames(0), nVarsBoundDisjunction(0),
837 idxVarBoundDisjunction(0), boundTypesBoundDisjunction(0), boundsBoundDisjunction(0),
838 nSos1Conss(0),idxSos1ConsNames(0), nSos1Coefs(0), sos1Coefs(0), idxSos1CoefsVars(0),
839 nSos2Conss(0), idxSos2ConsNames(0), nSos2Coefs(0), sos2Coefs(0), idxSos2CoefsVars(0),
840 nAggregatedConss(0), lAggregatedVarNames(0), aggregatedVarNames(0), posAggregatedVarNames(0),
841 lAggregatedConsNames(0), aggregatedConsNames(0), posAggregatedConsNames(0),
842 aggregatedLhsAndLhss(0), nAggregatedCoefs(0), aggregatedCoefs(0), idxAggregatedCoefsVars(0),
845 assert(
scip != NULL );
846 assert( SCIPgetStage(
scip) == SCIP_STAGE_TRANSFORMED ||
847 SCIPgetStage(
scip) == SCIP_STAGE_PRESOLVED ||
848 SCIPgetStage(
scip) == SCIP_STAGE_SOLVING ||
849 SCIPgetStage(
scip) == SCIP_STAGE_SOLVED );
866 if( SCIPgetStage(
scip) == SCIP_STAGE_TRANSFORMED || SCIPgetStage(
scip) == SCIP_STAGE_SOLVED )
return;
878 SCIP_VAR **vars = SCIPgetVars(
scip);
886 for(
int v = 0; v <
nVars; ++v)
889 objCoefs[v] = SCIPvarGetObj(vars[v]);
890 assert(SCIPvarGetProbindex(vars[v])!=-1);
891 assert(SCIPvarGetProbindex(vars[v]) == v);
892 lVarNames += strlen(SCIPvarGetName(vars[v])) + 1;
898 for(
int v = 0; v <
nVars; ++v )
900 SCIP_VAR *var = vars[v];
902 varLbs[SCIPvarGetProbindex(var)] = SCIPvarGetLbLocal(var);
903 varUbs[SCIPvarGetProbindex(var)] = SCIPvarGetUbLocal(var);
904 varTypes[SCIPvarGetProbindex(var)] = SCIPvarGetType(var);
916 SCIP_CONS **conss = SCIPgetConss(
scip);
922 int tempSizeConsNames = 0;
924 for(
int c = 0; c <
nConss; c++ )
926 tempSizeConsNames += strlen(SCIPconsGetName(conss[c])) + 1;
928 if( tempSizeConsNames > 0 )
933 SCIP_CONS** consSOS1;
934 SCIP_CONS** consSOS2;
939 SCIP_CALL_ABORT( SCIPallocBufferArray(
scip, &consSOS1,
nConss) );
940 SCIP_CALL_ABORT( SCIPallocBufferArray(
scip, &consSOS2,
nConss) );
943 const char* conshdlrname;
944 SCIP_CONSHDLR* conshdlr;
946 int nNotInitialActiveConss = 0;
949 for (
int c = 0; c <
nConss; ++c)
952 assert( cons != NULL);
955 if( !SCIPconsIsEnabled(cons) )
958 conshdlr = SCIPconsGetHdlr(cons);
959 assert( conshdlr != NULL );
961 if( SCIPconshdlrGetStartNActiveConss(conshdlr) > 0 )
963 conshdlrname = SCIPconshdlrGetName(conshdlr);
964 assert( SCIPconsIsTransformed(cons) );
966 if( strcmp(conshdlrname,
"linear") == 0 )
970 else if( strcmp(conshdlrname,
"setppc") == 0 )
974 else if ( strcmp(conshdlrname,
"logicor") == 0 )
978 else if ( strcmp(conshdlrname,
"knapsack") == 0 )
982 else if ( strcmp(conshdlrname,
"varbound") == 0 )
986 else if ( strcmp(conshdlrname,
"bounddisjunction") == 0 )
990 else if ( strcmp(conshdlrname,
"SOS1") == 0 )
994 else if ( strcmp(conshdlrname,
"SOS2") == 0 )
1000 THROW_LOGICAL_ERROR3(
"constraint handler <", conshdlrname,
"> can not print requested format");
1005 nNotInitialActiveConss++;
1022 nNotInitialActiveConss = 0;
1026 for (
int c = 0; c <
nConss; ++c)
1031 if( !SCIPconsIsEnabled(cons) )
1034 conshdlr = SCIPconsGetHdlr(cons);
1036 if( SCIPconshdlrGetStartNActiveConss(conshdlr) > 0 )
1038 conshdlrname = SCIPconshdlrGetName(conshdlr);
1040 if( strcmp(conshdlrname,
"linear") == 0 )
1044 else if( strcmp(conshdlrname,
"setppc") == 0 )
1048 else if ( strcmp(conshdlrname,
"logicor") == 0 )
1052 else if ( strcmp(conshdlrname,
"knapsack") == 0 )
1056 else if ( strcmp(conshdlrname,
"varbound") == 0 )
1060 else if ( strcmp(conshdlrname,
"bounddisjunction") == 0 )
1064 else if ( strcmp(conshdlrname,
"SOS1") == 0 )
1068 else if ( strcmp(conshdlrname,
"SOS2") == 0 )
1075 nNotInitialActiveConss++;
1081 SCIP_VAR** aggregatedVars;
1082 int nAggregatedVars = 0;
1083 SCIP_HASHTABLE* varAggregated;
1086 SCIP_CALL_ABORT( SCIPallocBufferArray(
scip, &aggregatedVars,
nVars) );
1087 SCIP_CALL_ABORT( SCIPhashtableCreate(&varAggregated, SCIPblkmem(
scip), 1000, hashGetKeyVar, hashKeyEqVar, hashKeyValVar,
1094 SCIP_VAR **consvars = SCIPgetVarsSOS1(
scip, cons);
1095 int nconsvars = SCIPgetNVarsSOS1(
scip, cons);
1104 SCIP_VAR **consvars = SCIPgetVarsSOS2(
scip, cons);
1105 int nconsvars = SCIPgetNVarsSOS2(
scip, cons);
1114 SCIPfreeBufferArray(
scip, &aggregatedVars);
1115 SCIPhashtableFree(&varAggregated);
1118 SCIPfreeBufferArray(
scip, &consSOS1);
1119 SCIPfreeBufferArray(
scip, &consSOS2);
1288 SCIP_Longint originalLimitsNodes;
1289 SCIP_CALL_ABORT( SCIPgetLongintParam(tempScip,
"limits/nodes", &originalLimitsNodes) );
1290 SCIP_CALL_ABORT( SCIPsetLongintParam(tempScip,
"limits/nodes", 1) );
1292 SCIP_RETCODE ret = SCIPsolve(tempScip);
1293 if( ret != SCIP_OKAY )
1298 SCIP_STATUS status = SCIPgetStatus(tempScip);
1299 if( status == SCIP_STATUS_OPTIMAL )
1305 if( status == SCIP_STATUS_MEMLIMIT )
1307 std::cout <<
"Warning: SCIP was interrupted because the memory limit was reached" << std::endl;
1317 cuts = SCIPgetPoolCuts(tempScip);
1318 ncuts = SCIPgetNPoolCuts(tempScip);
1319 for(
int c = 0; c < ncuts; ++c )
1323 row = SCIPcutGetRow(cuts[c]);
1324 assert(!SCIProwIsLocal(row));
1325 assert(!SCIProwIsModifiable(row));
1326 if( SCIPcutGetAge(cuts[c]) == 0 && SCIProwIsInLP(row) )
1328 char name[SCIP_MAXSTRLEN];
1336 cols = SCIProwGetCols(row);
1337 ncols = SCIProwGetNNonz(row);
1339 SCIP_CALL_ABORT( SCIPallocBufferArray(tempScip, &vars, ncols) );
1340 for( i = 0; i < ncols; ++i )
1341 vars[i] = SCIPcolGetVar(cols[i]);
1343 (void) SCIPsnprintf(name, SCIP_MAXSTRLEN,
"%s_%d", SCIProwGetName(row), SCIPgetNRuns(tempScip));
1344 SCIP_CALL_ABORT( SCIPcreateConsLinear(tempScip, &cons, name, ncols, vars, SCIProwGetVals(row),
1345 SCIProwGetLhs(row) - SCIProwGetConstant(row), SCIProwGetRhs(row) - SCIProwGetConstant(row),
1346 TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, TRUE, FALSE) );
1347 SCIP_CALL_ABORT( SCIPaddCons(tempScip, cons) );
1348 SCIP_CALL_ABORT( SCIPreleaseCons(tempScip, &cons) );
1350 SCIPfreeBufferArray(tempScip, &vars);
1355 SCIP_CALL_ABORT( SCIPsetLongintParam(tempScip,
"limits/nodes", originalLimitsNodes) );
1364 bool noPreprocessingInLC,
1365 bool usetRootNodeCuts,
1368 char *settingsNameLC,
1377 SCIP_CALL_ABORT( SCIPcreateProb(
scip,
probName, NULL, NULL, NULL, NULL, NULL, NULL, NULL) );
1378 SCIP_CALL_ABORT( SCIPsetObjsense(
scip, SCIP_OBJSENSE_MINIMIZE) );
1379 for(
int v = 0; v <
nVars; ++v)
1386 TRUE, FALSE, NULL, NULL, NULL, NULL, NULL) );
1387 SCIP_CALL_ABORT( SCIPaddVar(
scip, newvar) );
1388 assert( SCIPvarGetProbindex(newvar) == v );
1392 SCIP_CALL_ABORT( SCIPreleaseVar(
scip, &newvar) );
1421 SCIP_VAR **vars = SCIPgetVars(
scip);
1424 for(
int v = 0; v <
nVars; ++v )
1426 SCIP_VAR *var = vars[v];
1427 varLbs[SCIPvarGetProbindex(var)] = SCIPvarGetLbLocal(var);
1428 varUbs[SCIPvarGetProbindex(var)] = SCIPvarGetUbLocal(var);
1435 SCIP_Bool success = TRUE;
1436 SCIP_CALL_ABORT( SCIPcreate(&tempScip) );
1437 SCIP_CALL_ABORT( SCIPsetIntParam(tempScip,
"timing/clocktype", 2) );
1440 SCIP_CALL_ABORT( SCIPincludeDefaultPlugins(tempScip) );
1444#ifdef SCIP_THREADSAFE_MESSAGEHDLRS
1445 SCIPsetMessagehdlrQuiet(tempScip, TRUE);
1451 int retcode = SCIPreadProb(tempScip,
getFileName(), NULL );
1453 if( retcode != SCIP_OKAY )
1455 std::cout <<
"SCIPreadProb returns: " << retcode << std::endl;
1459 std::cout <<
"Cannot read < " << getcwd(dir, 511) <<
"/" <<
getFileName() << std::endl;
1463 std::cout <<
"Cannot read < " <<
getFileName() << std::endl;
1471 SCIP_CALL_ABORT( SCIPtransformProb(tempScip));
1475 SCIP_CALL_ABORT( SCIPreadProb(tempScip, isolname, NULL ) );
1479 char *probNameFromFileName;
1482 SCIPsplitFilename(temp, NULL, &probNameFromFileName, NULL, NULL);
1483 SCIP_CALL_ABORT( SCIPsetProbName(tempScip, probNameFromFileName));
1486 if( noPreprocessingInLC )
1488 SCIP_CALL_ABORT( SCIPsetIntParam(tempScip,
"presolving/maxrounds", 0));
1492 if( settingsNameLC )
1494 SCIP_CALL_ABORT( SCIPreadParams(tempScip, settingsNameLC) );
1505 SCIP_CALL_ABORT( SCIPpresolve(tempScip) );
1506 SCIP_STATUS scipStatus = SCIPgetStatus(tempScip);
1507 if( scipStatus == SCIP_STATUS_OPTIMAL )
return;
1510 if( usetRootNodeCuts )
1518 if( SCIPgetNVars(tempScip) == 0 )
1523 assert( SCIPgetStage(
scip) == SCIP_STAGE_INIT );
1527 SCIP_HASHMAP* varmap = 0;
1528 SCIP_HASHMAP* conssmap = 0;
1543 #if SCIP_VERSION == 211 && SCIP_SUBVERSION == 0
1544 SCIP_CALL_ABORT( SCIPcopyPlugins(tempScip,
scip, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE,
1545 TRUE, TRUE, TRUE, TRUE, &success) );
1547 #if SCIP_APIVERSION >= 100
1548 #if SCIP_APIVERSION >= 101
1549 SCIP_CALL_ABORT( SCIPcopyPlugins(tempScip,
scip, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE,
1550 TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, &success) );
1552 SCIP_CALL_ABORT( SCIPcopyPlugins(tempScip,
scip, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE,
1553 TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, &success) );
1555 #elif SCIP_APIVERSION >= 17
1556 SCIP_CALL_ABORT( SCIPcopyPlugins(tempScip,
scip, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE,
1557 TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, &success) );
1559 SCIP_CALL_ABORT( SCIPcopyPlugins(tempScip,
scip, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE,
1560 TRUE, TRUE, TRUE, TRUE, FALSE, &success) );
1563 SCIP_CALL_ABORT( SCIPcopyParamSettings(tempScip,
scip) );
1566 if( SCIPgetNVars(tempScip) > 0 )
1568 SCIP_CALL_ABORT( SCIPhashmapCreate(&varmap, SCIPblkmem(
scip), SCIPgetNVars(tempScip)) );
1570 if( SCIPgetNConss(tempScip) > 0 )
1572 SCIP_CALL_ABORT( SCIPhashmapCreate(&conssmap, SCIPblkmem(
scip), SCIPgetNConss(tempScip)) );
1576 SCIP_CALL_ABORT( SCIPcopyProb(tempScip,
scip, varmap, conssmap, TRUE, probNameFromFileName) );
1580 if( SCIPgetNVars(tempScip) > 0 )
1582#if (SCIP_VERSION < 321 || ( SCIP_VERSION == 321 && SCIP_SUBVERSION < 2) )
1583 SCIP_CALL_ABORT( SCIPcopyVars(tempScip,
scip, varmap, conssmap, TRUE) );
1585 SCIP_CALL_ABORT( SCIPcopyVars(tempScip,
scip, varmap, conssmap, NULL, NULL, 0, TRUE) );
1588 if( SCIPgetNConss(tempScip) > 0 )
1590 SCIP_CALL_ABORT( SCIPcopyConss(tempScip,
scip, varmap, conssmap, TRUE, FALSE, &success) );
1593#if SCIP_APIVERSION > 39
1599 SCIP_CALL_ABORT( SCIPcopyBenders(tempScip,
scip, NULL, TRUE, &valid) );
1605 if( SCIPgetNConss(tempScip) > 0 )
1607 SCIPhashmapFree(&conssmap);
1609 if( SCIPgetNVars(tempScip) > 0 )
1611 SCIPhashmapFree(&varmap);
1613 SCIPfree(&tempScip);
1614 std::cerr <<
"Some constraint handler did not perform a valid copy. Cannot solve this instance." << std::endl;
1619 nVars = SCIPgetNVars(tempScip);
1621 int n = SCIPgetNVars(
scip);
1625 assert(
nVars <= n );
1634 for(
int i = 0; i < SCIPgetNTotalVars(tempScip); i++ )
1641 assert(SCIPgetNTotalVars(
scip) >= SCIPgetNVars(tempScip));
1644 SCIP_VAR **srcVars = SCIPgetVars(tempScip);
1647 for(
int i = 0; i < SCIPgetNVars(tempScip); i++ )
1649 SCIP_VAR* copyvar = (SCIP_VAR*)SCIPhashmapGetImage(varmap, (
void*)srcVars[i]);
1673 if( SCIPgetNConss(tempScip) > 0 )
1675 SCIPhashmapFree(&conssmap);
1677 if( SCIPgetNVars(tempScip) > 0 )
1679 SCIPhashmapFree(&varmap);
1682 SCIPfree(&tempScip);
1685 SCIP_VAR **vars = SCIPgetVars(
scip);
1688 for(
int v = 0; v <
nVars; ++v )
1690 SCIP_VAR *var = vars[v];
1691 varLbs[SCIPvarGetProbindex(var)] = SCIPvarGetLbLocal(var);
1692 varUbs[SCIPvarGetProbindex(var)] = SCIPvarGetUbLocal(var);
1852 std::ostringstream s;
1854 s <<
"lProbName = " <<
lProbName << std::endl;
1855 s <<
"probName = " <<
probName << std::endl;
1857 s <<
"objScale = " <<
objScale << std::endl;
1858 s <<
"objOffset = " <<
objOffset << std::endl;
1859 s <<
"nVars = " <<
nVars <<
", lVarNames = " <<
lVarNames << std::endl;
1860 for(
int i = 0; i <
nVars; i++ )
1863 <<
", varsLbs = " <<
varLbs[i] <<
", varsUbs = " <<
varUbs[i]
1875 s <<
"nConss = " <<
nConss <<
", lConsNames = " <<
lConsNames << std::endl;
1876 for(
int i = 0; i <
nConss; i ++ )
1889 <<
", nLinearCoefs = " <<
nLinearCoefs[i] << std::endl;
1892 s <<
" [" << j <<
"]: linearCoefs = " <<
linearCoefs[i][j]
1907 s <<
" [" << j <<
"]: idxSetppcVars = " <<
idxSetppcVars[i][j] << std::endl;
1921 s <<
" [" << j <<
"]: idxLogicorVars = " <<
idxLogicorVars[i][j] << std::endl;
1954 s <<
"nSos1Conss = " <<
nSos1Conss << std::endl;
1958 <<
", nSos1Coefs = " <<
nSos1Coefs[i] << std::endl;
1961 s <<
" [" << j <<
"]: sos1Coefs = " <<
sos1Coefs[i][j] <<
", idxSos1CoefsVars = " <<
idxSos1CoefsVars[i][j] << std::endl;
1968 s <<
"nSos2Conss = " <<
nSos2Conss << std::endl;
1972 <<
", nSos2Coefs = " <<
nSos2Coefs[i] << std::endl;
1975 s <<
" [" << j <<
"]: sos2Coefs = " <<
sos2Coefs[i][j] <<
", idxSos2CoefsVars = " <<
idxSos2CoefsVars[i][j] << std::endl;
Base class for instance data.
void setParametersInScip(SCIP *scip)
int * nVarsBoundDisjunction
SCIP_Real * varboundCoef2s
int ** idxAggregatedCoefsVars
const std::string toString()
int * idxBoundDisjunctionConsNames
void setLinearConstraint(SCIP *scip, int c, SCIP_CONS *cons)
bool addRootNodeCuts(SCIP *scip, ScipDiffParamSet *scipDiffParamSetRoot)
SCIP_Longint ** knapsackCoefs
void setSos2Constraint(SCIP *scip, int c, SCIP_CONS *cons, SCIP_CONS **consSOS2)
void setAggregatedConstrains(SCIP *scip, int nvars, int nAggregatedVars, SCIP_VAR **aggregatedVars)
char * aggregatedConsNames
void createVarboundConstraintsInSCIP(SCIP *scip)
int ** idxLinearCoefsVars
int * mapToSolverLocalIndecies
void setAggregatedConstraint(SCIP *scip, int c, const char *constName, SCIP_VAR **vars, SCIP_Real *vals, int nvars, SCIP_Real lhsAndrhs)
void setSos1Constraint(SCIP *scip, int c, SCIP_CONS *cons, SCIP_CONS **consSOS1)
int * posAggregatedVarNames
virtual const char * getFileName()=0
void createSetppcConstraintsInSCIP(SCIP *scip)
int * idxLogicorConsNames
int * idxKnapsackConsNames
void createLinearConstraintsInSCIP(SCIP *scip)
void addOrdinaryConstraintName(int c, SCIP_CONS *cons)
SCIP_BOUNDTYPE ** boundTypesBoundDisjunction
SCIP_Real ** boundsBoundDisjunction
void setSetppcConstraint(SCIP *scip, int c, SCIP_CONS *cons)
ScipUserPlugins * userPlugins
void getActiveVariables(SCIP *scip, SCIP_VAR **vars, SCIP_Real *scalars, int *nvars, SCIP_Real *constant, SCIP_Bool transformed)
void collectAggregatedVars(SCIP *scip, int nvars, SCIP_VAR **vars, int *nAggregatedVars, SCIP_VAR ***aggregatedVars, SCIP_HASHTABLE **varAggregated)
void createSos1ConstraintsInSCIP(SCIP *scip)
bool copyIncreasedVariables
void allocateMemoryForOrdinaryConstraints()
void setKnapsackConstraint(SCIP *scip, int c, SCIP_CONS *cons)
void setBoundDisjunctionConstraint(SCIP *scip, int c, SCIP_CONS *cons)
int * posAggregatedConsNames
void createSos2ConstraintsInSCIP(SCIP *scip)
int * idxVarboundConsNames
void createBoundDisjunctionConstraintInSCIP(SCIP *scip)
void setVarboundConstraint(SCIP *scip, int c, SCIP_CONS *cons)
int * idxVarboundCoefVar1s
int ** idxKnapsackCoefsVars
char * aggregatedVarNames
int nVarBoundDisjunctionConss
void setLogicorConstraint(SCIP *scip, int c, SCIP_CONS *cons)
int * mapToOriginalIndecies
SCIP_Longint * capacities
SCIP_Real * aggregatedLhsAndLhss
void createProblem(SCIP *scip, int method, bool noPreprocessingInLC, bool usetRootNodeCuts, ScipDiffParamSet *scipDiffParamSetRoot, ScipDiffParamSet *scipDiffParamSet, char *settingsNameLC, char *isolname)
int ** idxVarBoundDisjunction
int * idxVarboundCoefVar2s
void createLogicorConstraintsInSCIP(SCIP *scip)
void createKnapsackConstraintsInSCIP(SCIP *scip)
void createAggregatedVarsAndConstrainsInSCIP(SCIP *scip)
virtual ~ScipParaInstance()
void includeUserPlugins(SCIP *inScip)
SCIP_Real ** aggregatedCoefs
static const int LpMaxNamelen
Defines for UG Framework.
#define THROW_LOGICAL_ERROR1(msg1)
#define THROW_LOGICAL_ERROR2(msg1, msg2)
#define THROW_LOGICAL_ERROR3(msg1, msg2, msg3)
static SCIP_DECL_HASHGETKEY(hashGetKeyVar)
static const char * PRESOLVED_INSTANCE
static SCIP_DECL_HASHKEYEQ(hashKeyEqVar)
static SCIP_DECL_HASHKEYVAL(hashKeyValVar)
ParaInstance extenstion for SCIP solver.