/** includes event handler for best solution found */ SCIP_RETCODE SCIPincludeEventHdlrSofttimelimit( SCIP* scip /**< SCIP data structure */ ) { SCIP_EVENTHDLRDATA* eventhdlrdata; SCIP_EVENTHDLR* eventhdlr; SCIP_CALL( SCIPallocMemory(scip, &eventhdlrdata) ); eventhdlrdata->filterpos = -1; eventhdlr = NULL; /* create event handler for events on watched variables */ SCIP_CALL( SCIPincludeEventhdlrBasic(scip, &eventhdlr, EVENTHDLR_NAME, EVENTHDLR_DESC, eventExecSofttimelimit, eventhdlrdata) ); assert(eventhdlr != NULL); SCIP_CALL( SCIPsetEventhdlrCopy(scip, eventhdlr, eventCopySofttimelimit) ); SCIP_CALL( SCIPsetEventhdlrFree(scip, eventhdlr, eventFreeSofttimelimit) ); SCIP_CALL( SCIPsetEventhdlrInit(scip, eventhdlr, eventInitSofttimelimit) ); SCIP_CALL( SCIPsetEventhdlrExit(scip, eventhdlr, eventExitSofttimelimit) ); SCIP_CALL( SCIPaddRealParam(scip, "limits/softtime", "soft time limit which should be applied after first solution was found", &eventhdlrdata->softtimelimit, FALSE, -1.0, -1.0, SCIP_REAL_MAX, NULL, NULL) ); return SCIP_OKAY; }
/** creates the distributiondiving heuristic and includes it in SCIP */ SCIP_RETCODE SCIPincludeHeurDistributiondiving( SCIP* scip /**< SCIP data structure */ ) { SCIP_HEURDATA* heurdata; SCIP_HEUR* heur; SCIP_EVENTHDLRDATA* eventhdlrdata; /* create distributiondiving data */ heurdata = NULL; SCIP_CALL( SCIPallocMemory(scip, &heurdata) ); heurdata->memsize = 0; heurdata->rowmeans = NULL; heurdata->rowvariances = NULL; heurdata->rowinfinitiesdown = NULL; heurdata->rowinfinitiesup = NULL; heurdata->varfilterposs = NULL; heurdata->currentlbs = NULL; heurdata->currentubs = NULL; /* create event handler first to finish heuristic data */ eventhdlrdata = NULL; SCIP_CALL( SCIPallocMemory(scip, &eventhdlrdata) ); eventhdlrdata->heurdata = heurdata; heurdata->eventhdlr = NULL; SCIP_CALL( SCIPincludeEventhdlrBasic(scip, &heurdata->eventhdlr, EVENTHDLR_NAME, "event handler for dynamic acitivity distribution updating", eventExecDistribution, eventhdlrdata) ); assert( heurdata->eventhdlr != NULL); SCIP_CALL( SCIPsetEventhdlrFree(scip, heurdata->eventhdlr, eventFreeDistributiondiving) ); /* include primal heuristic */ SCIP_CALL( SCIPincludeHeurBasic(scip, &heur, HEUR_NAME, HEUR_DESC, HEUR_DISPCHAR, HEUR_PRIORITY, HEUR_FREQ, HEUR_FREQOFS, HEUR_MAXDEPTH, HEUR_TIMING, HEUR_USESSUBSCIP, heurExecDistributiondiving, heurdata) ); assert(heur != NULL); /* set non-NULL pointers to callback methods */ SCIP_CALL( SCIPsetHeurCopy(scip, heur, heurCopyDistributiondiving) ); SCIP_CALL( SCIPsetHeurFree(scip, heur, heurFreeDistributiondiving) ); SCIP_CALL( SCIPsetHeurInit(scip, heur, heurInitDistributiondiving) ); SCIP_CALL( SCIPsetHeurExit(scip, heur, heurExitDistributiondiving) ); SCIP_CALL( SCIPcreateDiveset(scip, NULL, heur, HEUR_NAME, DEFAULT_MINRELDEPTH, DEFAULT_MAXRELDEPTH, DEFAULT_MAXLPITERQUOT, DEFAULT_MAXDIVEUBQUOT, DEFAULT_MAXDIVEAVGQUOT, DEFAULT_MAXDIVEUBQUOTNOSOL, DEFAULT_MAXDIVEAVGQUOTNOSOL, DEFAULT_LPRESOLVEDOMCHGQUOT, DEFAULT_LPSOLVEFREQ, DEFAULT_MAXLPITEROFS, DEFAULT_BACKTRACK, DEFAULT_ONLYLPBRANCHCANDS, DIVESET_DIVETYPES, divesetGetScoreDistributiondiving) ); SCIP_CALL( SCIPaddCharParam(scip, "heuristics/" HEUR_NAME "/scoreparam", "the score;largest 'd'ifference, 'l'owest cumulative probability,'h'ighest c.p., 'v'otes lowest c.p., votes highest c.p.('w'), 'r'evolving", &heurdata->scoreparam, TRUE, DEFAULT_SCOREPARAM, "lvdhwr", NULL, NULL) ); return SCIP_OKAY; }
/** includes event handler for writing primal- and dualbound for all open nodes */ SCIP_RETCODE SCIPincludeEventHdlrBoundwriting( SCIP* scip /**< SCIP data structure */ ) { SCIP_EVENTHDLRDATA* eventhdlrdata; SCIP_EVENTHDLR* eventhdlr; /* create bounds reader data */ SCIP_CALL( SCIPallocMemory(scip, &eventhdlrdata) ); initEventhdlrdata(eventhdlrdata); eventhdlr = NULL; /* create event handler for events on watched variables */ SCIP_CALL( SCIPincludeEventhdlrBasic(scip, &eventhdlr, EVENTHDLR_NAME, EVENTHDLR_DESC, eventExecBoundwriting, eventhdlrdata) ); assert(eventhdlr != NULL); SCIP_CALL( SCIPsetEventhdlrCopy(scip, eventhdlr, eventCopyBoundwriting) ); SCIP_CALL( SCIPsetEventhdlrFree(scip, eventhdlr, eventFreeBoundwriting) ); SCIP_CALL( SCIPsetEventhdlrInit(scip, eventhdlr, eventInitBoundwriting) ); SCIP_CALL( SCIPsetEventhdlrExit(scip, eventhdlr, eventExitBoundwriting) ); /* add boundwriting parameters */ SCIP_CALL( SCIPaddLongintParam(scip, "eventhdlr/"EVENTHDLR_NAME"/freq", "in which frequency should all bounds be written(0: never)", &eventhdlrdata->freq, FALSE, DEFAULT_FREQ, 0LL, SCIP_LONGINT_MAX, NULL, NULL) ); SCIP_CALL( SCIPaddStringParam(scip, "eventhdlr/"EVENTHDLR_NAME"/filename", "filename to write all bounds to", &eventhdlrdata->filename, FALSE, DEFAULT_FILENAME, NULL, NULL) ); SCIP_CALL( SCIPaddBoolParam(scip, "eventhdlr/"EVENTHDLR_NAME"/writesubmipdualbound", "should the dualbound of the submip-root which was created out of an open node be printed", &eventhdlrdata->writesubmipdualbound, FALSE, DEFAULT_WRITESUBMIPDUALBOUND, NULL, NULL) ); return SCIP_OKAY; }