59 #define RELAX_NAME "SDP"
60 #define RELAX_DESC "SDP-relaxator"
61 #define RELAX_PRIORITY 1
66 #define DEFAULT_SDPSOLVEREPSILON 1e-4
67 #define DEFAULT_SDPSOLVERFEASTOL 1e-6
68 #define DEFAULT_PENALTYPARAM -1.0
69 #define DEFAULT_LAMBDASTAR -1.0
70 #define DEFAULT_MAXPENALTYPARAM -1.0
71 #define DEFAULT_SLATERCHECK 0
72 #define DEFAULT_OBJLIMIT FALSE
73 #define DEFAULT_RESOLVE TRUE
74 #define DEFAULT_TIGHTENVB FALSE
75 #define DEFAULT_SDPINFO FALSE
76 #define DEFAULT_DISPLAYSTAT TRUE
77 #define DEFAULT_SETTINGSRESETFREQ -1
78 #define DEFAULT_SETTINGSRESETOFS 0
91 SCIP_Bool probingsolved;
92 SCIP_Real sdpsolverepsilon;
93 SCIP_Real sdpsolverfeastol;
94 SCIP_Real penaltyparam;
95 SCIP_Real maxpenaltyparam;
105 SCIP_Bool displaystat;
109 int settingsresetfreq;
110 int settingsresetofs;
112 int sdpinterfacecalls;
113 long int lastsdpnode;
121 int unstablenoslater;
124 int unsolvednoslater;
127 int nslatercheckfailed;
131 int npslatercheckfailed;
134 int ndslatercheckfailed;
135 int nslaterinfeasible;
136 int stableinfeasible;
137 int unstableinfeasible;
138 int penaltyinfeasible;
139 int boundedinfeasible;
140 int unsolvedinfeasible;
151 SCIP_CONSHDLR* conshdlr;
152 const char* conshdlrname;
154 SCIP_VAR** blockvars;
157 SCIP_Real** constval;
170 int* nconstblocknonz;
171 int constnnonzcounter;
183 SCIP_CALL( SCIPgetRealParam(scip,
"relaxing/SDP/sdpsolverepsilon", ¶m) );
185 SCIPdebugMessage(
"Putting SDP Data in general SDP interface!\n");
187 assert( scip != NULL );
188 assert( sdpi != NULL );
189 assert( varmapper != NULL );
191 vars = SCIPgetVars(scip);
192 nvars = SCIPgetNVars(scip);
195 SCIP_CALL( SCIPallocBufferArray(scip, &obj, nvars) );
196 SCIP_CALL( SCIPallocBufferArray(scip, &lb, nvars) );
197 SCIP_CALL( SCIPallocBufferArray(scip, &ub, nvars) );
199 for (i = 0; i < nvars; i++)
201 obj[i] = SCIPvarGetObj(vars[i]);
202 lb[i] = SCIPvarGetLbLocal(vars[i]);
203 ub[i] = SCIPvarGetUbLocal(vars[i]);
206 nconss = SCIPgetNConss(scip);
207 conss = SCIPgetConss(scip);
214 for (i = 0; i < nconss; i++)
216 conshdlr = SCIPconsGetHdlr(conss[i]);
217 assert( conshdlr != NULL );
219 conshdlrname = SCIPconshdlrGetName(conshdlr);
221 #ifdef SCIP_EVEN_MORE_DEBUG
222 SCIP_CALL( SCIPprintCons(scip, conss[i], NULL) );
223 SCIPinfoMessage(scip, NULL,
"\n");
226 if ( strcmp(conshdlrname,
"SDP") == 0 )
231 sdpnnonz += blocknnonz;
232 sdpconstnnonz += constnnonzcounter;
237 SCIP_CALL( SCIPallocBufferArray(scip, &sdpblocksizes, nsdpblocks) );
238 SCIP_CALL( SCIPallocBufferArray(scip, &nblockvarnonz, nsdpblocks) );
239 SCIP_CALL( SCIPallocBufferArray(scip, &nconstblocknonz, nsdpblocks) );
240 SCIP_CALL( SCIPallocBufferArray(scip, &col, nsdpblocks) );
241 SCIP_CALL( SCIPallocBufferArray(scip, &row, nsdpblocks) );
242 SCIP_CALL( SCIPallocBufferArray(scip, &val, nsdpblocks) );
243 SCIP_CALL( SCIPallocBufferArray(scip, &constcol, nsdpblocks) );
244 SCIP_CALL( SCIPallocBufferArray(scip, &constrow, nsdpblocks) );
245 SCIP_CALL( SCIPallocBufferArray(scip, &constval, nsdpblocks) );
246 SCIP_CALL( SCIPallocBufferArray(scip, &nblockvars, nsdpblocks) );
247 SCIP_CALL( SCIPallocBufferArray(scip, &sdpvar, nsdpblocks) );
249 for (i = 0; i < nsdpblocks; i++)
251 SCIP_CALL( SCIPallocBufferArray(scip, &(nblockvarnonz[i]), nvars) );
252 SCIP_CALL( SCIPallocBufferArray(scip, &col[i], nvars) );
253 SCIP_CALL( SCIPallocBufferArray(scip, &row[i], nvars) );
254 SCIP_CALL( SCIPallocBufferArray(scip, &val[i], nvars) );
259 SCIP_CALL( SCIPallocBufferArray(scip, &blockvars, nvars) );
261 for (i = 0; i < nconss; i++)
263 conshdlr = SCIPconsGetHdlr(conss[i]);
264 assert( conshdlr != NULL );
266 conshdlrname = SCIPconshdlrGetName(conshdlr);
268 if ( strcmp(conshdlrname,
"SDP") == 0 )
270 assert( ind < nsdpblocks );
274 nconstblocknonz[ind] = constlength;
275 SCIP_CALL( SCIPallocBufferArray(scip, &(constcol[ind]), constlength) );
276 SCIP_CALL( SCIPallocBufferArray(scip, &(constrow[ind]), constlength) );
277 SCIP_CALL( SCIPallocBufferArray(scip, &(constval[ind]), constlength) );
280 SCIP_CALL(
SCIPconsSdpGetData(scip, conss[i], &nblockvars[ind], &blocknnonz, &sdpblocksizes[ind], &nvars, nblockvarnonz[ind], col[ind],
281 row[ind], val[ind], blockvars, &nconstblocknonz[ind], constcol[ind], constrow[ind], constval[ind]) );
284 assert( nvars == SCIPgetNVars(scip) );
285 assert( nconstblocknonz[ind] <= constlength );
287 SCIP_CALL( SCIPallocBufferArray(scip, &(sdpvar[ind]), nblockvars[ind]) );
290 for (j = 0; j < nblockvars[ind]; j++)
298 SCIPfreeBufferArray(scip, &blockvars);
301 SCIP_CALL(
SCIPsdpiLoadSDP(sdpi, nvars, obj, lb, ub, nsdpblocks, sdpblocksizes, nblockvars, sdpconstnnonz, nconstblocknonz, constrow,
302 constcol, constval, sdpnnonz, nblockvarnonz, sdpvar, row, col, val, 0,
303 NULL, NULL, 0, NULL, NULL, NULL) );
306 for (i = 0; i < nsdpblocks; i++)
308 SCIPfreeBufferArrayNull(scip, &(sdpvar[i]));
309 SCIPfreeBufferArrayNull(scip, &val[i]);
310 SCIPfreeBufferArrayNull(scip, &row[i]);
311 SCIPfreeBufferArrayNull(scip, &col[i]);
312 SCIPfreeBufferArrayNull(scip, &(nblockvarnonz[i]));
313 SCIPfreeBufferArrayNull(scip, &(constval[i]));
314 SCIPfreeBufferArrayNull(scip, &(constrow[i]));
315 SCIPfreeBufferArrayNull(scip, &(constcol[i]));
318 SCIPfreeBufferArrayNull(scip, &sdpvar);
319 SCIPfreeBufferArrayNull(scip, &nblockvars);
320 SCIPfreeBufferArrayNull(scip, &constval);
321 SCIPfreeBufferArrayNull(scip, &constrow);
322 SCIPfreeBufferArrayNull(scip, &constcol);
323 SCIPfreeBufferArrayNull(scip, &val);
324 SCIPfreeBufferArrayNull(scip, &row);
325 SCIPfreeBufferArrayNull(scip, &col);
326 SCIPfreeBufferArrayNull(scip, &nconstblocknonz);
327 SCIPfreeBufferArrayNull(scip, &nblockvarnonz);
328 SCIPfreeBufferArrayNull(scip, &sdpblocksizes);
329 SCIPfreeBufferArray(scip, &ub);
330 SCIPfreeBufferArray(scip, &lb);
331 SCIPfreeBufferArray(scip, &obj);
371 assert( scip != NULL );
372 assert( sdpi != NULL );
373 assert( varmapper != NULL );
375 nvars = SCIPgetNVars(scip);
378 SCIP_CALL( SCIPgetLPRowsData(scip, &rows, &nrows) );
379 SCIP_CALL( SCIPgetBoolParam(scip,
"relaxing/SDP/tightenvb", &tightenvb) );
381 SCIPdebugMessage(
"inserting %d LPRows into the interface.\n", nrows);
385 for (i = 0; i < nrows; i++)
387 assert( rows[i] != NULL );
388 scipnnonz += SCIProwGetNNonz(rows[i]);
392 SCIP_CALL( SCIPallocBufferArray(scip, &lhs, nrows) );
393 SCIP_CALL( SCIPallocBufferArray(scip, &rhs, nrows) );
394 SCIP_CALL( SCIPallocBufferArray(scip, &rowind, scipnnonz) );
395 SCIP_CALL( SCIPallocBufferArray(scip, &colind, scipnnonz) );
396 SCIP_CALL( SCIPallocBufferArray(scip, &val, scipnnonz) );
402 for (i = 0; i < nrows; i++)
405 SCIP_Bool tightened = FALSE;
406 SCIP_Real tightenedval = 0.0;
407 SCIP_Bool swapped = FALSE;
411 rownnonz = SCIProwGetNNonz(row);
413 rowvals = SCIProwGetVals(row);
414 rowcols = SCIProwGetCols(row);
415 sciplhs = SCIProwGetLhs(row) - SCIProwGetConstant(row);
416 sciprhs = SCIProwGetRhs(row) - SCIProwGetConstant(row);
419 if ( tightenvb && rownnonz == 2 && (SCIPisZero(scip, sciplhs) || SCIPisZero(scip, sciprhs) ) )
429 assert( rowcols[0] != NULL );
430 assert( rowcols[1] != NULL );
431 var1 = SCIPcolGetVar(rowcols[0]);
432 var2 = SCIPcolGetVar(rowcols[1]);
433 assert( var1 != NULL );
434 assert( var2 != NULL );
437 if ( ! SCIPisEQ(scip, SCIPvarGetLbLocal(var1), SCIPvarGetUbLocal(var1)) && ! SCIPisEQ(scip, SCIPvarGetLbLocal(var2), SCIPvarGetUbLocal(var2)) )
440 if ( (SCIPisEQ(scip, val1, 1.0) || SCIPisEQ(scip, val2, 1.0)) && ( SCIPisNegative(scip, val1) || SCIPisNegative(scip, val2) ) )
443 if ( ! SCIPisEQ(scip, val1, 1.0) || ! SCIPisNegative(scip, val2) )
445 SCIPswapPointers((
void**) &var1, (
void**) &var2);
452 if ( SCIPvarIsBinary(var2) )
454 if ( SCIPisZero(scip, sciprhs) )
456 if ( SCIPisLT(scip, SCIPvarGetUbLocal(var1), REALABS(val2)) )
458 SCIPdebugMessage(
"Big-M in %s changed from %f to %f\n", SCIProwGetName(row), REALABS(val2), SCIPvarGetUbLocal(var1));
461 tightenedval = -SCIPvarGetUbLocal(var1);
465 if ( SCIPisZero(scip, sciplhs) )
467 if ( SCIPisGT(scip, SCIPvarGetLbLocal(var1), REALABS(val2)) )
469 SCIPdebugMessage(
"Big-M in %s changed from %f to %f\n", SCIProwGetName(row), REALABS(val2), SCIPvarGetLbLocal(var1));
472 tightenedval = -SCIPvarGetUbLocal(var1);
480 for (j = 0; j < rownnonz; j++)
483 if ( tightened && ( (swapped && (j == 0)) || ((! swapped) && (j == 1)) ) )
485 if ( SCIPisFeasGT(scip, REALABS(tightenedval), 0.0) )
487 assert( SCIPcolGetVar(rowcols[j]) != 0 );
489 rowind[nnonz] = nconss;
490 val[nnonz] = tightenedval;
494 else if ( SCIPisFeasGT(scip, REALABS(rowvals[j]), 0.0))
496 assert( SCIPcolGetVar(rowcols[j]) != 0 );
498 rowind[nnonz] = nconss;
499 val[nnonz] = rowvals[j];
503 lhs[nconss] = sciplhs;
504 rhs[nconss] = sciprhs;
516 SCIP_CALL(
SCIPsdpiAddLPRows(sdpi, nconss, lhs, rhs, nnonz, (
const int*)rowind, (
const int*)colind, val) );
519 SCIPfreeBufferArray(scip, &val);
520 SCIPfreeBufferArray(scip, &colind);
521 SCIPfreeBufferArray(scip, &rowind);
522 SCIPfreeBufferArray(scip, &rhs);
523 SCIPfreeBufferArray(scip, &lhs);
528 vars = SCIPgetVars(scip);
529 assert( vars != NULL );
532 SCIP_CALL( SCIPallocBufferArray(scip, &lb, nvars) );
533 SCIP_CALL( SCIPallocBufferArray(scip, &ub, nvars) );
534 SCIP_CALL( SCIPallocBufferArray(scip, &inds, nvars) );
535 SCIP_CALL( SCIPallocBufferArray(scip, &obj, nvars) );
536 SCIP_CALL( SCIPallocBufferArray(scip, &objinds, nvars) );
539 for (i = 0; i < nvars; i++)
541 assert( vars[i] != NULL );
542 lb[i] = SCIPvarGetLbLocal(vars[i]);
543 ub[i] = SCIPvarGetUbLocal(vars[i]);
545 obj[i] = SCIPvarGetObj(vars[i]);
554 SCIPfreeBufferArray(scip, &objinds);
555 SCIPfreeBufferArray(scip, &obj);
556 SCIPfreeBufferArray(scip, &inds);
557 SCIPfreeBufferArray(scip, &ub);
558 SCIPfreeBufferArray(scip, &lb);
567 SCIP_RELAXDATA* relaxdata,
569 SCIP_Real* lowerbound
572 char saveconsname[SCIP_MAXSTRLEN];
576 SCIP_CONS* savedsetting;
581 SCIP_Bool enforceslater;
583 SCIP_Real objforscip;
584 SCIP_Real* solforscip;
595 SCIPdebugMessage(
"calcRelax called\n");
597 assert( scip != NULL );
598 assert( relaxdata != NULL );
599 assert( result != NULL );
600 assert( lowerbound != NULL );
602 nvars = SCIPgetNVars(scip);
604 vars = SCIPgetVars (scip);
606 sdpi = relaxdata->sdpi;
607 assert( sdpi != NULL );
608 varmapper = relaxdata->varmapper;
609 assert( varmapper != NULL );
611 if ( relaxdata->objlimit )
619 rootnode = ! SCIPnodeGetParent(SCIPgetCurrentNode(scip));
622 if ( rootnode || (SCIPnodeGetDepth(SCIPgetCurrentNode(scip)) == relaxdata->settingsresetofs) ||
623 ( relaxdata->settingsresetfreq > 0 && ((SCIPnodeGetDepth(SCIPgetCurrentNode(scip)) - relaxdata->settingsresetofs) % relaxdata->settingsresetfreq == 0)) )
629 SCIP_CONSHDLR* conshdlr;
633 conshdlr = SCIPfindConshdlr(scip,
"Savedsdpsettings");
634 if ( conshdlr == NULL )
636 SCIPerrorMessage(
"Savedsdpsettings constraint handler not found!\n");
637 return SCIP_PLUGINNOTFOUND;
641 conss = SCIPconshdlrGetConss(conshdlr);
642 lastconsind = SCIPconshdlrGetNConss(conshdlr) - 1;
643 assert ( conss != NULL );
644 assert ( conss[lastconsind] != NULL );
651 SCIP_CALL( SCIPgetRealParam(scip,
"limits/time", &timelimit) );
652 if ( ! SCIPisInfinity(scip, timelimit) )
654 timelimit -= SCIPgetSolvingTime(scip);
655 if ( timelimit <= 0.0 )
657 *result = SCIP_DIDNOTRUN;
664 enforceslater = SCIPisInfinity(scip, -1 * SCIPnodeGetLowerbound(SCIPgetCurrentNode(scip)));
667 SCIP_CALL(
SCIPsdpiSolve(sdpi, NULL, startsetting, enforceslater, timelimit) );
668 relaxdata->lastsdpnode = SCIPnodeGetNumber(SCIPgetCurrentNode(scip));
671 relaxdata->sdpinterfacecalls++;
674 relaxdata->sdpcalls += naddedsdpcalls;
677 relaxdata->sdpiterations += naddediters;
682 switch( usedsetting )
685 relaxdata->solvedpenalty++;
688 relaxdata->solvedfast++;
691 relaxdata->solvedmedium++;
694 relaxdata->solvedstable++;
697 relaxdata->unsolved++;
704 SCIP_CALL(
SCIPsdpiSlater(relaxdata->sdpi, &primalslater, &dualslater) );
705 switch( primalslater )
708 relaxdata->npslatercheckfailed++;
712 relaxdata->ndslatercheckfailed++;
713 relaxdata->nslatercheckfailed++;
716 relaxdata->ndnoslater++;
717 relaxdata->nnoslater++;
720 relaxdata->ndslaterholds++;
721 relaxdata->nslatercheckfailed++;
724 relaxdata->nslaterinfeasible++;
727 relaxdata->ndslatercheckfailed++;
728 relaxdata->nslatercheckfailed++;
733 relaxdata->npnoslater++;
737 relaxdata->ndslatercheckfailed++;
738 relaxdata->nnoslater++;
741 relaxdata->ndnoslater++;
742 relaxdata->nnoslater++;
745 relaxdata->ndslaterholds++;
746 relaxdata->nnoslater++;
749 relaxdata->nslaterinfeasible++;
752 relaxdata->ndslatercheckfailed++;
753 relaxdata->nnoslater++;
758 relaxdata->npslaterholds++;
762 relaxdata->ndslatercheckfailed++;
763 relaxdata->nslatercheckfailed++;
766 relaxdata->ndnoslater++;
767 relaxdata->nnoslater++;
770 relaxdata->ndslaterholds++;
771 relaxdata->nslaterholds++;
774 relaxdata->nslaterinfeasible++;
777 relaxdata->ndslatercheckfailed++;
778 relaxdata->nslatercheckfailed++;
783 relaxdata->npslatercheckfailed++;
784 relaxdata->ndslatercheckfailed++;
785 relaxdata->nslatercheckfailed++;
790 switch( slatersetting )
793 relaxdata->stablewslater++;
796 relaxdata->unstablewslater++;
799 relaxdata->penaltywslater++;
802 relaxdata->boundedwslater++;
805 relaxdata->unsolvedwslater++;
808 relaxdata->stablenoslater++;
811 relaxdata->unstablenoslater++;
814 relaxdata->penaltynoslater++;
817 relaxdata->boundednoslater++;
820 relaxdata->unsolvednoslater++;
823 relaxdata->stableinfeasible++;
826 relaxdata->unstableinfeasible++;
829 relaxdata->penaltyinfeasible++;
832 relaxdata->boundedinfeasible++;
835 relaxdata->unsolvedinfeasible++;
842 (void) SCIPsnprintf(saveconsname, SCIP_MAXSTRLEN,
"savedsettings_node_%d", SCIPnodeGetNumber(SCIPgetCurrentNode(scip)));
844 SCIP_CALL( SCIPaddCons(scip, savedsetting) );
845 SCIP_CALL( SCIPreleaseCons(scip, &savedsetting) );
848 relaxdata->feasible = FALSE;
850 if ( SCIPinProbing(scip) )
858 #ifdef SCIP_MORE_DEBUG
861 SCIP_CALL( SCIPallocBufferArray(scip, &solforscip, nvars) );
863 SCIP_CALL(
SCIPsdpiGetSol(sdpi, &objforscip, solforscip, &sollength) );
865 assert( sollength == nvars );
870 SCIPdebugMessage(
"optimal solution: objective = %f, dual feasible: %d, primal feasible: %d.\n",
875 SCIPdebugMessage(
"The solver could not determine feasibility ! ");
879 for (i = 0; i < nvars; ++i)
881 SCIPdebugMessage(
"<%s> = %f\n", SCIPvarGetName(vars[i]), solforscip[i]);
883 SCIPfreeBufferArray(scip, &solforscip);
889 SCIPdebugMessage(
"Node cut off due to infeasibility.\n");
890 relaxdata->feasible = FALSE;
891 *result = SCIP_CUTOFF;
896 SCIPdebugMessage(
"Node cut off due to objective limit.\n");
897 relaxdata->feasible = FALSE;
898 *result = SCIP_CUTOFF;
903 SCIPdebugMessage(
"Node unbounded.");
904 relaxdata->feasible = TRUE;
905 *result = SCIP_SUCCESS;
906 *lowerbound = -SCIPinfinity(scip);
919 SCIP_CALL( SCIPallocBufferArray(scip, &solforscip, nvars) );
921 SCIP_CALL(
SCIPsdpiGetSol(sdpi, &objforscip, solforscip, &slength) );
923 assert( slength == nvars );
928 for (v = 0; v < nvars; v++)
938 SCIP_CALL( SCIPcreateSol(scip, &scipsol, NULL) );
939 SCIP_CALL( SCIPsetSolVals(scip, scipsol, nvars, vars, solforscip) );
941 *lowerbound = objforscip;
942 relaxdata->objval = objforscip;
946 SCIP_CALL( SCIPcheckSol(scip, scipsol, TRUE, FALSE, FALSE, FALSE, &allfeas) );
950 if ( ! SCIPinProbing(scip) )
952 SCIP_CALL( SCIPtrySol(scip, scipsol, TRUE, FALSE, FALSE, FALSE, &stored) );
955 SCIPdebugMessage(
"feasible solution for MISDP found, cut node off, solution is stored.\n");
959 SCIPdebugMessage(
"feasible solution for MISDP found, cut node off, solution is worse than earlier one.\n");
964 SCIP_CALL( SCIPsetRelaxSolVals(scip, nvars, vars, solforscip) );
965 SCIP_CALL( SCIPmarkRelaxSolValid(scip) );
967 SCIPfreeBufferArray(scip, &solforscip);
968 SCIP_CALL( SCIPfreeSol(scip, &scipsol) );
970 relaxdata->feasible = TRUE;
971 *result = SCIP_CUTOFF;
974 SCIPdebugMessage(
"Found a solution that is feasible for the SDP-solver and integrality, but infeasible for SCIP!\n");
978 SCIP_CALL( SCIPgetLPColsData(scip, &cols, &ncols) );
979 for (i = 0; i < ncols; i++)
981 SCIP_CALL( SCIPsetRelaxSolVal(scip, SCIPcolGetVar(cols[i]), SCIPgetSolVal(scip, scipsol, SCIPcolGetVar(cols[i]))) );
984 SCIP_CALL( SCIPmarkRelaxSolValid(scip) );
985 relaxdata->feasible = TRUE;
986 *result = SCIP_SUCCESS;
991 for (i = 0; i < nvars; ++i)
993 SCIP_VAR* var = vars[i];
994 if ( SCIPvarIsIntegral(var) && ! SCIPisFeasIntegral(scip, solforscip[i]) && ! SCIPisEQ(scip, SCIPvarGetLbLocal(var), SCIPvarGetUbLocal(var)) )
997 SCIP_CALL( SCIPaddExternBranchCand(scip, var, 10000.0, solforscip[i]) );
1002 SCIPfreeBufferArray(scip, &solforscip);
1003 SCIP_CALL( SCIPfreeSol(scip, &scipsol) );
1012 *result = SCIP_DIDNOTRUN;
1018 objlb = -SCIPinfinity(scip);
1020 if ( ! SCIPisInfinity(scip, objlb) )
1022 *lowerbound = objlb;
1023 SCIPdebugMessage(
"The relaxation could not be solved, using best computed bound from penalty formulation.\n");
1025 else if ( ! SCIPisInfinity(scip, -1 * SCIPnodeGetLowerbound(SCIPgetCurrentNode(scip))) )
1027 *lowerbound = SCIPnodeGetLowerbound(SCIPgetCurrentNode(scip));
1028 SCIPdebugMessage(
"The relaxation could not be solved, keeping old bound.\n");
1032 *result = SCIP_SUSPENDED;
1033 SCIPerrorMessage(
"The relaxation of the root node could not be solved, so there is no hope to solve this instance.\n");
1037 *result = SCIP_SUCCESS;
1038 SCIP_CALL( SCIPupdateLocalLowerbound(scip, *lowerbound) );
1054 assert( scip != NULL );
1056 vars = SCIPgetVars(scip);
1059 for (i = 0; i < SCIPgetNVars(scip); i++)
1061 if ( SCIPisFeasLT(scip, SCIPvarGetLbLocal(vars[i]), SCIPvarGetUbLocal(vars[i])) )
1073 SCIP_RELAXDATA* relaxdata;
1082 #ifdef SCIP_EVEN_MORE_DEBUG
1083 SCIP_VAR** varsfordebug = SCIPgetVars(scip);
1084 const int nvarsfordebug = SCIPgetNVars(scip);
1087 SCIPdebugMessage(
"Calling relaxExecSdp.\n");
1089 relaxdata = SCIPrelaxGetData(relax);
1090 vars = SCIPgetVars(scip);
1091 nvars = SCIPgetNVars(scip);
1094 if ( (relaxdata->lastsdpnode == SCIPnodeGetNumber(SCIPgetCurrentNode(scip)) && ( ! SCIPinProbing(scip) ) ) && relaxdata->origsolved && ! relaxdata->resolve )
1097 SCIP_Real objforscip;
1098 SCIP_Real* solforscip;
1102 SCIPdebugMessage(
"Already solved SDP-relaxation for node %ld, returning with SCIP_SUCCESS so that no other relaxator is called.\n",
1103 SCIPrelaxGetData(relax)->lastsdpnode);
1107 relaxdata->feasible = TRUE;
1108 *result = SCIP_SUCCESS;
1109 *lowerbound = -SCIPinfinity(scip);
1114 SCIP_CALL( SCIPallocBufferArray(scip, &solforscip, nvars) );
1116 SCIP_CALL(
SCIPsdpiGetSol(relaxdata->sdpi, &objforscip, solforscip, &slength) );
1118 assert( slength == nvars );
1122 SCIP_CALL( SCIPcreateSol(scip, &scipsol, NULL) );
1123 SCIP_CALL( SCIPsetSolVals(scip, scipsol, nvars, vars, solforscip) );
1125 *lowerbound = objforscip;
1128 SCIP_CALL( SCIPgetLPColsData(scip, &cols, &ncols) );
1129 for (i = 0; i < ncols; i++)
1131 SCIP_CALL( SCIPsetRelaxSolVal(scip, SCIPcolGetVar(cols[i]), SCIPgetSolVal(scip, scipsol, SCIPcolGetVar(cols[i]))) );
1134 SCIP_CALL( SCIPmarkRelaxSolValid(scip) );
1135 *result = SCIP_SUCCESS;
1137 SCIPfreeBufferArray(scip, &solforscip);
1138 SCIP_CALL( SCIPfreeSol(scip, &scipsol) );
1140 *result = SCIP_SUCCESS;
1145 relaxdata->origsolved = FALSE;
1148 SCIP_CALL( SCIPconstructLP(scip, &cutoff) );
1152 relaxdata->feasible = FALSE;
1153 *result = SCIP_CUTOFF;
1158 SCIP_CALL( SCIPflushLP(scip) );
1161 nconss = SCIPgetNConss(scip);
1163 #ifdef SCIP_EVEN_MORE_DEBUG
1164 for (i = 0; i < nvarsfordebug; i++)
1166 SCIPdebugMessage(
"variable %s: status = %u, integral = %u, bounds = [%f, %f] \n", SCIPvarGetName(varsfordebug[i]), SCIPvarGetStatus(varsfordebug[i]),
1167 SCIPvarIsIntegral(varsfordebug[i]), SCIPvarGetLbLocal(varsfordebug[i]), SCIPvarGetUbLocal(varsfordebug[i]));
1174 relaxdata->feasible = TRUE;
1175 *result = SCIP_DIDNOTRUN;
1185 SCIP_CALL( SCIPallocBufferArray(scip, &ubs, nvars) );
1188 for (i = 0; i < nvars; i++)
1190 ubs[i] = SCIPvarGetUbLocal(vars[i]);
1191 *lowerbound += SCIPvarGetObj(vars[i]) * ubs[i];
1192 assert( SCIPisFeasEQ(scip, SCIPvarGetUbLocal(vars[i]), SCIPvarGetLbLocal(vars[i])));
1194 if ( SCIPgetObjsense(scip) == SCIP_OBJSENSE_MAXIMIZE )
1197 SCIPdebugMessage(
"EVERYTHING IS FIXED, objective value = %f\n", *lowerbound);
1199 SCIP_CALL( SCIPcreateSol(scip, &scipsol, NULL) );
1200 SCIP_CALL( SCIPsetSolVals(scip, scipsol, nvars, vars, ubs) );
1203 for (i = 0; i < nvars; i++)
1205 SCIP_CALL( SCIPsetRelaxSolVal(scip, vars[i], SCIPvarGetLbLocal(vars[i])) );
1207 SCIP_CALL( SCIPmarkRelaxSolValid(scip) );
1210 SCIP_CALL( SCIPcheckSol(scip, scipsol, FALSE, TRUE, TRUE, TRUE, &feasible) );
1215 SCIP_CALL( SCIPtrySolFree(scip, &scipsol, FALSE, FALSE, FALSE, FALSE, &stored) );
1219 SCIP_CALL( SCIPfreeSol(scip, &scipsol) );
1222 relaxdata->feasible = feasible;
1224 if ( feasible && stored )
1226 *result = SCIP_CUTOFF;
1227 SCIPdebugMessage(
"New solution was stored, node is cut off!\n");
1231 *result = SCIP_CUTOFF;
1232 SCIPdebugMessage(
"Fixed solution either infeasible or not good enough for storage, node cut off!\n");
1235 SCIPfreeBufferArray(scip, &ubs);
1243 SCIP_CALL(
calcRelax(scip, relaxdata, result, lowerbound));
1254 SCIP_RELAXDATA* relaxdata;
1255 SCIP_RETCODE retcode;
1259 SCIP_Real penaltyparam;
1260 SCIP_Real maxpenaltyparam;
1262 SCIP_Real givenpenaltyparam;
1266 assert( relax != NULL );
1268 relaxdata = SCIPrelaxGetData(relax);
1269 assert( relaxdata != NULL );
1271 relaxdata->objval = 0.0;
1272 relaxdata->origsolved = FALSE;
1273 relaxdata->probingsolved = FALSE;
1274 relaxdata->sdpcalls = 0;
1275 relaxdata->sdpinterfacecalls = 0;
1276 relaxdata->sdpiterations = 0;
1277 relaxdata->solvedfast = 0;
1278 relaxdata->solvedmedium = 0;
1279 relaxdata->solvedstable = 0;
1280 relaxdata->solvedpenalty = 0;
1281 relaxdata->stablewslater = 0;
1282 relaxdata->unstablewslater = 0;
1283 relaxdata->boundedwslater = 0;
1284 relaxdata->unsolvedwslater = 0;
1285 relaxdata->stablenoslater = 0;
1286 relaxdata->unsolvednoslater = 0;
1287 relaxdata->boundednoslater = 0;
1288 relaxdata->unsolvednoslater = 0;
1289 relaxdata->nslaterholds = 0;
1290 relaxdata->nnoslater = 0;
1291 relaxdata->nslatercheckfailed = 0;
1292 relaxdata->npslaterholds = 0;
1293 relaxdata->npnoslater = 0;
1294 relaxdata->npslatercheckfailed = 0;
1295 relaxdata->ndslaterholds = 0;
1296 relaxdata->ndnoslater = 0;
1297 relaxdata->ndslatercheckfailed = 0;
1298 relaxdata->nslaterinfeasible = 0;
1299 relaxdata->stableinfeasible = 0;
1300 relaxdata->unstableinfeasible = 0;
1301 relaxdata->penaltyinfeasible = 0;
1302 relaxdata->boundedinfeasible = 0;
1303 relaxdata->unsolvedinfeasible = 0;
1304 relaxdata->unsolved = 0;
1305 relaxdata->feasible = FALSE;
1307 nvars = SCIPgetNVars(scip);
1308 vars = SCIPgetVars(scip);
1314 if ( SCIPgetNVars(scip) > 0 )
1320 SCIP_CALL( SCIPgetRealParam(scip,
"relaxing/SDP/sdpsolverepsilon", &epsilon) );
1322 if ( retcode == SCIP_PARAMETERUNKNOWN )
1324 SCIPverbMessage(scip, SCIP_VERBLEVEL_FULL, NULL,
1325 "SDP Solver <%s>: epsilon setting not available -- SCIP parameter has no effect.\n",
1330 SCIP_CALL( retcode );
1333 SCIP_CALL( SCIPgetRealParam(scip,
"relaxing/SDP/sdpsolverfeastol", &feastol) );
1335 if ( retcode == SCIP_PARAMETERUNKNOWN )
1337 SCIPverbMessage(scip, SCIP_VERBLEVEL_FULL, NULL,
1338 "SDP Solver <%s>: feastol setting not available -- SCIP parameter has no effect.\n",
1343 SCIP_CALL( retcode );
1347 SCIP_CALL( SCIPgetRealParam(scip,
"relaxing/SDP/penaltyparam", &penaltyparam) );
1348 if ( SCIPisGE(scip, penaltyparam, 0.0) )
1351 givenpenaltyparam = penaltyparam;
1352 if ( retcode == SCIP_PARAMETERUNKNOWN )
1354 SCIPverbMessage(scip, SCIP_VERBLEVEL_FULL, NULL,
1355 "SDP Solver <%s>: penaltyparam setting not available -- SCIP parameter has no effect\n",
1360 SCIP_CALL( retcode );
1370 for (v = 0; v < nvars; v++)
1372 if ( SCIPisGT(scip, REALABS(SCIPvarGetObj(vars[v])), maxcoeff) )
1373 maxcoeff = REALABS(SCIPvarGetObj(vars[v]));
1380 SCIP_CALL( SCIPgetRealParam(scip,
"relaxing/SDP/maxpenaltyparam", &maxpenaltyparam) );
1381 if ( SCIPisGE(scip, maxpenaltyparam, 0.0) )
1385 if ( retcode == SCIP_PARAMETERUNKNOWN )
1387 SCIPverbMessage(scip, SCIP_VERBLEVEL_FULL, NULL,
1388 "SDP Solver <%s>: maxpenaltyparam setting not available -- SCIP parameter has no effect.\n",
1393 SCIP_CALL( retcode );
1397 if ( SCIPisLT(scip, givenpenaltyparam, maxpenaltyparam) )
1399 SCIPdebugMessage(
"Penalty parameter %f overwritten by maxpenaltyparam %f! \n", givenpenaltyparam, maxpenaltyparam);
1405 SCIP_Real givenmaxpenaltyparam;
1415 SCIP_Real lambdastar;
1417 SCIP_CALL( SCIPgetRealParam(scip,
"relaxing/SDP/lambdastar", &lambdastar) );
1418 if ( SCIPisGE(scip, lambdastar, 0.0) )
1431 conss = SCIPgetConss(scip);
1432 nconss = SCIPgetNConss(scip);
1435 for (c = 0; c < nconss; c++)
1438 if ( strcmp(SCIPconshdlrGetName(SCIPconsGetHdlr(conss[c])),
"SDP") == 0 )
1441 if ( SCIPisGT(scip, guess, maxguess) )
1450 if ( retcode == SCIP_PARAMETERUNKNOWN )
1452 SCIPverbMessage(scip, SCIP_VERBLEVEL_FULL, NULL,
1453 "SDP Solver <%s>: lambdastar setting not available -- SCIP parameter has no effect.\n",
1458 SCIP_CALL( retcode );
1461 SCIP_CALL( SCIPgetBoolParam(scip,
"relaxing/SDP/sdpinfo", &sdpinfo) );
1463 if ( retcode == SCIP_PARAMETERUNKNOWN )
1465 SCIPverbMessage(scip, SCIP_VERBLEVEL_FULL, NULL,
1466 "SDP Solver <%s>: sdpinfo setting not available -- SCIP parameter has no effect.\n",
1471 SCIP_CALL( retcode );
1474 SCIP_CALL( SCIPgetIntParam(scip,
"relaxing/SDP/slatercheck", &slatercheck) );
1476 if ( retcode == SCIP_PARAMETERUNKNOWN )
1478 SCIPverbMessage(scip, SCIP_VERBLEVEL_FULL, NULL,
1479 "SDP Solver <%s>: slatercheck setting not available -- SCIP parameter has no effect.\n",
1484 SCIP_CALL( retcode );
1494 assert( scip != NULL );
1495 assert( relax != NULL );
1496 assert(strcmp(SCIPrelaxGetName(relax),
RELAX_NAME) == 0);
1507 SCIP_RELAXDATA* relaxdata;
1509 assert( scip != NULL );
1510 assert( relax != NULL );
1512 relaxdata = SCIPrelaxGetData(relax);
1513 assert( relaxdata != NULL );
1515 SCIPdebugMessage(
"Exiting Relaxation Handler.\n");
1517 if ( relaxdata->displaystat && SCIPgetSubscipDepth(scip) == 0 )
1519 SCIPverbMessage(scip, SCIP_VERBLEVEL_NORMAL, NULL,
"\nSDP iterations:\t\t\t\t%6d\n", relaxdata->sdpiterations);
1520 SCIPverbMessage(scip, SCIP_VERBLEVEL_NORMAL, NULL,
"Average SDP-iterations:\t\t\t%6.2f \n", (SCIP_Real) relaxdata->sdpiterations / (SCIP_Real) relaxdata->sdpcalls );
1523 SCIPverbMessage(scip, SCIP_VERBLEVEL_NORMAL, NULL,
"Percentage 'fastest settings' solved:\t%6.2f \n", 100.0 * (SCIP_Real) relaxdata->solvedfast / (SCIP_Real) relaxdata->sdpinterfacecalls);
1524 SCIPverbMessage(scip, SCIP_VERBLEVEL_NORMAL, NULL,
"Percentage 'medium settings' solved:\t%6.2f \n", 100.0 * (SCIP_Real) relaxdata->solvedmedium / (SCIP_Real) relaxdata->sdpinterfacecalls);
1525 SCIPverbMessage(scip, SCIP_VERBLEVEL_NORMAL, NULL,
"Percentage 'stable settings' solved:\t%6.2f \n", 100.0 * (SCIP_Real) relaxdata->solvedstable / (SCIP_Real) relaxdata->sdpinterfacecalls);
1529 SCIPverbMessage(scip, SCIP_VERBLEVEL_NORMAL, NULL,
"Percentage 'default formulation' solved:\t%6.2f \n", 100.0 * (SCIP_Real) relaxdata->solvedfast / (SCIP_Real) relaxdata->sdpinterfacecalls);
1531 SCIPverbMessage(scip, SCIP_VERBLEVEL_NORMAL, NULL,
"Percentage penalty formulation used:\t%6.2f \n", 100.0 * (SCIP_Real) relaxdata->solvedpenalty / (SCIP_Real) relaxdata->sdpinterfacecalls);
1532 SCIPverbMessage(scip, SCIP_VERBLEVEL_NORMAL, NULL,
"Percentage unsolved even with penalty:\t%6.2f \n", 100.0 * (SCIP_Real) relaxdata->unsolved / (SCIP_Real) relaxdata->sdpinterfacecalls);
1534 if ( relaxdata->slatercheck )
1536 SCIPverbMessage(scip, SCIP_VERBLEVEL_NORMAL, NULL,
"Percentage primal Slater condition held:\t%6.2f \n", 100.0 * (SCIP_Real) relaxdata->npslaterholds / (SCIP_Real) relaxdata->sdpinterfacecalls);
1537 SCIPverbMessage(scip, SCIP_VERBLEVEL_NORMAL, NULL,
"Percentage primal Slater condition did not hold:\t%6.2f \n", 100.0 * (SCIP_Real) relaxdata->npnoslater / (SCIP_Real) relaxdata->sdpinterfacecalls);
1538 SCIPverbMessage(scip, SCIP_VERBLEVEL_NORMAL, NULL,
"Percentage primal Slater check failed:\t%6.2f \n", 100.0 * (SCIP_Real) relaxdata->npslatercheckfailed / (SCIP_Real) relaxdata->sdpinterfacecalls);
1540 SCIPverbMessage(scip, SCIP_VERBLEVEL_NORMAL, NULL,
"Percentage dual Slater condition held:\t%6.2f \n", 100.0 * (SCIP_Real) relaxdata->ndslaterholds / (SCIP_Real) relaxdata->sdpinterfacecalls);
1541 SCIPverbMessage(scip, SCIP_VERBLEVEL_NORMAL, NULL,
"Percentage dual Slater condition did not hold:\t%6.2f \n", 100.0 * (SCIP_Real) relaxdata->ndnoslater / (SCIP_Real) relaxdata->sdpinterfacecalls);
1542 SCIPverbMessage(scip, SCIP_VERBLEVEL_NORMAL, NULL,
"Percentage dual Slater check failed:\t%6.2f \n", 100.0 * (SCIP_Real) relaxdata->ndslatercheckfailed / (SCIP_Real) relaxdata->sdpinterfacecalls);
1543 SCIPverbMessage(scip, SCIP_VERBLEVEL_NORMAL, NULL,
"Percentage dual Slater check detected infeasibility:\t%6.2f \n", 100.0 * (SCIP_Real) relaxdata->nslaterinfeasible / (SCIP_Real) relaxdata->sdpinterfacecalls);
1545 if ( relaxdata->nslaterholds )
1547 SCIPverbMessage(scip, SCIP_VERBLEVEL_NORMAL, NULL,
"Percentage 'fastest settings' with primal and dual slater holding:\t%6.2f \n",
1548 100.0 * (SCIP_Real) relaxdata->stablewslater / (SCIP_Real) relaxdata->nslaterholds);
1549 SCIPverbMessage(scip, SCIP_VERBLEVEL_NORMAL, NULL,
"Percentage 'stable settings' with primal and dual slater holding:\t%6.2f \n",
1550 100.0 * (SCIP_Real) relaxdata->unstablewslater / (SCIP_Real) relaxdata->nslaterholds);
1551 SCIPverbMessage(scip, SCIP_VERBLEVEL_NORMAL, NULL,
"Percentage 'penalty' with primal and dual slater holding:\t%6.2f \n",
1552 100.0 * (SCIP_Real) relaxdata->penaltywslater / (SCIP_Real) relaxdata->nslaterholds);
1553 SCIPverbMessage(scip, SCIP_VERBLEVEL_NORMAL, NULL,
"Percentage 'computed infeasible lower bound' with primal and dual slater holding:\t%6.2f \n",
1554 100.0 * (SCIP_Real) relaxdata->boundedwslater / (SCIP_Real) relaxdata->nslaterholds);
1555 SCIPverbMessage(scip, SCIP_VERBLEVEL_NORMAL, NULL,
"Percentage 'unsolved' with primal and dual slater holding:\t%6.2f \n",
1556 100.0 * (SCIP_Real) relaxdata->unsolvedwslater / (SCIP_Real) relaxdata->nslaterholds);
1558 if ( relaxdata->nnoslater )
1560 SCIPverbMessage(scip, SCIP_VERBLEVEL_NORMAL, NULL,
"Percentage 'fastest settings' with either primal or dual slater not holding:\t%6.2f \n",
1561 100.0 * (SCIP_Real) relaxdata->stablenoslater / (SCIP_Real) relaxdata->nnoslater);
1562 SCIPverbMessage(scip, SCIP_VERBLEVEL_NORMAL, NULL,
"Percentage 'stable settings' with either primal or dual slater not holding:\t%6.2f \n",
1563 100.0 * (SCIP_Real) relaxdata->unstablenoslater / (SCIP_Real) relaxdata->nnoslater);
1564 SCIPverbMessage(scip, SCIP_VERBLEVEL_NORMAL, NULL,
"Percentage 'penalty' with either primal or dual slater not holding:\t%6.2f \n",
1565 100.0 * (SCIP_Real) relaxdata->penaltynoslater / (SCIP_Real) relaxdata->nnoslater);
1566 SCIPverbMessage(scip, SCIP_VERBLEVEL_NORMAL, NULL,
"Percentage 'computed infeasible lower bound' with either primal or dual slater not holding:\t%6.2f \n",
1567 100.0 * (SCIP_Real) relaxdata->boundednoslater / (SCIP_Real) relaxdata->nnoslater);
1568 SCIPverbMessage(scip, SCIP_VERBLEVEL_NORMAL, NULL,
"Percentage 'unsolved' with either primal or dual slater not holding:\t%6.2f \n",
1569 100.0 * (SCIP_Real) relaxdata->unsolvednoslater / (SCIP_Real) relaxdata->nnoslater);
1571 if ( relaxdata->nslaterinfeasible )
1573 SCIPverbMessage(scip, SCIP_VERBLEVEL_NORMAL, NULL,
"Percentage 'fastest settings' with slater check showing infeasibility:\t%6.2f \n",
1574 100.0 * (SCIP_Real) relaxdata->stableinfeasible / (SCIP_Real) relaxdata->nslaterinfeasible);
1575 SCIPverbMessage(scip, SCIP_VERBLEVEL_NORMAL, NULL,
"Percentage 'stable settings' with slater check showing infeasibility:\t%6.2f \n",
1576 100.0 * (SCIP_Real) relaxdata->unstableinfeasible / (SCIP_Real) relaxdata->nslaterinfeasible);
1577 SCIPverbMessage(scip, SCIP_VERBLEVEL_NORMAL, NULL,
"Percentage 'penalty' with slater check showing infeasibility:\t%6.2f \n",
1578 100.0 * (SCIP_Real) relaxdata->penaltyinfeasible / (SCIP_Real) relaxdata->nslaterinfeasible);
1579 SCIPverbMessage(scip, SCIP_VERBLEVEL_NORMAL, NULL,
"Percentage 'computed infeasible lower bound' with slater check showing infeasibility:\t%6.2f \n",
1580 100.0 * (SCIP_Real) relaxdata->boundedinfeasible / (SCIP_Real) relaxdata->nslaterinfeasible);
1581 SCIPverbMessage(scip, SCIP_VERBLEVEL_NORMAL, NULL,
"Percentage 'unsolved' with slater check showing infeasibility:\t%6.2f \n",
1582 100.0 * (SCIP_Real) relaxdata->unsolvedinfeasible / (SCIP_Real) relaxdata->nslaterinfeasible);
1584 #ifdef SLATERSOLVED_ABSOLUTE
1585 SCIPverbMessage(scip, SCIP_VERBLEVEL_NORMAL, NULL,
"Number of nodes with primal and dual slater holding:\t%d \n", relaxdata->nslaterholds);
1586 SCIPverbMessage(scip, SCIP_VERBLEVEL_NORMAL, NULL,
"Number of nodes with 'fastest settings' and primal and dual slater holding:\t%d \n", relaxdata->stablewslater);
1587 SCIPverbMessage(scip, SCIP_VERBLEVEL_NORMAL, NULL,
"Number of nodes with 'stable settings' and primal and dual slater holding:\t%d \n", relaxdata->unstablewslater);
1588 SCIPverbMessage(scip, SCIP_VERBLEVEL_NORMAL, NULL,
"Number of nodes with 'penalty' and primal and dual slater holding:\t%d \n", relaxdata->penaltywslater);
1589 SCIPverbMessage(scip, SCIP_VERBLEVEL_NORMAL, NULL,
"Number of nodes with 'computed infeasible lower bound' and primal and dual slater holding:\t%d \n", relaxdata->boundedwslater);
1590 SCIPverbMessage(scip, SCIP_VERBLEVEL_NORMAL, NULL,
"Number of nodes with 'unsolved' and primal and dual slater holding:\t%d \n", relaxdata->unsolvedwslater);
1592 SCIPverbMessage(scip, SCIP_VERBLEVEL_NORMAL, NULL,
"Number of nodes with either primal or dual slater not holding:\t%d \n", relaxdata->nnoslater);
1593 SCIPverbMessage(scip, SCIP_VERBLEVEL_NORMAL, NULL,
"Number of nodes with 'fastest settings' and either primal or dual slater not holding:\t%d \n", relaxdata->stablenoslater);
1594 SCIPverbMessage(scip, SCIP_VERBLEVEL_NORMAL, NULL,
"Number of nodes with 'stable settings' and either primal or dual slater not holding:\t%d \n", relaxdata->unstablenoslater);
1595 SCIPverbMessage(scip, SCIP_VERBLEVEL_NORMAL, NULL,
"Number of nodes with 'penalty' and either primal or dual slater not holding:\t%d \n", relaxdata->penaltynoslater);
1596 SCIPverbMessage(scip, SCIP_VERBLEVEL_NORMAL, NULL,
"Number of nodes with 'computed infeasible lower bound' and either primal or dual slater not holding:\t%d \n", relaxdata->boundednoslater);
1597 SCIPverbMessage(scip, SCIP_VERBLEVEL_NORMAL, NULL,
"Number of nodes with 'unsolved' and either primal or dual slater not holding:\t%d \n", relaxdata->unsolvednoslater);
1599 SCIPverbMessage(scip, SCIP_VERBLEVEL_NORMAL, NULL,
"Number of infeasible nodes:\t%d \n", relaxdata->nslaterinfeasible);
1600 SCIPverbMessage(scip, SCIP_VERBLEVEL_NORMAL, NULL,
"Number of infeasible nodes with 'fastest settings':\t%d \n", relaxdata->stableinfeasible);
1601 SCIPverbMessage(scip, SCIP_VERBLEVEL_NORMAL, NULL,
"Number of infeasible nodes with 'stable settings':\t%d \n", relaxdata->unstableinfeasible);
1602 SCIPverbMessage(scip, SCIP_VERBLEVEL_NORMAL, NULL,
"Number of infeasible nodes with 'penalty':\t%d \n", relaxdata->penaltyinfeasible);
1603 SCIPverbMessage(scip, SCIP_VERBLEVEL_NORMAL, NULL,
"Number of infeasible nodes with 'computed infeasible lower bound':\t%d \n", relaxdata->boundedinfeasible);
1604 SCIPverbMessage(scip, SCIP_VERBLEVEL_NORMAL, NULL,
"Number of infeasible nodes with 'unsolved':\t%d \n", relaxdata->unsolvedinfeasible);
1609 if ( relaxdata->varmapper != NULL )
1614 relaxdata->objval = 0.0;
1615 relaxdata->origsolved = FALSE;
1616 relaxdata->probingsolved = FALSE;
1617 relaxdata->feasible = FALSE;
1618 relaxdata->sdpiterations = 0;
1619 relaxdata->sdpcalls = 0;
1620 relaxdata->sdpinterfacecalls = 0;
1621 relaxdata->lastsdpnode = 0;
1631 SCIP_RELAXDATA* relaxdata;
1633 relaxdata = SCIPrelaxGetData(relax);
1634 assert(relaxdata != NULL);
1636 if ( relaxdata->sdpi != NULL )
1641 SCIPfreeMemory(scip, &relaxdata);
1643 SCIPrelaxSetData(relax, NULL);
1653 SCIP_RELAXDATA* relaxdata = NULL;
1657 assert( scip != NULL );
1660 SCIP_CALL( SCIPallocMemory(scip, &relaxdata) );
1661 SCIP_CALL(
SCIPsdpiCreate(&sdpi, SCIPgetMessagehdlr(scip), SCIPblkmem(scip)) );
1663 relaxdata->sdpi = sdpi;
1664 relaxdata->lastsdpnode = -1;
1668 assert( relax != NULL );
1671 SCIP_CALL( SCIPsetRelaxInitsol(scip, relax, relaxInitSolSdp) );
1672 SCIP_CALL( SCIPsetRelaxExit(scip, relax, relaxExitSdp) );
1673 SCIP_CALL( SCIPsetRelaxFree(scip, relax, relaxFreeSdp) );
1674 SCIP_CALL( SCIPsetRelaxCopy(scip, relax, relaxCopySdp) );
1677 SCIP_CALL( SCIPaddRealParam(scip,
"relaxing/SDP/sdpsolverepsilon",
1678 "the stopping criterion for the duality gap the sdpsolver should use",
1681 SCIP_CALL( SCIPaddRealParam(scip,
"relaxing/SDP/sdpsolverfeastol",
1682 "the feasibility tolerance the SDP solver should use for the SDP constraints",
1685 SCIP_CALL( SCIPaddRealParam(scip,
"relaxing/SDP/penaltyparam",
1686 "the starting value of the penalty parameter Gamma used for the penalty formulation if the "
1687 "SDP solver didn't converge; set this to a negative value to compute the parameter depending on the given problem", &(relaxdata->penaltyparam),
1690 SCIP_CALL( SCIPaddRealParam(scip,
"relaxing/SDP/maxpenaltyparam",
1691 "the maximum value of the penalty parameter Gamma used for the penalty formulation if the "
1692 "SDP solver didn't converge; set this to a negative value to compute the parameter depending on the given problem", &(relaxdata->maxpenaltyparam),
1695 SCIP_CALL( SCIPaddRealParam(scip,
"relaxing/SDP/lambdastar",
1696 "the parameter lambda star used by SDPA to set the initial point , "
1697 "set this to a negative value to compute the parameter depending on the given problem", &(relaxdata->lambdastar),
1700 SCIP_CALL( SCIPaddIntParam(scip,
"relaxing/SDP/slatercheck",
1701 "Should the Slater condition for the primal and dual problem be checked ahead of solving each SDP? 0: no, 1: yes and output statistics, 2: yes and print warning for "
1702 "every problem not satisfying primal and dual Slater condition", &(relaxdata->slatercheck), TRUE,
DEFAULT_SLATERCHECK, 0, 2, NULL, NULL) );
1704 SCIP_CALL( SCIPaddBoolParam(scip,
"relaxing/SDP/sdpinfo",
1705 "Should the SDP solver output information to the screen?",
1708 SCIP_CALL( SCIPaddBoolParam(scip,
"relaxing/SDP/objlimit",
1709 "Should an objective limit be given to the SDP-Solver?",
1712 SCIP_CALL( SCIPaddBoolParam(scip,
"relaxing/SDP/resolve",
1713 "Should the relaxation be resolved after bound-tightenings were found during propagation (outside of probing)?",
1716 SCIP_CALL( SCIPaddBoolParam(scip,
"relaxing/SDP/tightenvb",
1717 "Should Big-Ms in varbound-like constraints be tightened before giving them to the SDP-solver ?",
1720 SCIP_CALL( SCIPaddBoolParam(scip,
"relaxing/SDP/displaystatistics",
1721 "Should statistics about SDP iterations and solver settings/success be printed after quitting SCIP-SDP ?",
1724 SCIP_CALL( SCIPaddIntParam(scip,
"relaxing/SDP/settingsresetfreq",
1725 "frequency for resetting parameters in SDP solver and trying again with fastest settings (-1: never, 0: only at depth settingsresetofs)",
1728 SCIP_CALL( SCIPaddIntParam(scip,
"relaxing/SDP/settingsresetofs",
1729 "frequency offset for resetting parameters in SDP solver and trying again with fastest settings",
1757 SCIP_RELAXDATA* relaxdata;
1759 assert( relax != NULL );
1760 assert( lbvars != NULL );
1761 assert( ubvars != NULL );
1762 assert( arraylength != NULL );
1763 assert( *arraylength >= 0 );
1765 relaxdata = SCIPrelaxGetData(relax);
1766 assert( relaxdata != NULL );
1780 SCIP_RELAXDATA* relaxdata;
1782 assert( relax != NULL );
1783 assert( success != NULL );
1784 assert( objval != NULL );
1786 relaxdata = SCIPrelaxGetData(relax);
1787 assert( relaxdata != NULL );
1789 *success = relaxdata->origsolved;
1790 *objval = relaxdata->objval;
1800 SCIP_Real* solarray,
1804 SCIP_RELAXDATA* relaxdata;
1806 assert( relax != NULL );
1807 assert( success != NULL );
1808 assert( solarray != NULL );
1810 relaxdata = SCIPrelaxGetData(relax);
1811 assert( relaxdata != NULL );
1813 *success = relaxdata->origsolved;
1815 if ( *sollength >= SCIPgetNVars(scip) )
1817 SCIP_CALL(
SCIPsdpiGetSol(relaxdata->sdpi, NULL, solarray, sollength) );
1821 SCIPdebugMessage(
"Called SCIPrelaxSdpGetRelaxSol with an array that wasn't big enough, needed length %d, given %d!\n", SCIPgetNVars(scip), *sollength);
1822 *sollength = SCIPgetNVars(scip);
1833 assert( relax != NULL );
1834 assert( SCIPrelaxGetData(relax) != NULL );
1836 return SCIPrelaxGetData(relax)->lastsdpnode;
1844 SCIP_RELAXDATA* relaxdata;
1846 assert( relax != NULL );
1848 relaxdata = SCIPrelaxGetData(relax);
1850 assert( relaxdata != NULL );
1851 assert( relaxdata->sdpi != NULL );
1861 SCIP_RELAXDATA* relaxdata;
1863 assert( relax != NULL );
1865 relaxdata = SCIPrelaxGetData(relax);
1867 assert( relaxdata != NULL );
1868 assert( relaxdata->sdpi != NULL );
1870 return relaxdata->probingsolved;
1878 assert( relax != NULL );
1879 assert( SCIPrelaxGetData(relax) != NULL );
1881 return ( SCIPrelaxGetData(relax)->feasible );
1889 assert( relax != NULL );
1890 assert( SCIPrelaxGetData(relax) != NULL );
1892 return SCIPrelaxGetData(relax)->sdpiterations;
1900 assert( relax != NULL );
1901 assert( SCIPrelaxGetData(relax) != NULL );
1903 return ( SCIPrelaxGetData(relax)->sdpcalls );
1911 assert( relax != NULL );
1912 assert( SCIPrelaxGetData(relax) != NULL );
1914 return ( SCIPrelaxGetData(relax)->solvedfast );
1922 assert( relax != NULL );
1923 assert( SCIPrelaxGetData(relax) != NULL );
1925 return ( SCIPrelaxGetData(relax)->solvedmedium );
1933 assert( relax != NULL );
1934 assert( SCIPrelaxGetData(relax) != NULL );
1936 return ( SCIPrelaxGetData(relax)->solvedstable );
1944 assert( relax != NULL );
1945 assert( SCIPrelaxGetData(relax) != NULL );
1947 return ( SCIPrelaxGetData(relax)->solvedpenalty );
1955 assert( relax != NULL );
1956 assert( SCIPrelaxGetData(relax) != NULL );
1958 return ( SCIPrelaxGetData(relax)->unsolved );
SCIP_RETCODE SCIPsdpiFree(SCIP_SDPI **sdpi)
SCIP_Bool SCIPsdpiIsDualUnbounded(SCIP_SDPI *sdpi)
SCIP_RETCODE SCIPsdpiDelLPRows(SCIP_SDPI *sdpi, int firstrow, int lastrow)
SCIP_RETCODE SCIPsdpiGetSdpCalls(SCIP_SDPI *sdpi, int *calls)
static SCIP_RETCODE calcRelax(SCIP *scip, SCIP_RELAXDATA *relaxdata, SCIP_RESULT *result, SCIP_Real *lowerbound)
static SCIP_DECL_RELAXCOPY(relaxCopySdp)
SCIP_RETCODE SCIPsdpVarmapperAddVars(SCIP *scip, SdpVarmapper *varmapper, int nvars, SCIP_VAR **vars)
static SCIP_Bool allVarsFixed(SCIP *scip)
#define DEFAULT_SLATERCHECK
int SCIPrelaxSdpGetNSdpPenalty(SCIP_RELAX *relax)
enum SCIP_SDPSolverSetting SCIP_SDPSOLVERSETTING
static SCIP_DECL_RELAXEXIT(relaxExitSdp)
#define DEFAULT_SDPSOLVERFEASTOL
const char * SCIPsdpiGetSolverName(void)
SCIP_RETCODE SCIPsdpiGetSol(SCIP_SDPI *sdpi, SCIP_Real *objval, SCIP_Real *dualsol, int *dualsollength)
int SCIPrelaxSdpGetNSdpUnsolved(SCIP_RELAX *relax)
#define DEFAULT_PENALTYPARAM
SCIP_Bool SCIPsdpiFeasibilityKnown(SCIP_SDPI *sdpi)
SCIP_RETCODE SCIPsdpiLoadSDP(SCIP_SDPI *sdpi, int nvars, SCIP_Real *obj, SCIP_Real *lb, SCIP_Real *ub, int nsdpblocks, int *sdpblocksizes, int *sdpnblockvars, int sdpconstnnonz, int *sdpconstnblocknonz, int **sdpconstrow, int **sdpconstcol, SCIP_Real **sdpconstval, int sdpnnonz, int **sdpnblockvarnonz, int **sdpvar, int ***sdprow, int ***sdpcol, SCIP_Real ***sdpval, int nlpcons, SCIP_Real *lplhs, SCIP_Real *lprhs, int lpnnonz, int *lprow, int *lpcol, SCIP_Real *lpval)
SCIP_RETCODE SCIPsdpiComputeLambdastar(SCIP_SDPI *sdpi, SCIP_Real maxguess)
SCIP_RETCODE createConsSavedsdpsettings(SCIP *scip, SCIP_CONS **cons, const char *name, SCIP_SDPSOLVERSETTING settings)
#define DEFAULT_TIGHTENVB
static SCIP_DECL_RELAXEXEC(relaxExecSdp)
SCIP_VAR * SCIPsdpVarmapperGetSCIPvar(SdpVarmapper *varmapper, int ind)
SCIP_RETCODE SCIPsdpiGetIterations(SCIP_SDPI *sdpi, int *iterations)
#define DEFAULT_SETTINGSRESETFREQ
SCIP_RETCODE SCIPsdpiSettingsUsed(SCIP_SDPI *sdpi, SCIP_SDPSOLVERSETTING *usedsetting)
SCIP_RETCODE SCIPsdpiSlaterSettings(SCIP_SDPI *sdpi, SCIP_SDPSLATERSETTING *slatersetting)
SCIP_Bool SCIPsdpiIsAcceptable(SCIP_SDPI *sdpi)
static SCIP_DECL_RELAXINITSOL(relaxInitSolSdp)
int SCIPrelaxSdpGetNSdpStable(SCIP_RELAX *relax)
int SCIPrelaxSdpGetNSdpMedium(SCIP_RELAX *relax)
SCIP_RETCODE SCIPsdpVarmapperCreate(SCIP *scip, SdpVarmapper **varmapper, int size)
SCIP_Bool SCIPsdpiIsTimelimExc(SCIP_SDPI *sdpi)
SCIP_RETCODE SCIPrelaxSdpRelaxVal(SCIP_RELAX *relax, SCIP_Bool *success, SCIP_Real *objval)
SCIP_Bool SCIPsdpiIsDualInfeasible(SCIP_SDPI *sdpi)
General interface methods for SDP-preprocessing (mainly fixing variables and removing empty rows/cols...
static SCIP_DECL_RELAXFREE(relaxFreeSdp)
struct Sdpvarmapper SdpVarmapper
enum SCIP_SDPSlaterSetting SCIP_SDPSLATERSETTING
#define DEFAULT_DISPLAYSTAT
int SCIPsdpVarmapperGetSdpIndex(SdpVarmapper *varmapper, SCIP_VAR *var)
static SCIP_RETCODE putLpDataInInterface(SCIP *scip, SCIP_SDPI *sdpi, SdpVarmapper *varmapper)
SCIP_RETCODE SCIPsdpiChgBounds(SCIP_SDPI *sdpi, int nvars, const int *ind, const SCIP_Real *lb, const SCIP_Real *ub)
int SCIPrelaxSdpGetNSdpCalls(SCIP_RELAX *relax)
Constraint handler for SDP-constraints.
SCIP_RETCODE SCIPsdpiGetLowerObjbound(SCIP_SDPI *sdpi, SCIP_Real *objlb)
SCIP_Bool SCIPsdpiIsObjlimExc(SCIP_SDPI *sdpi)
class that maps SCIP variables to SDP indices (the SCIP variables are given SDP indices in the order ...
#define DEFAULT_MAXPENALTYPARAM
SCIP_RETCODE SCIPsdpiCreate(SCIP_SDPI **sdpi, SCIP_MESSAGEHDLR *messagehdlr, BMS_BLKMEM *blkmem)
SCIP_RETCODE SCIPconsSdpGetData(SCIP *scip, SCIP_CONS *cons, int *nvars, int *nnonz, int *blocksize, int *arraylength, int *nvarnonz, int **col, int **row, SCIP_Real **val, SCIP_VAR **vars, int *constnnonz, int *constcol, int *constrow, SCIP_Real *constval)
SCIP_RETCODE SCIPsdpiAddLPRows(SCIP_SDPI *sdpi, int nrows, const SCIP_Real *lhs, const SCIP_Real *rhs, int nnonz, const int *row, const int *col, const SCIP_Real *val)
const char * SCIPsdpiGetSolverDesc(void)
SCIP_RETCODE SCIPsdpiComputePenaltyparam(SCIP_SDPI *sdpi, SCIP_Real maxcoeff, SCIP_Real *penaltyparam)
SCIP_RETCODE SCIPsdpiSetIntpar(SCIP_SDPI *sdpi, SCIP_SDPPARAM type, int ival)
SCIP_SDPSOLVERSETTING SCIPconsSavedsdpsettingsGetSettings(SCIP *scip, SCIP_CONS *cons)
#define DEFAULT_SETTINGSRESETOFS
SCIP_Bool SCIPrelaxSdpSolvedProbing(SCIP_RELAX *relax)
SCIP_Real SCIPsdpiInfinity(SCIP_SDPI *sdpi)
SCIP_RETCODE SCIPsdpiSolve(SCIP_SDPI *sdpi, SCIP_Real *start, SCIP_SDPSOLVERSETTING startsettings, SCIP_Bool enforceslatercheck, SCIP_Real timelimit)
long int SCIPrelaxSdpGetSdpNode(SCIP_RELAX *relax)
int SCIPrelaxSdpGetNSdpFast(SCIP_RELAX *relax)
SCIP_Bool SCIPrelaxSdpSolvedOrig(SCIP_RELAX *relax)
static SCIP_RETCODE putSdpDataInInterface(SCIP *scip, SCIP_SDPI *sdpi, SdpVarmapper *varmapper)
SCIP_Bool SCIPsdpiWasSolved(SCIP_SDPI *sdpi)
int SCIPrelaxSdpGetNIterations(SCIP_RELAX *relax)
SCIP_RETCODE SCIPsdpiComputeMaxPenaltyparam(SCIP_SDPI *sdpi, SCIP_Real penaltyparam, SCIP_Real *maxpenaltyparam)
SCIP_RETCODE SCIPsdpiClear(SCIP_SDPI *sdpi)
SCIP_RETCODE SCIPsdpiChgObj(SCIP_SDPI *sdpi, int nvars, const int *ind, const SCIP_Real *obj)
SCIP_RETCODE SCIPrelaxSdpGetRelaxSol(SCIP *scip, SCIP_RELAX *relax, SCIP_Bool *success, SCIP_Real *solarray, int *sollength)
SCIP_RETCODE SCIPsdpVarmapperFree(SCIP *scip, SdpVarmapper **varmapper)
SCIP_RETCODE SCIPrelaxSdpGetPrimalBoundVars(SCIP_RELAX *relax, SCIP_Real *lbvars, SCIP_Real *ubvars, int *arraylength)
#define DEFAULT_LAMBDASTAR
SCIP_Bool SCIPsdpiIsDualFeasible(SCIP_SDPI *sdpi)
struct SCIP_SDPi SCIP_SDPI
SCIP_Bool SCIPsdpiIsPrimalFeasible(SCIP_SDPI *sdpi)
SCIP_Bool SCIPrelaxSdpIsFeasible(SCIP_RELAX *relax)
SCIP_RETCODE SCIPsdpiSetRealpar(SCIP_SDPI *sdpi, SCIP_SDPPARAM type, SCIP_Real dval)
enum SCIP_SDPSlater SCIP_SDPSLATER
SCIP_RETCODE SCIPconsSdpGetNNonz(SCIP *scip, SCIP_CONS *cons, int *nnonz, int *constnnonz)
SCIP_RETCODE SCIPsdpiGetNLPRows(SCIP_SDPI *sdpi, int *nlprows)
SCIP_RETCODE SCIPsdpiGetPrimalBoundVars(SCIP_SDPI *sdpi, SCIP_Real *lbvars, SCIP_Real *ubvars, int *arraylength)
SCIP_RETCODE SCIPconsSdpGuessInitialPoint(SCIP *scip, SCIP_CONS *cons, SCIP_Real *lambdastar)
SCIP_Bool SCIPsdpiSolvedOrig(SCIP_SDPI *sdpi)
SCIP_RETCODE SCIPsdpiSlater(SCIP_SDPI *sdpi, SCIP_SDPSLATER *primalslater, SCIP_SDPSLATER *dualslater)
#define DEFAULT_SDPSOLVEREPSILON
SCIP_RETCODE SCIPincludeRelaxSdp(SCIP *scip)
constraint handler for saving SDP settings