/** arbitrary primal solution separation method of separator */ static SCIP_DECL_SEPAEXECSOL(sepaExecsolIntobj) { /*lint --e{715}*/ *result = SCIP_DIDNOTRUN; SCIP_CALL( separateCuts(scip, sepa, sol, result) ); return SCIP_OKAY; }
/** LP solution separation method of separator */ static SCIP_DECL_SEPAEXECLP(sepaExeclpImpliedbounds) { /*lint --e{715}*/ SCIP_VAR** vars; SCIP_VAR** fracvars; SCIP_Real* solvals; SCIP_Real* fracvals; SCIP_Bool cutoff; int nvars; int nbinvars; int nfracs; int ncuts; assert(sepa != NULL); assert(scip != NULL); *result = SCIP_DIDNOTRUN; /* gets active problem variables */ SCIP_CALL( SCIPgetVarsData(scip, &vars, &nvars, &nbinvars, NULL, NULL, NULL) ); if( nbinvars == 0 ) return SCIP_OKAY; /* get fractional problem variables */ /* todo try out also separating fractional implicit integer variables */ SCIP_CALL( SCIPgetLPBranchCands(scip, &fracvars, &fracvals, NULL, &nfracs, NULL, NULL) ); if( nfracs == 0 ) return SCIP_OKAY; /* get solution values for all variables */ SCIP_CALL( SCIPallocBufferArray(scip, &solvals, nvars) ); SCIP_CALL( SCIPgetVarSols(scip, nvars, vars, solvals) ); /* call the cut separation */ SCIP_CALL( separateCuts(scip, sepa, NULL, solvals, fracvars, fracvals, nfracs, &cutoff, &ncuts) ); /* adjust result code */ if ( cutoff ) *result = SCIP_CUTOFF; else if ( ncuts > 0 ) *result = SCIP_SEPARATED; else *result = SCIP_DIDNOTFIND; /* free temporary memory */ SCIPfreeBufferArray(scip, &solvals); return SCIP_OKAY; }
/** LP solution separation method of separator */ static SCIP_DECL_SEPAEXECLP(sepaExeclpIntobj) { /*lint --e{715}*/ *result = SCIP_DIDNOTRUN; /* only call separator, if we are not close to terminating */ if( SCIPisStopped(scip) ) return SCIP_OKAY; /* only call separator, if an optimal LP solution is at hand */ if( SCIPgetLPSolstat(scip) != SCIP_LPSOLSTAT_OPTIMAL ) return SCIP_OKAY; /* only call separator, if there are fractional variables */ if( SCIPgetNLPBranchCands(scip) == 0 ) return SCIP_OKAY; SCIP_CALL( separateCuts(scip, sepa, NULL, result) ); return SCIP_OKAY; }
/** arbitrary primal solution separation method of separator */ static SCIP_DECL_SEPAEXECSOL(sepaExecsolImpliedbounds) { /*lint --e{715}*/ SCIP_VAR** vars; SCIP_VAR** fracvars; SCIP_Real* solvals; SCIP_Real* fracvals; SCIP_Bool cutoff; int nvars; int nbinvars; int nfracs; int ncuts; int i; assert(sepa != NULL); assert(scip != NULL); *result = SCIP_DIDNOTRUN; /* gets active problem variables */ SCIP_CALL( SCIPgetVarsData(scip, &vars, &nvars, &nbinvars, NULL, NULL, NULL) ); if( nbinvars == 0 ) return SCIP_OKAY; /* get solution values for all variables */ SCIP_CALL( SCIPallocBufferArray(scip, &solvals, nvars) ); SCIP_CALL( SCIPgetSolVals(scip, sol, nvars, vars, solvals) ); /* get binary problem variables that are fractional in given solution */ SCIP_CALL( SCIPallocBufferArray(scip, &fracvars, nbinvars) ); SCIP_CALL( SCIPallocBufferArray(scip, &fracvals, nbinvars) ); nfracs = 0; for( i = 0; i < nbinvars; ++i ) { if( !SCIPisFeasIntegral(scip, solvals[i]) ) { fracvars[nfracs] = vars[i]; fracvals[nfracs] = solvals[i]; nfracs++; } } /* call the cut separation */ ncuts = 0; cutoff = FALSE; if( nfracs > 0 ) { SCIP_CALL( separateCuts(scip, sepa, sol, solvals, fracvars, fracvals, nfracs, &cutoff, &ncuts) ); } /* adjust result code */ if ( cutoff ) *result = SCIP_CUTOFF; else if ( ncuts > 0 ) *result = SCIP_SEPARATED; else *result = SCIP_DIDNOTFIND; /* free temporary memory */ SCIPfreeBufferArray(scip, &fracvals); SCIPfreeBufferArray(scip, &fracvars); SCIPfreeBufferArray(scip, &solvals); return SCIP_OKAY; }