Originally posted by: Cplex81
hi,
I am trying to run the following code but I get the error "generate 215" which is element immutable. it has sth to do with the STA paramter. although it is only called in the function findmin but I don't know why I still the get this error.
"The collection "STA" is immutable because it is referenced by another element.
tuple Station
{
int index;
int datarate;
float linkrate;
float norm_rate;
int isAssigned;
}; tuple Channel
{
int StaNb;
float StaLoad; Station staInfo;
};
{Station
} station = ...; Channel K[1..3];
float tempMin=2; Station tempSta;
//{Station} STA = station; execute
{ function findmin(whatever)
{ var tempMin=2; var result;
for (var i in whatever)
{
if (i.norm_rate < tempMin )
{ i.isAssigned =1; tempMin =i.norm_rate; result= i;
}
}
return result;
}
}
{Station
} STA = station; main
{ var station = thisOplModel.STA; var tempSta = thisOplModel.tempSta;
//var STA = thisOplModel.STA; var i =0 ; var tempMin = 2;
while ( i<15)
{ tempSta = findmin(station); writeln(
"rate=",tempSta.norm_rate);
for ( var r in station)
{
if ( r.isAssigned == tempSta.isAssigned)
{ r.isAssigned=1;
}
} i++;
}
}
#DecisionOptimization#OPLusingCPLEXOptimizer