63#define CONSHDLR_NAME "exactsol"
64#define CONSHDLR_DESC "constraint handler for repairing floating-point primal solutions to satisfy exact feasibility"
65#define CONSHDLR_ENFOPRIORITY -9999999
66#define CONSHDLR_CHECKPRIORITY -999999
67#define CONSHDLR_EAGERFREQ 100
69#define CONSHDLR_NEEDSCONS FALSE
71#define DEFAULT_CHECKFPFEASIBILITY TRUE
73#define DEFAULT_CHECKCONTIMPLINT TRUE
75#define DEFAULT_ABORTFRAC 1e-9
77#define DEFAULT_UNFIXFRAC 0.0
78#define DEFAULT_MAXSTALLS 1000
79#define DEFAULT_SOLBUFSIZE 10
80#define DEFAULT_MINIMPROVE 0.2
91struct SCIP_ConshdlrData
96 int nhashedassignments;
133 if( sol1->
len != sol2->
len )
136 for(
i = 0;
i < sol1->
len;
i++ )
155 for(
i = 0;
i <
sol->len; ++
i )
177 if( conshdlrdata->nbufferedsols == conshdlrdata->lensolubuffer )
180 conshdlrdata->lensolubuffer, conshdlrdata->lensolubuffer * 2) );
181 conshdlrdata->lensolubuffer *= 2;
185 conshdlrdata->solubuffer[conshdlrdata->nbufferedsols] = insertsol;
186 conshdlrdata->nbufferedsols++;
200 for(
i = 0;
i < conshdlrdata->nbufferedsols;
i++ )
205 conshdlrdata->nbufferedsols = 0;
225 if( checkcontimplint )
230 nintegers =
nvars - ncontvars;
238 nintegers =
nvars - ncontvars - ncontimplvars;
246 for(
i = 0;
i < nintegers;
i++ )
254 (*assignment)->len = nintegers;
289 if( conshdlrdata->probhasconteqs != -1 )
296 conshdlrdata->probhasconteqs = 0;
298 for(
c = 0;
c < nconss; ++
c )
313 conshdlrdata->probhasconteqs = 1;
318 if( conshdlrdata->probhasconteqs == 1 )
410 if( conshdlrdata->probhasconteqs == -1 )
414 if( conshdlrdata->ncurrentstalls >= conshdlrdata->maxstalls )
475 if( conshdlrdata->checkfpfeasibility )
518 if( conshdlrdata->lenhash == conshdlrdata->nhashedassignments )
521 conshdlrdata->lenhash, conshdlrdata->lenhash * 2) );
522 conshdlrdata->lenhash *= 2;
524 conshdlrdata->hashedassignments[conshdlrdata->nhashedassignments] = assignment;
525 conshdlrdata->nhashedassignments++;
562 if( !conshdlrdata->checkcontimplint )
566 for(
i = nintegers;
i <
nvars; ++
i )
581 SCIPsortPtr((
void**)conshdlrdata->solubuffer, SCIPsolComp, conshdlrdata->nbufferedsols);
583 while( conshdlrdata->nbufferedsols > 0 && !foundsol )
586 worksol = conshdlrdata->solubuffer[conshdlrdata->nbufferedsols - 1];
591 SCIPdebugMessage(
"don't repair heuristic with obj value (%g) greater than upper bound (%g) \n",
594 conshdlrdata->nbufferedsols--;
598 SCIPdebugMessage(
"attempting to repair solution from heuristic %s with floating point objval %g \n",
602 for(
i = 0;
i < nintegers; ++
i )
657 conshdlrdata->nbufferedsols--;
673 SCIPwarningMessage(
scip,
"Error while solving LP in Exactsol Constraint Handler; exact LP solve terminated with code <%d>\n",retstat);
696 conshdlrdata->nbufferedsols--;
703 conshdlrdata->nbufferedsols--;
712 SCIPdebugMessage(
"successfully found feasible improving solution, objval %g, upperbound %g\n",
714 conshdlrdata->ncurrentstalls = 0;
718 SCIPdebugMessage(
"repaired solution not feasible or not improving, objval %g, upperbound %g \n",
720 conshdlrdata->ncurrentstalls++;
774 conshdlrdata->nhashedassignments = 0;
780 conshdlrdata->nbufferedsols = 0;
782 conshdlrdata->ncurrentstalls = 0;
783 conshdlrdata->probhasconteqs = -1;
812 for(
i = 0;
i < conshdlrdata->nhashedassignments;
i++ )
819 conshdlrdata->nhashedassignments = 0;
822 for(
i = 0;
i < conshdlrdata->nbufferedsols;
i++ )
827 conshdlrdata->nbufferedsols = 0;
868 consEnfolpExactSol, consEnfopsExactSol, consCheckExactSol, consLockExactSol,
885 "should a solution be checked in floating-point arithmetic prior to being processed?",
889 "should integrality of continuous implied integral variables be ensured?",
893 "fractionality of enforced integral value above which reparation is aborted",
897 "fractionality of weakly implied value up to which reparation fixes variable",
901 "maximal number of consecutive repair calls without success",
905 "size of solution buffer",
909 "minimal percentage of primal improvement to trigger solution processing",
#define CONSHDLR_NEEDSCONS
#define CONSHDLR_CHECKPRIORITY
#define CONSHDLR_EAGERFREQ
#define CONSHDLR_ENFOPRIORITY
Constraint handler for linear constraints in their most general form, .
#define DEFAULT_CHECKFPFEASIBILITY
#define DEFAULT_MAXSTALLS
#define DEFAULT_ABORTFRAC
struct SolIntAssignment SOLINTASSIGNMENT
static void clearSoluBuffer(SCIP *scip, SCIP_CONSHDLRDATA *conshdlrdata)
static SCIP_RETCODE bufferSolution(SCIP *scip, SCIP_SOL *sol, SCIP_CONSHDLRDATA *conshdlrdata)
#define DEFAULT_MINIMPROVE
static void checkProbHasContEqs(SCIP *scip, SCIP_CONSHDLRDATA *conshdlrdata)
#define DEFAULT_CHECKCONTIMPLINT
static void solFreeAssignment(SCIP *scip, SOLINTASSIGNMENT **assignment)
static SCIP_RETCODE solCreateSolAssignment(SCIP *scip, SCIP_SOL *sol, SCIP_Bool checkcontimplint, SOLINTASSIGNMENT **assignment)
#define DEFAULT_UNFIXFRAC
#define DEFAULT_SOLBUFSIZE
constraint handler for ensuring that primal solution is exact
common defines and data types used in all packages of SCIP
#define SCIP_STRINGEQ(name, reference, retcode)
#define SCIP_CALL_ABORT(x)
SCIP_VAR ** SCIPgetVarsExactLinear(SCIP *scip, SCIP_CONS *cons)
int SCIPgetNVarsExactLinear(SCIP *scip, SCIP_CONS *cons)
SCIP_RETCODE SCIPincludeConshdlrExactSol(SCIP *scip)
SCIP_STAGE SCIPgetStage(SCIP *scip)
int SCIPgetNContVars(SCIP *scip)
SCIP_RETCODE SCIPgetSolVarsData(SCIP *scip, SCIP_SOL *sol, SCIP_VAR ***vars, int *nvars, int *nbinvars, int *nintvars, int *nbinimplvars, int *nintimplvars, int *ncontimplvars, int *ncontvars)
SCIP_CONS ** SCIPgetConss(SCIP *scip)
int SCIPgetNVars(SCIP *scip)
int SCIPgetNConss(SCIP *scip)
SCIP_VAR ** SCIPgetVars(SCIP *scip)
int SCIPgetNContImplVars(SCIP *scip)
void SCIPhashtableFree(SCIP_HASHTABLE **hashtable)
SCIP_Bool SCIPhashtableExists(SCIP_HASHTABLE *hashtable, void *element)
SCIP_RETCODE SCIPhashtableCreate(SCIP_HASHTABLE **hashtable, BMS_BLKMEM *blkmem, int tablesize, SCIP_DECL_HASHGETKEY((*hashgetkey)), SCIP_DECL_HASHKEYEQ((*hashkeyeq)), SCIP_DECL_HASHKEYVAL((*hashkeyval)), void *userptr)
void SCIPhashtableRemoveAll(SCIP_HASHTABLE *hashtable)
SCIP_RETCODE SCIPhashtableInsert(SCIP_HASHTABLE *hashtable, void *element)
#define SCIPhashSignature64(a)
void SCIPwarningMessage(SCIP *scip, const char *formatstr,...)
SCIP_RETCODE SCIPaddIntParam(SCIP *scip, const char *name, const char *desc, int *valueptr, SCIP_Bool isadvanced, int defaultvalue, int minvalue, int maxvalue, SCIP_DECL_PARAMCHGD((*paramchgd)), SCIP_PARAMDATA *paramdata)
SCIP_RETCODE SCIPaddRealParam(SCIP *scip, const char *name, const char *desc, SCIP_Real *valueptr, SCIP_Bool isadvanced, SCIP_Real defaultvalue, SCIP_Real minvalue, SCIP_Real maxvalue, SCIP_DECL_PARAMCHGD((*paramchgd)), SCIP_PARAMDATA *paramdata)
SCIP_RETCODE SCIPaddBoolParam(SCIP *scip, const char *name, const char *desc, SCIP_Bool *valueptr, SCIP_Bool isadvanced, SCIP_Bool defaultvalue, SCIP_DECL_PARAMCHGD((*paramchgd)), SCIP_PARAMDATA *paramdata)
void SCIPconshdlrSetData(SCIP_CONSHDLR *conshdlr, SCIP_CONSHDLRDATA *conshdlrdata)
SCIP_RETCODE SCIPsetConshdlrFree(SCIP *scip, SCIP_CONSHDLR *conshdlr,)
SCIP_RETCODE SCIPsetConshdlrEnforelax(SCIP *scip, SCIP_CONSHDLR *conshdlr,)
SCIP_RETCODE SCIPincludeConshdlrBasic(SCIP *scip, SCIP_CONSHDLR **conshdlrptr, const char *name, const char *desc, int enfopriority, int chckpriority, int eagerfreq, SCIP_Bool needscons, SCIP_DECL_CONSENFOLP((*consenfolp)), SCIP_DECL_CONSENFOPS((*consenfops)), SCIP_DECL_CONSCHECK((*conscheck)), SCIP_DECL_CONSLOCK((*conslock)), SCIP_CONSHDLRDATA *conshdlrdata)
void SCIPconshdlrMarkExact(SCIP_CONSHDLR *conshdlr)
const char * SCIPconshdlrGetName(SCIP_CONSHDLR *conshdlr)
SCIP_Bool SCIPconshdlrNeedsCons(SCIP_CONSHDLR *conshdlr)
SCIP_RETCODE SCIPsetConshdlrCopy(SCIP *scip, SCIP_CONSHDLR *conshdlr, SCIP_DECL_CONSHDLRCOPY((*conshdlrcopy)),)
SCIP_CONSHDLR * SCIPfindConshdlr(SCIP *scip, const char *name)
void SCIPconshdlrSetNeedsCons(SCIP_CONSHDLR *conshdlr, SCIP_Bool needscons)
SCIP_RETCODE SCIPsetConshdlrInit(SCIP *scip, SCIP_CONSHDLR *conshdlr,)
SCIP_CONSHDLRDATA * SCIPconshdlrGetData(SCIP_CONSHDLR *conshdlr)
SCIP_RETCODE SCIPsetConshdlrExit(SCIP *scip, SCIP_CONSHDLR *conshdlr,)
SCIP_CONSHDLR * SCIPconsGetHdlr(SCIP_CONS *cons)
SCIP_Bool SCIPisExact(SCIP *scip)
const char * SCIPheurGetName(SCIP_HEUR *heur)
SCIP_RETCODE SCIPchgVarLbDive(SCIP *scip, SCIP_VAR *var, SCIP_Real newbound)
SCIP_RETCODE SCIPchgVarUbDive(SCIP *scip, SCIP_VAR *var, SCIP_Real newbound)
SCIP_Bool SCIPinDive(SCIP *scip)
SCIP_RETCODE SCIPsolveExactDiveLP(SCIP *scip, int itlim, SCIP_Bool *lperror, SCIP_Bool *cutoff)
SCIP_Bool SCIPisExactDivePossible(SCIP *scip)
SCIP_RETCODE SCIPchgVarLbExactDive(SCIP *scip, SCIP_VAR *var, SCIP_RATIONAL *newbound)
SCIP_LPSOLSTAT SCIPgetLPExactSolstat(SCIP *scip)
SCIP_RETCODE SCIPstartExactDive(SCIP *scip)
SCIP_RETCODE SCIPendExactDive(SCIP *scip)
SCIP_RETCODE SCIPchgVarUbExactDive(SCIP *scip, SCIP_VAR *var, SCIP_RATIONAL *newbound)
SCIP_Bool SCIPinExactDive(SCIP *scip)
SCIP_RETCODE SCIPflushLP(SCIP *scip)
SCIP_Bool SCIPhasCurrentNodeLP(SCIP *scip)
SCIP_RETCODE SCIPconstructLP(SCIP *scip, SCIP_Bool *cutoff)
SCIP_Bool SCIPisLPConstructed(SCIP *scip)
#define SCIPfreeBlockMemoryArray(scip, ptr, num)
BMS_BLKMEM * SCIPblkmem(SCIP *scip)
#define SCIPallocClearBlockMemoryArray(scip, ptr, num)
BMS_BUFMEM * SCIPbuffer(SCIP *scip)
#define SCIPallocBlockMemoryArray(scip, ptr, num)
#define SCIPreallocBlockMemoryArray(scip, ptr, oldnum, newnum)
#define SCIPfreeBlockMemory(scip, ptr)
#define SCIPallocBlockMemory(scip, ptr)
SCIP_NODETYPE SCIPnodeGetType(SCIP_NODE *node)
void SCIPrationalRoundInteger(SCIP_RATIONAL *res, SCIP_RATIONAL *src, SCIP_ROUNDMODE_RAT roundmode)
void SCIPrationalSetReal(SCIP_RATIONAL *res, SCIP_Real real)
void SCIPrationalFreeBuffer(BMS_BUFMEM *bufmem, SCIP_RATIONAL **rational)
SCIP_RETCODE SCIPrationalCreateBuffer(BMS_BUFMEM *bufmem, SCIP_RATIONAL **rational)
SCIP_Bool SCIPrationalIsEQ(SCIP_RATIONAL *rat1, SCIP_RATIONAL *rat2)
SCIP_Bool SCIPrationalIsLE(SCIP_RATIONAL *rat1, SCIP_RATIONAL *rat2)
SCIP_Real SCIProwGetLhs(SCIP_ROW *row)
SCIP_Real SCIProwGetRhs(SCIP_ROW *row)
SCIP_Real SCIPgetRowSolActivity(SCIP *scip, SCIP_ROW *row, SCIP_SOL *sol)
SCIP_RETCODE SCIPcreateSolCopy(SCIP *scip, SCIP_SOL **sol, SCIP_SOL *sourcesol)
SCIP_RETCODE SCIPprintSol(SCIP *scip, SCIP_SOL *sol, FILE *file, SCIP_Bool printzeros)
SCIP_RETCODE SCIPtrySolFreeExact(SCIP *scip, SCIP_SOL **sol, SCIP_Bool printreason, SCIP_Bool completely, SCIP_Bool checkbounds, SCIP_Bool checkintegrality, SCIP_Bool checklprows, SCIP_Bool *stored)
SCIP_RETCODE SCIPoverwriteFPsol(SCIP *scip, SCIP_SOL *sol)
SCIP_HEUR * SCIPsolGetHeur(SCIP_SOL *sol)
SCIP_RETCODE SCIPunlinkSol(SCIP *scip, SCIP_SOL *sol)
SCIP_RETCODE SCIPcreateLPSolExact(SCIP *scip, SCIP_SOL **sol, SCIP_HEUR *heur)
SCIP_SOLTYPE SCIPsolGetType(SCIP_SOL *sol)
SCIP_Real SCIPgetSolVal(SCIP *scip, SCIP_SOL *sol, SCIP_VAR *var)
SCIP_Real SCIPgetSolTransObj(SCIP *scip, SCIP_SOL *sol)
void SCIPsolSetHeur(SCIP_SOL *sol, SCIP_HEUR *heur)
SCIP_Bool SCIPsolIsExact(SCIP_SOL *sol)
SCIP_Real SCIPgetUpperbound(SCIP *scip)
SCIP_Real SCIPround(SCIP *scip, SCIP_Real val)
SCIP_Bool SCIPisFeasLT(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_Bool SCIPisFeasGT(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_Bool SCIPisLT(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_NODE * SCIPgetCurrentNode(SCIP *scip)
SCIP_VARTYPE SCIPvarGetType(SCIP_VAR *var)
SCIP_Real SCIPvarGetUbGlobal(SCIP_VAR *var)
SCIP_VARSTATUS SCIPvarGetStatusExact(SCIP_VAR *var)
int SCIPvarGetIndex(SCIP_VAR *var)
SCIP_RATIONAL * SCIPvarGetUbLocalExact(SCIP_VAR *var)
SCIP_Bool SCIPvarIsIntegral(SCIP_VAR *var)
SCIP_RATIONAL * SCIPvarGetLbGlobalExact(SCIP_VAR *var)
SCIP_Real SCIPvarGetLbGlobal(SCIP_VAR *var)
SCIP_RATIONAL * SCIPvarGetLbLocalExact(SCIP_VAR *var)
SCIP_IMPLINTTYPE SCIPvarGetImplType(SCIP_VAR *var)
SCIP_RATIONAL * SCIPvarGetUbGlobalExact(SCIP_VAR *var)
void SCIPsortPtr(void **ptrarray, SCIP_DECL_SORTPTRCOMP((*ptrcomp)), int len)
SCIPfreeSol(scip, &heurdata->sol))
assert(minobj< SCIPgetCutoffbound(scip))
SCIP_RATIONAL * SCIPconsGetRhsExact(SCIP *scip, SCIP_CONS *cons, SCIP_Bool *success)
SCIP_RATIONAL * SCIPconsGetLhsExact(SCIP *scip, SCIP_CONS *cons, SCIP_Bool *success)
SCIP_ROW * SCIPconsGetRow(SCIP *scip, SCIP_CONS *cons)
public methods for managing constraints
public methods for primal heuristics
public methods for LP management
public methods for LP management
public methods for message output
public data structures and miscellaneous methods
public methods for primal CIP solutions
public methods for problem variables
wrapper for rational number arithmetic
public methods for certified solving
public methods for constraint handler plugins and constraints
public methods for exact solving
public methods for the LP relaxation, rows and columns
public methods for the LP relaxation, rows and columns
public methods for memory management
public methods for message handling
public methods for numerical tolerances
public methods for SCIP parameter handling
public methods for global and local (sub)problems
public methods for querying solving statistics
public methods for the branch-and-bound tree
internal methods for global SCIP settings
#define SCIP_DECL_CONSENFOLP(x)
struct SCIP_Cons SCIP_CONS
#define SCIP_DECL_CONSEXIT(x)
struct SCIP_ConshdlrData SCIP_CONSHDLRDATA
#define SCIP_DECL_CONSENFORELAX(x)
#define SCIP_DECL_CONSENFOPS(x)
#define SCIP_DECL_CONSLOCK(x)
struct SCIP_Conshdlr SCIP_CONSHDLR
#define SCIP_DECL_CONSINIT(x)
#define SCIP_DECL_CONSCHECK(x)
#define SCIP_DECL_CONSHDLRCOPY(x)
#define SCIP_DECL_CONSFREE(x)
#define SCIP_DECL_HASHKEYEQ(x)
#define SCIP_DECL_HASHGETKEY(x)
#define SCIP_DECL_HASHKEYVAL(x)
struct SCIP_HashTable SCIP_HASHTABLE
struct SCIP_Rational SCIP_RATIONAL
enum SCIP_Retcode SCIP_RETCODE
@ SCIP_NODETYPE_FOCUSNODE
@ SCIP_VARTYPE_CONTINUOUS