Originally posted by: kendong
hi,
I am trying to run the following code but I get the error "inboundtrain","outboundtrian" which are element immutable. the set cannot be iterated in more than 2 loops??
thanks.
int PlanMonth = ...;
int PlanDay = ...;
//Inbound Trians Information
tuple nInboundTrians
{
string TrianID;
float ArrivalMonth;
float ArrivalDay;
float ArrivalHour;
float ArrivalMinute;
float InspectionTime;
float RailcarNum;
float HumpTime;
float ArrivalTime;
}
{nInboundTrians} inboundtrain = ...;
//Blocks Information
tuple nBlocks
{
string BlockID;
string InboundTrainID;
int RailcarNum;
string OutboundTrainID;
float DwellTime;
float ArrivalTime;
}
{nBlocks} block = ...;
//Outbound Trians Information
tuple nOutboundTrians
{
string TrianID;
float DepartureMonth;
float DepartureDay;
float DepartureHour;
float DepartureMinute;
float InspectionTime;
float AssembleTime;
float DepartureTime;
string BlockID1;
string BlockID2;
string BlockID3;
string BlockID4;
string BlockID5;
string BlockID6;
}
{nOutboundTrians} outboundtrain = ...;
execute INITIALIZE {
//Calculate the arrival time and deparutre time
for(i in inboundtrain)
i.ArrivalTime = ((i.ArrivalMonth - PlanMonth) * 30 + (i.ArrivalDay - PlanDay)) * 1440
+ i.ArrivalHour * 60 + i.ArrivalMinute;
for(j in outboundtrain)
j.DepartureTime = ((j.DepartureMonth - PlanMonth) * 30 + (j.DepartureDay - PlanDay)) * 1440
+ j.DepartureHour * 60 + j.DepartureMinute;
//set arrival time of each block
for(u in block)
for(i in inboundtrain)
if(u.InboundTrainID == i.TrianID)
u.ArrivalTime = i.ArrivalTime;
}
#DecisionOptimization#OPLusingCPLEXOptimizer