Rob, Thanks for your reply.. but I need to apply the same concept for a 3 dimension matrix Can you help me with this? This are the heuristics I want to apply: - I need to cluster a set of points by proximity - Objective - I can do this by minimizing the sum of distances from all origins to all destinations for all the clusters created - Constraint - Clusters must have more than x points (in example is 5) QUESTION: How can I specify that if an origin is in one group, then it cannot be in other groups. I have implemented this, (as you recommended, but the problem is that the limits are applied across the clusters.. I want to specify that if an origin is in one group... it cannot be in another group for any of the destinations. See bellow an attempt to use your recommendation... problem is that the limits 0-1 AND 4 TO card apply for the origin across all the groups. proc optmodel; set DEST = 1..&num_vars; set GROUPS = 1..&num_groups; set ORIG; num dist {ORIG, DEST}; read data SFDISTANCES into ORIG=[_N_] {j in DEST} <dist[_N_,j]=col('x'||j)>; /* Assign[i,g] = 1 if observation i assigned to group g, 0 otherwise */ var Assign {ORIG, DEST, GROUPS} binary; Var IsOriginGroup{ ORIG,GROUPS} binary init 0; con orig_assignment_lb1 {i in ORIG}: sum {j in DEST, g in GROUPS} Assign [i,j,g] >= 0 * and {g in GROUPS} IsOriginGroup[i,g] + 4 * (1 - IsOriginGroup[i,g]); con orig_assignment_lb2 {i in ORIG}: sum {j in DEST, g in GROUPS} Assign [i,j,g] >= 1 * IsOriginGroup[i,g] + card(DEST) * (1 - IsOriginGroup[i,g]); con Simetry {i in ORIG, j in DEST, g in GROUPS}: Assign[i,j,g]=Assign[j,i,g]; con ASimetry {i in ORIG, g in GROUPS}: Assign[i,i,g]= 0; con NearlyEqual {g in GROUPS}: sum {i in ORIG, j in DEST} Assign[i,j,g] >=4 ; impvar GroupSum {g in GROUPS} = sum {i in ORIG,j in DEST} dist [i,j] * Assign[i,j,g]; min distance = sum {g in GROUPS} GroupSum[g]; solve with milp / primalin allcuts=AGGRESSIVE RELOBJGAP=0.1 maxtime=50 ; create data Allocated_Demand from [ORIG DEST GROUPS]={i in ORIG, j in DEST, G IN GROUPS: Assign[i,j,g] = 1}; print Assign; print GroupSum;
... View more