/** branching execution method for fractional LP solutions */ static SCIP_DECL_BRANCHEXECLP(branchExeclpnodereopt) {/*lint --e{715}*/ assert(branchrule != NULL ); assert(*result != SCIP_BRANCHED); *result = SCIP_DIDNOTRUN; if( SCIPisReoptEnabled(scip) && SCIPreoptimizeNode(scip, SCIPgetCurrentNode(scip)) ) { SCIP_VAR** branchcands; SCIP_Real* branchcandssol; SCIP_Real* branchcandsfrac; int nbranchcands; SCIP_Bool sbinit; SCIP_Real objsimrootlp; SCIP_CALL( SCIPgetBoolParam(scip, "reoptimization/strongbranchinginit", &sbinit) ); SCIP_CALL( SCIPgetRealParam(scip, "reoptimization/objsimrootLP", &objsimrootlp) ); if( sbinit && SCIPgetCurrentNode(scip) == SCIPgetRootNode(scip) && SCIPgetReoptSimilarity(scip, SCIPgetNReoptRuns(scip), SCIPgetNReoptRuns(scip)) <= objsimrootlp ) /* check objsimrootlp */ { /* get branching candidates */ SCIP_CALL( SCIPgetLPBranchCands(scip, &branchcands, &branchcandssol, &branchcandsfrac, NULL, &nbranchcands, NULL) ); /* run strong branching initialization */ if( nbranchcands > 0 ) { SCIP_CALL( SCIPexecRelpscostBranching(scip, TRUE, branchcands, branchcandssol, branchcandsfrac, nbranchcands, FALSE, result) ); assert(*result == SCIP_DIDNOTRUN || *result == SCIP_CUTOFF || *result == SCIP_REDUCEDDOM); } } if( *result != SCIP_CUTOFF && *result != SCIP_REDUCEDDOM) { assert((SCIPnodeGetReoptID(SCIPgetCurrentNode(scip)) == 0 && SCIPnodeGetDepth(SCIPgetCurrentNode(scip)) == 0 ) || 1 <= SCIPnodeGetReoptID(SCIPgetCurrentNode(scip))); SCIP_CALL( Exec(scip, result) ); } } return SCIP_OKAY; }
/** execution method of primal heuristic */ static SCIP_DECL_HEUREXEC(heurExecReoptsols) {/*lint --e{715}*/ SCIP_HEURDATA* heurdata; SCIP_SOL** sols; SCIP_Real objsimsol; SCIP_Bool sepabestsol; int allocmem; int nchecksols; int nsolsadded; #ifdef SCIP_MORE_DEBUG int nsolsaddedrun; #endif int run; int max_run; assert(heur != NULL); assert(scip != NULL); *result = SCIP_DIDNOTRUN; if( !SCIPisReoptEnabled(scip) ) return SCIP_OKAY; heurdata = SCIPheurGetData(heur); assert(heurdata != NULL); max_run = heurdata->maxruns == -1 ? 0 : MAX(0, SCIPgetNReoptRuns(scip)-1-heurdata->maxruns); /*lint !e666*/ nchecksols = heurdata->maxsols == -1 ? INT_MAX : heurdata->maxsols; SCIP_CALL( SCIPgetRealParam(scip, "reoptimization/objsimsol", &objsimsol) ); SCIP_CALL( SCIPgetBoolParam(scip, "reoptimization/sepabestsol", &sepabestsol) ); /* allocate a buffer array to store the solutions */ allocmem = 20; SCIP_CALL( SCIPallocBufferArray(scip, &sols, allocmem) ); nsolsadded = 0; for( run = SCIPgetNReoptRuns(scip); run > max_run && nchecksols > 0; run-- ) { SCIP_Real sim; int nsols; #ifdef SCIP_MORE_DEBUG nsolsaddedrun = 0; #endif nsols = 0; if( objsimsol == -1 ) sim = 1; else sim = SCIPgetReoptSimilarity(scip, run, SCIPgetNReoptRuns(scip)-1); if( sim >= objsimsol ) { int s; /* get solutions of a specific run */ SCIP_CALL( SCIPgetReopSolsRun(scip, run, sols, allocmem, &nsols) ); /* check memory and reallocate */ if( nsols > allocmem ) { allocmem = nsols; SCIP_CALL( SCIPreallocBufferArray(scip, &sols, allocmem) ); SCIP_CALL( SCIPgetReopSolsRun(scip, run, sols, allocmem, &nsols) ); } assert(nsols <= allocmem); /* update the solutions * stop, if the maximal number of solutions to be checked is reached */ for( s = 0; s < nsols && nchecksols > 0; s++ ) { SCIP_SOL* sol; SCIP_Real objsol; sol = sols[s]; SCIP_CALL( SCIPrecomputeSolObj(scip, sol) ); objsol = SCIPgetSolTransObj(scip, sol); /* we do not want to add solutions with objective value +infinity. * moreover, the solution should improve the current primal bound */ if( !SCIPisInfinity(scip, objsol) && !SCIPisInfinity(scip, -objsol) && SCIPisFeasLT(scip, objsol, SCIPgetCutoffbound(scip)) ) { SCIP_Bool stored; SCIP_Bool feasible; if( sepabestsol ) { SCIP_CALL( SCIPcheckSolOrig(scip, sol, &feasible, FALSE, TRUE) ); } else feasible = TRUE; if( feasible) { /* create a new solution */ SCIP_CALL( createNewSol(scip, heur, sol, &stored) ); if( stored ) { nsolsadded++; #ifdef SCIP_MORE_DEBUG nsolsaddedrun++; #endif heurdata->nimprovingsols++; } } } nchecksols--; heurdata->ncheckedsols++; } } #ifdef SCIP_MORE_DEBUG printf(">> heuristic <%s> found %d of %d improving solutions from run %d.\n", HEUR_NAME, nsolsaddedrun, nsols, run); #endif } SCIPdebugMessage(">> heuristic <%s> found %d improving solutions.\n", HEUR_NAME, nsolsadded); if( nsolsadded > 0 ) *result = SCIP_FOUNDSOL; else *result = SCIP_DIDNOTFIND; /* reset the marks of the checked solutions */ SCIPresetReoptSolMarks(scip); /* free the buffer array */ SCIPfreeBufferArray(scip, &sols); return SCIP_OKAY; }