assert(violrows !=
NULL);
100assert(violrowpos !=
NULL);
101assert(nviolrows !=
NULL);
128 if( oldviol != newviol )
139violpos = violrowpos[rowpos];
140assert(0 <= violpos && violpos < *nviolrows);
141assert(violrows[violpos] == row);
142violrowpos[rowpos] = -1;
145 if( nfracsinrow[rowpos] > 0 )
147assert(violpos < *nviolfracrows);
150 if( violpos != *nviolfracrows - 1 )
152violrows[violpos] = violrows[*nviolfracrows - 1];
154violpos = *nviolfracrows - 1;
159assert(violpos >= *nviolfracrows);
162 if( violpos != *nviolrows - 1 )
164violrows[violpos] = violrows[*nviolrows - 1];
172assert(violrowpos[rowpos] == -1);
173violrows[*nviolrows] = row;
174violrowpos[rowpos] = *nviolrows;
180 if( nfracsinrow[rowpos] > 0 )
182 if( *nviolfracrows < *nviolrows - 1 )
186violrows[*nviolrows - 1] = violrows[*nviolfracrows];
187violrowpos[
SCIProwGetLPPos(violrows[*nviolrows - 1])] = *nviolrows - 1;
189violrows[*nviolfracrows] = row;
190violrowpos[rowpos] = *nviolfracrows;
221assert(activities !=
NULL);
222assert(nviolrows !=
NULL);
223assert(0 <= *nviolrows && *nviolrows <= nlprows);
225delta = newsolval - oldsolval;
230assert(ncolrows == 0 || (colrows !=
NULL&& colvals !=
NULL));
232 for(
r= 0;
r< ncolrows; ++
r)
239assert(-1 <= rowpos && rowpos < nlprows);
249oldactivity = activities[rowpos];
252newactivity = oldactivity + delta * colvals[
r];
257activities[rowpos] = newactivity;
260 updateViolations(
scip, row, violrows, violrowpos, nviolrows, nviolfracrows, nfracsinrow, oldactivity, newactivity);
297assert(direction == +1 || direction == -1);
298assert(nincreases !=
NULL);
299assert(ndecreases !=
NULL);
300assert(shiftvar !=
NULL);
301assert(oldsolval !=
NULL);
302assert(newsolval !=
NULL);
320 for( c = 0; c < nrowcols; ++c )
340increase = (direction * val > 0.0);
352shiftscore = ndecreases[probindex]/increaseweight;
354shiftscore = nincreases[probindex]/increaseweight;
359 if( shiftscore <= bestshiftscore )
366assert(direction * val < 0.0);
373assert(activitydelta/val < 0.0);
374shiftval = solval + activitydelta/val;
375assert(shiftval <= solval);
379shiftval =
MAX(shiftval, lb);
385assert(direction * val > 0.0);
392assert(activitydelta/val > 0.0);
393shiftval = solval + activitydelta/val;
394assert(shiftval >= solval);
398shiftval =
MIN(shiftval, ub);
408 if( shiftscore < bestshiftscore || deltaobj < bestdeltaobj )
410bestshiftscore = shiftscore;
411bestdeltaobj = deltaobj;
414*newsolval = shiftval;
449assert(shiftvar !=
NULL);
450assert(oldsolval !=
NULL);
451assert(newsolval !=
NULL);
457 for( v = 0; v < nlpcands; ++v )
469 if( nlocks >= maxnlocks )
472deltaobj = obj * (shiftval - solval);
476bestdeltaobj = deltaobj;
479*newsolval = shiftval;
485 if( nlocks >= maxnlocks )
488deltaobj = obj * (shiftval - solval);
492bestdeltaobj = deltaobj;
495*newsolval = shiftval;
523assert(nviolrows >= *nviolfracrows);
527 for(
r= 0;
r< nrows; ++
r)
533assert(0 <= rowlppos && rowlppos < nlprows);
540nfracsinrow[rowlppos] += incval;
541assert(nfracsinrow[rowlppos] >= 0);
542theviolrowpos = violrowpos[rowlppos];
545 if( theviolrowpos >= 0 )
550 if( nfracsinrow[rowlppos] == 0 )
552assert(theviolrowpos <= *nviolfracrows - 1);
556 if( theviolrowpos < *nviolfracrows - 1 )
558violrows[theviolrowpos] = violrows[*nviolfracrows - 1];
559violrows[*nviolfracrows - 1] = rows[
r];
561violrowpos[
SCIProwGetLPPos(violrows[theviolrowpos])] = theviolrowpos;
562violrowpos[rowlppos] = *nviolfracrows - 1;
569 else if( nfracsinrow[rowlppos] == incval )
571assert(theviolrowpos >= *nviolfracrows);
574 if( theviolrowpos > *nviolfracrows )
576violrows[theviolrowpos] = violrows[*nviolfracrows];
577violrows[*nviolfracrows] = rows[
r];
579violrowpos[
SCIProwGetLPPos(violrows[theviolrowpos])] = theviolrowpos;
580violrowpos[rowlppos] = *nviolfracrows;
598assert(heur !=
NULL);
620heurdata->lastlp = -1;
641assert(heurdata !=
NULL);
662assert(heurdata !=
NULL);
663heurdata->lastlp = -1;
696 intnnonimprovingshifts;
706assert(result !=
NULL);
721assert(heurdata !=
NULL);
725 if( nlps == heurdata->lastlp )
727heurdata->lastlp = nlps;
733 if(
nnodes% ((ncalls/100)/(nsolsfound+1)+1) != 0 )
750 SCIPdebugMsg(
scip,
"executing shifting heuristic: %d LP rows, %d fractionals\n", nlprows, nfrac);
768 for(
r= 0;
r< nlprows; ++
r)
781violrows[nviolrows] = row;
782violrowpos[
r] = nviolrows;
786violrowpos[
r] = -1;
789violrowpos[
r] = -1;
794 for( c = 0; c < nlpcands; ++c )
795 addFracCounter(nfracsinrow, violrows, violrowpos, &nviolfracrows, nviolrows, nlprows, lpcands[c], +1);
799assert(sol !=
NULL);
807 for( c = 0; c < nlpcands; ++c )
811minobj += obj * (bestshiftval - lpcandssol[c]);
815nnonimprovingshifts = 0;
816minnviolrows = INT_MAX;
817increaseweight = 1.0;
818 while( (nfrac > 0 || nviolrows > 0) && nnonimprovingshifts <
MAXSHIFTINGS)
826 SCIPdebugMsg(
scip,
"shifting heuristic: nfrac=%d, nviolrows=%d, obj=%g (best possible obj: %g), cutoff=%g\n",
830nprevviolrows = nviolrows;
839 if( nviolrows > 0 && (nfrac == 0 || nnonimprovingshifts <
MAXSHIFTINGS-1) )
846assert(nviolfracrows == 0 || nfrac > 0);
850 if( nviolfracrows > 0 )
851rowidx = nviolfracrows - 1;
856assert(0 <= rowidx && rowidx < nviolrows);
857row = violrows[rowidx];
859assert(0 <= rowpos && rowpos < nlprows);
860assert(violrowpos[rowpos] == rowidx);
861assert(nfracsinrow[rowpos] == 0 || rowidx == nviolfracrows - 1);
863 SCIPdebugMsg(
scip,
"shifting heuristic: try to fix violated row <%s>: %g <= %g <= %g\n",
874nincreases, ndecreases, increaseweight, &shiftvar, &oldsolval, &newsolval) );
877 if( shiftvar ==
NULL&& nfrac > 0 )
879 SCIPdebugMsg(
scip,
"shifting heuristic: search rounding variable and try to stay feasible\n");
886 SCIPdebugMsg(
scip,
"shifting heuristic: -> didn't find a shifting variable\n");
890 SCIPdebugMsg(
scip,
"shifting heuristic: -> shift var <%s>[%g,%g], type=%d, oldval=%g, newval=%g, obj=%g\n",
896shiftvar, oldsolval, newsolval) );
897 if( nviolrows >= nprevviolrows )
898nnonimprovingshifts++;
899 else if( nviolrows < minnviolrows )
901minnviolrows = nviolrows;
902nnonimprovingshifts = 0;
917nnonimprovingshifts = 0;
918minnviolrows = INT_MAX;
919 addFracCounter(nfracsinrow, violrows, violrowpos, &nviolfracrows, nviolrows, nlprows, shiftvar, -1);
922 if( obj > 0.0 && newsolval > oldsolval )
924 else if( obj < 0.0 && newsolval < oldsolval )
930minobj += obj * (newsolval - oldsolval);
934 if( !oldsolvalisfrac )
937assert(0 <= probindex && probindex < nvars);
939 if( newsolval < oldsolval )
940ndecreases[probindex] += increaseweight;
942nincreases[probindex] += increaseweight;
943 if( increaseweight >= 1e+09 )
947 for( i = 0; i < nvars; ++i )
949nincreases[i] /= increaseweight;
950ndecreases[i] /= increaseweight;
952increaseweight = 1.0;
956 SCIPdebugMsg(
scip,
"shifting heuristic: -> nfrac=%d, nviolrows=%d, obj=%g (best possible obj: %g)\n",
961 if( nfrac == 0 && nviolrows == 0 )
1008assert(heur !=
NULL);
int SCIPgetNVars(SCIP *scip)
SCIP_RETCODE SCIPincludeHeurShifting(SCIP *scip)
SCIP_RETCODE SCIPgetLPBranchCands(SCIP *scip, SCIP_VAR ***lpcands, SCIP_Real **lpcandssol, SCIP_Real **lpcandsfrac, int *nlpcands, int *npriolpcands, int *nfracimplvars)
SCIP_VAR * SCIPcolGetVar(SCIP_COL *col)
SCIP_Real * SCIPcolGetVals(SCIP_COL *col)
SCIP_ROW ** SCIPcolGetRows(SCIP_COL *col)
int SCIPcolGetNLPNonz(SCIP_COL *col)
SCIP_RETCODE SCIPsetHeurCopy(SCIP *scip, SCIP_HEUR *heur, SCIP_DECL_HEURCOPY((*heurcopy)))
SCIP_HEURDATA * SCIPheurGetData(SCIP_HEUR *heur)
SCIP_RETCODE SCIPincludeHeurBasic(SCIP *scip, SCIP_HEUR **heur, const char *name, const char *desc, char dispchar, int priority, int freq, int freqofs, int maxdepth, SCIP_HEURTIMING timingmask, SCIP_Bool usessubscip, SCIP_DECL_HEUREXEC((*heurexec)), SCIP_HEURDATA *heurdata)
SCIP_Longint SCIPheurGetNSolsFound(SCIP_HEUR *heur)
SCIP_RETCODE SCIPsetHeurExit(SCIP *scip, SCIP_HEUR *heur, SCIP_DECL_HEUREXIT((*heurexit)))
SCIP_Longint SCIPheurGetNBestSolsFound(SCIP_HEUR *heur)
SCIP_Longint SCIPheurGetNCalls(SCIP_HEUR *heur)
SCIP_RETCODE SCIPsetHeurInitsol(SCIP *scip, SCIP_HEUR *heur, SCIP_DECL_HEURINITSOL((*heurinitsol)))
SCIP_RETCODE SCIPsetHeurInit(SCIP *scip, SCIP_HEUR *heur, SCIP_DECL_HEURINIT((*heurinit)))
const char * SCIPheurGetName(SCIP_HEUR *heur)
void SCIPheurSetData(SCIP_HEUR *heur, SCIP_HEURDATA *heurdata)
SCIP_Bool SCIPhasCurrentNodeLP(SCIP *scip)
SCIP_RETCODE SCIPgetLPRowsData(SCIP *scip, SCIP_ROW ***rows, int *nrows)
SCIP_LPSOLSTAT SCIPgetLPSolstat(SCIP *scip)
SCIP_Real SCIPgetLPObjval(SCIP *scip)
#define SCIPallocBufferArray(scip, ptr, num)
#define SCIPfreeBufferArray(scip, ptr)
#define SCIPfreeBlockMemory(scip, ptr)
#define SCIPallocBlockMemory(scip, ptr)
SCIP_Real SCIProwGetLhs(SCIP_ROW *row)
SCIP_COL ** SCIProwGetCols(SCIP_ROW *row)
SCIP_Real SCIProwGetRhs(SCIP_ROW *row)
int SCIProwGetNLPNonz(SCIP_ROW *row)
int SCIProwGetLPPos(SCIP_ROW *row)
SCIP_Bool SCIProwIsLocal(SCIP_ROW *row)
SCIP_RETCODE SCIPprintRow(SCIP *scip, SCIP_ROW *row, FILE *file)
const char * SCIProwGetName(SCIP_ROW *row)
SCIP_Real SCIPgetRowActivity(SCIP *scip, SCIP_ROW *row)
SCIP_Bool SCIProwIsInLP(SCIP_ROW *row)
SCIP_Real * SCIProwGetVals(SCIP_ROW *row)
SCIP_RETCODE SCIPcreateSol(SCIP *scip, SCIP_SOL **sol, SCIP_HEUR *heur)
SCIP_RETCODE SCIPfreeSol(SCIP *scip, SCIP_SOL **sol)
SCIP_RETCODE SCIPprintSol(SCIP *scip, SCIP_SOL *sol, FILE *file, SCIP_Bool printzeros)
SCIP_RETCODE SCIPtrySol(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 SCIPlinkLPSol(SCIP *scip, SCIP_SOL *sol)
SCIP_Real SCIPgetSolOrigObj(SCIP *scip, SCIP_SOL *sol)
SCIP_RETCODE SCIPsetSolVal(SCIP *scip, SCIP_SOL *sol, SCIP_VAR *var, SCIP_Real val)
SCIP_Real SCIPgetSolVal(SCIP *scip, SCIP_SOL *sol, SCIP_VAR *var)
SCIP_Real SCIPgetSolTransObj(SCIP *scip, SCIP_SOL *sol)
SCIP_Real SCIPretransformObj(SCIP *scip, SCIP_Real obj)
SCIP_Longint SCIPgetNNodes(SCIP *scip)
SCIP_Longint SCIPgetNLPs(SCIP *scip)
SCIP_Real SCIPgetCutoffbound(SCIP *scip)
SCIP_Real SCIPinfinity(SCIP *scip)
SCIP_Bool SCIPisGE(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_Bool SCIPisPositive(SCIP *scip, SCIP_Real val)
SCIP_Real SCIPfeasCeil(SCIP *scip, SCIP_Real val)
SCIP_Real SCIPfeasFloor(SCIP *scip, SCIP_Real val)
SCIP_Bool SCIPisInfinity(SCIP *scip, SCIP_Real val)
SCIP_Bool SCIPisFeasLT(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_Bool SCIPisFeasIntegral(SCIP *scip, SCIP_Real val)
SCIP_Bool SCIPisNegative(SCIP *scip, SCIP_Real val)
SCIP_Bool SCIPisFeasGT(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_Bool SCIPisEQ(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_Bool SCIPisZero(SCIP *scip, SCIP_Real val)
SCIP_COL * SCIPvarGetCol(SCIP_VAR *var)
int SCIPvarGetNLocksUpType(SCIP_VAR *var, SCIP_LOCKTYPE locktype)
SCIP_Real SCIPvarGetObj(SCIP_VAR *var)
SCIP_VARTYPE SCIPvarGetType(SCIP_VAR *var)
SCIP_Real SCIPvarGetUbGlobal(SCIP_VAR *var)
int SCIPvarGetProbindex(SCIP_VAR *var)
const char * SCIPvarGetName(SCIP_VAR *var)
SCIP_Bool SCIPvarIsIntegral(SCIP_VAR *var)
SCIP_Real SCIPvarGetLbGlobal(SCIP_VAR *var)
int SCIPvarGetNLocksDownType(SCIP_VAR *var, SCIP_LOCKTYPE locktype)
void SCIPfreeRandom(SCIP *scip, SCIP_RANDNUMGEN **randnumgen)
int SCIPrandomGetInt(SCIP_RANDNUMGEN *randnumgen, int minrandval, int maxrandval)
SCIP_RETCODE SCIPcreateRandom(SCIP *scip, SCIP_RANDNUMGEN **randnumgen, unsigned int initialseed, SCIP_Bool useglobalseed)
static SCIP_RETCODE selectEssentialRounding(SCIP *scip, SCIP_SOL *sol, SCIP_Real minobj, SCIP_VAR **lpcands, int nlpcands, SCIP_VAR **shiftvar, SCIP_Real *oldsolval, SCIP_Real *newsolval)
static SCIP_DECL_HEURINITSOL(heurInitsolShifting)
static void addFracCounter(int *nfracsinrow, SCIP_ROW **violrows, int *violrowpos, int *nviolfracrows, int nviolrows, int nlprows, SCIP_VAR *var, int incval)
static SCIP_DECL_HEUREXIT(heurExitShifting)
static SCIP_DECL_HEUREXEC(heurExecShifting)
static SCIP_DECL_HEURCOPY(heurCopyShifting)
static SCIP_RETCODE updateActivities(SCIP *scip, SCIP_Real *activities, SCIP_ROW **violrows, int *violrowpos, int *nviolrows, int *nviolfracrows, int *nfracsinrow, int nlprows, SCIP_VAR *var, SCIP_Real oldsolval, SCIP_Real newsolval)
static void updateViolations(SCIP *scip, SCIP_ROW *row, SCIP_ROW **violrows, int *violrowpos, int *nviolrows, int *nviolfracrows, int *nfracsinrow, SCIP_Real oldactivity, SCIP_Real newactivity)
static SCIP_DECL_HEURINIT(heurInitShifting)
static SCIP_RETCODE selectShifting(SCIP *scip, SCIP_SOL *sol, SCIP_ROW *row, SCIP_Real rowactivity, int direction, SCIP_Real *nincreases, SCIP_Real *ndecreases, SCIP_Real increaseweight, SCIP_VAR **shiftvar, SCIP_Real *oldsolval, SCIP_Real *newsolval)
LP rounding heuristic that tries to recover from intermediate infeasibilities and shifts continuous v...
memory allocation routines
#define BMSclearMemoryArray(ptr, num)
public methods for primal heuristics
public methods for LP management
public methods for message output
public data structures and miscellaneous methods
public methods for problem variables
public methods for branching rule plugins and branching
public methods for primal heuristic plugins and divesets
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 global and local (sub)problems
public methods for random numbers
public methods for solutions
public methods for querying solving statistics
struct SCIP_HeurData SCIP_HEURDATA
enum SCIP_Retcode SCIP_RETCODE
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4