Originally posted by: hacimehmet
Hi, I have one more question about variable selection. I want to change an array that I use for variable selection while programme is running. How can I update this array? For this, I wrote the following code block. So, I plan to update the array in the time. But, it gave the following error. How can I correct this error?
ilog.concert.IloException: IloInt IloIntVarChooser::choose(...) : unfixed variables remains while the function return -1
Note: I know this code is the same as IloVarSelector varSel = cp.selectLargest(cp.explicitVarEval(stationnumber, selectingrule)); but my main problem is about updating the selectingrule array while the programme is running.
static public classChoosemaximum extendsIloCustomIntVarChooser {
publicChoosemaximum(IloCP cp) throwsIloException {
super(cp);
};
double[] selectingrule= {270, 270, 100, 140, 190, 290, 335, 179, 485, 199, 248, 248, 248, 248, 248, 260, 260, 260, 286, 241, 260, 60, 260, 230, 230, 171, 480, 174, 170, 300, 105, 248, 180, 235, 330, 276, 248, 440, 260, 270, 160, 110, 270, 430, 243, 190, 160, 110, 386, 0, 200, 242, 186, 270, 150, 73, 466, 230, 134, 181, 107, 271, 133, 266, 119, 181, 139, 149, 189, 149, 149, 277, 192, 333, 229, 130, 608, 0, 0, 117, 117, 342, 138, 240, 240, 87, 0, 294, 198, 147, 267, 151, 190, 78, 135, 235, 425, 90, 107, 0, 423, 128, 287, 105, 158, 439, 159, 246, 188, 184, 680, 70, 185, 185, 0, 881, 166, 153, 185, 128, 387, 301, 51, 227, 138, 181, 731, 848, 227, 121, 317, 121, 439, 125, 129, 143, 138, 107, 312, 241, 228, 186, 249, 371, 90, 136, 90, 90, 66, 90, 102, 146, 101, 371, 118, 285, 201, 148, 148, 79, 148, 91, 52, 215, 336, 869, 125, 68, 121, 80, 207, 178, 132, 121, 150, 81, 30, 63, 351, 274, 82, 75, 145, 120, 495, 99, 169, 65, 500, 92, 42, 263, 213, 187, 164, 86, 107, 108, 117, 78, 0, 472, 72, 30, 112, 216, 0, 220, 183, 183, 220, 74, 139, 339, 202, 102, 550, 406, 147, 0, 0, 5, 128, 68, 100, 68, 310, 835, 740, 213, 68, 390, 130, 304, 85, 403, 21, 236, 129, 1019, 34, 115, 68, 910, 102, 578, 101, 1300, 0, 178, 0, 190, 100, 352, 92, 28, 83, 242, 141, 303, 217, 58, 199, 196, 91, 44, 99, 50, 421, 129, 114, 196, 215, 378, 0, 270, 345, 193, 140, 100, 150, 412, 0, 170, 252, 198, 301, 301, 121, 52, 326, 84, 1386, 527, 968, 1000, 538};
public intchoose(IloCP cp, IloIntVar [] vars) {
double best= Double.MIN_VALUE;
int bestIndex=-1;
int n= vars.length;
for(int i= 0; i< n; i++) {
if(!cp.isFixed(vars[i])){
while(selectingrule[i] > best) {
best= selectingrule[i];
bestIndex= i;
}
}
}
System.out.println("aaaa "+" ="+ bestIndex);
return bestIndex;
}
}
#ConstraintProgramming-General#DecisionOptimization