lasteffectrootdepth;
71 for( c = 0; c < ncluster; ++c )
73c2 = ( c + 1 ) % ncluster;
74objective += qmatrix[c][c2] - qmatrix[c2][c];
75objective += scale * qmatrix[c][c];
97 for( k = 0; k < ncluster; ++k )
99 for( l = 0; l < ncluster; ++l )
103 for( i = 0; i < nbins; ++i )
105 for( j = 0; j < nbins; ++j )
108 if( clusterassignment[i][k] < 1 || clusterassignment[j][l] < 1 )
111qmatrix[k][l] += cmatrix[i][j];
135 for( cluster = 0; cluster < ncluster; ++cluster )
137 for( bin = 0; bin < nbins; ++bin )
141 if( clusterassignment[bin][cluster] == 1 )
144 if( cluster != newcluster )
146qmatrix[newcluster][cluster] += temp * cmatrix[newbin][bin];
147qmatrix[cluster][newcluster] += temp * cmatrix[bin][newbin];
152qmatrix[newcluster][newcluster] += cmatrix[newbin][bin];
154qmatrix[newcluster][newcluster] += (cmatrix[newbin][bin] + cmatrix[bin][newbin]) * temp;
182 for( i = 0; i < nbins; ++i )
184temp = (clusterassignment[i][
phiinv(newcluster, ncluster)] < 1 ? 0 : 1);
185obj += (cmatrix[i][newbin] - cmatrix[newbin][i]) * temp;
186temp = (clusterassignment[i][
phi(newcluster, ncluster)] < 1 ? 0 : 1);
187obj -= (cmatrix[i][newbin] - cmatrix[newbin][i]) * temp;
188temp = (clusterassignment[i][newcluster] < 1 ? 0 : 1);
189obj += (cmatrix[i][newbin] + cmatrix[newbin][i]) * temp;
206 int* amountassigned,
228 for( i = 0; i < nbins; ++i )
234 for( c = 0; c < ncluster; ++c )
238 if( binsincluster[c] == 0 )
240 for( i = 0; i < nbins; ++i )
247binobjective[i] =
getTempObj(
scip, qmatrix, cmatrix, clusterassignment, i, c, nbins, ncluster);
249 if( binobjective[i] > tempobj )
252tempobj = binobjective[i];
261 for( c1 = 0; c1 < ncluster; ++c1 )
263clusterassignment[save][c1] = 0;
266clusterassignment[save][c] = 1;
269assert(binsincluster[c] == 1);
271isassigned[save] =
TRUE;
272*amountassigned += 1;
275 updateIrrevMat(clusterassignment, qmatrix, cmatrix, save, c, nbins, ncluster);
280 for( i = 0; i < nbins; ++i )
286 for( i = 0; i < nbins; ++i )
292 for( c1 = 0; c1 < ncluster; ++c1 )
295 if( 0 != clusterassignment[i][c1] )
296clusterispossible[i][c1] =
TRUE;
298clusterispossible[i][c1] =
FALSE;
302 for( c2 = 0; c2 < ncluster; ++c2 )
304 if( !clusterispossible[i][c2] || clusterassignment[i][c2] == 0 )
308save = (int) clusterassignment[i][c2];
309clusterassignment[i][c2] = 1;
312tempobj =
getTempObj(
scip, qmatrix, cmatrix, clusterassignment, i, c2, nbins, ncluster);
317binobjective[i] = tempobj;
321clusterassignment[i][c2] = save;
325 if( localheur &&
SCIPisGT(
scip, binobjective[i], *objective) )
330 for( i = 0; i < nbins; ++i )
334max = binobjective[i];
339assert(!isassigned[ind] && ind > -1 && ind < nbins);
342 for( c1 = 0; c1 < ncluster; ++c1 )
344clusterassignment[ind][c1] = 0;
347clusterassignment[ind][bestcluster[ind]] = 1;
348binsincluster[bestcluster[ind]]++;
349*amountassigned += 1;
350isassigned[ind] =
TRUE;
353 updateIrrevMat(clusterassignment, qmatrix, cmatrix, ind, bestcluster[ind], nbins, ncluster);
357 for( i = 0; i < nbins; ++i )
377assert(heur !=
NULL);
392assert(heur !=
NULL);
399assert(heurdata !=
NULL);
411assert(heur !=
NULL);
426assert(heur !=
NULL);
431assert(heurdata !=
NULL);
434heurdata->lasteffectrootdepth = -1;
477assert(nbins > 0 && ncluster > 0);
485 for( i = 0; i < nbins; ++i )
494 for( j = 0; j < ncluster; ++j )
497clustering[i][j] = -1;
504 for( i = 0; i < nbins; ++i )
506 for( j = 0; j < ncluster; ++j )
508 if(
NULL== binvars[i][j] )
522isassigned[i] =
TRUE;
525 for( c = 0; c < ncluster; ++c )
527 if( clustering[i][c] == -1 )
528clustering[i][c] = 0;
536 for( i = 0; i < nbins; ++i )
541 for( j = 0; j < ncluster; ++j )
543 if( 0 == clustering[i][j] )
545 if( 1 == clustering[i][j] )
549 if( ncluster == amountzeros || sum > 1 )
553 if( amountassigned < nbins && possible )
560 while( amountassigned < nbins )
563isassigned, nbins, ncluster, &amountassigned, binsincluster, &obj ) );
586 for( i = 0; i < nbins; ++i )
623assert(heur !=
NULL);
632 "localheur",
"If set to true, heuristic assigns bins as soon as any improvement is found",
Constraint handler for AND constraints, .
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)
SCIP_RETCODE SCIPsetHeurExitsol(SCIP *scip, SCIP_HEUR *heur, SCIP_DECL_HEUREXITSOL((*heurexitsol)))
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_RETCODE SCIPsetHeurFree(SCIP *scip, SCIP_HEUR *heur, SCIP_DECL_HEURFREE((*heurfree)))
void SCIPheurSetTimingmask(SCIP_HEUR *heur, SCIP_HEURTIMING timingmask)
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)
#define SCIPallocClearBufferArray(scip, ptr, num)
#define SCIPallocMemory(scip, ptr)
#define SCIPfreeBufferArray(scip, ptr)
#define SCIPfreeMemory(scip, ptr)
SCIP_RETCODE SCIPcreateSol(SCIP *scip, SCIP_SOL **sol, SCIP_HEUR *heur)
SCIP_RETCODE SCIPtrySolFree(SCIP *scip, SCIP_SOL **sol, SCIP_Bool printreason, SCIP_Bool completely, SCIP_Bool checkbounds, SCIP_Bool checkintegrality, SCIP_Bool checklprows, SCIP_Bool *stored)
SCIP_Real SCIPinfinity(SCIP *scip)
SCIP_Bool SCIPisGT(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_Bool SCIPisEQ(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_Bool SCIPisLT(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
int SCIPgetEffectiveRootDepth(SCIP *scip)
SCIP_Real SCIPvarGetUbGlobal(SCIP_VAR *var)
SCIP_Real SCIPvarGetLbGlobal(SCIP_VAR *var)
static SCIP_Real getObjective(SCIP *scip, SCIP_Real **qmatrix, SCIP_Real scale, int ncluster)
static SCIP_DECL_HEURINIT(heurInitCycGreedy)
SCIP_RETCODE SCIPincludeHeurCycGreedy(SCIP *scip)
static SCIP_DECL_HEUREXEC(heurExecCycGreedy)
static SCIP_DECL_HEUREXITSOL(heurExitsolCycGreedy)
static SCIP_DECL_HEURCOPY(heurCopyCycGreedy)
static void computeIrrevMat(SCIP_Real **clusterassignment, SCIP_Real **qmatrix, SCIP_Real **cmatrix, int nbins, int ncluster)
static SCIP_DECL_HEURFREE(heurFreeCycGreedy)
static void updateIrrevMat(SCIP_Real **clusterassignment, SCIP_Real **qmatrix, SCIP_Real **cmatrix, int newbin, int newcluster, int nbins, int ncluster)
static SCIP_RETCODE assignNextBin(SCIP *scip, SCIP_Bool localheur, SCIP_Real **clusterassignment, SCIP_Real **cmatrix, SCIP_Real **qmatrix, SCIP_Bool *isassigned, int nbins, int ncluster, int *amountassigned, int *binsincluster, SCIP_Real *objective)
static SCIP_Real getTempObj(SCIP *scip, SCIP_Real **qmatrix, SCIP_Real **cmatrix, SCIP_Real **clusterassignment, int newbin, int newcluster, int nbins, int ncluster)
Greedy primal heuristic. States are assigned to clusters iteratively. At each iteration all possible ...
internal miscellaneous methods
SCIP_RETCODE assignVars(SCIP *scip, SCIP_SOL *sol, SCIP_Real **clustering, int nbins, int ncluster)
int SCIPcycGetNBins(SCIP *scip)
int phiinv(int k, int ncluster)
SCIP_Real SCIPcycGetScale(SCIP *scip)
int SCIPcycGetNCluster(SCIP *scip)
SCIP_VAR *** SCIPcycGetBinvars(SCIP *scip)
SCIP_Real ** SCIPcycGetCmatrix(SCIP *scip)
SCIP_Bool isPartition(SCIP *scip, SCIP_Real **solclustering, int nbins, int ncluster)
problem data for cycle clustering problem
static SCIP_Real phi(SCIP *scip, SCIP_Real val, SCIP_Real lb, SCIP_Real ub)
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