Reputation: 15
I created a transporterFleet with the following code in "On enter node" in Fleets properties.
When the transporter enters a specific node the speed is set by a variable called agvCycle
.
I coded it that way because the transporters speed has to change on each node.
I noticed my simulation run time gets really slow eaven on "virtual". I think the unnecessary repetive coding might be the reason. How can I implement a loop in this case? Would that speed up the simulation time?
if (node == locationCycle1) {
unit.setMaximumSpeed(agvSpeedCycle1/60.0, MPS);
}
else if (node == locationCycle2){
unit.setMaximumSpeed(agvSpeedCycle2/60.0, MPS);
}
else if (node == locationCycle3){
unit.setMaximumSpeed(agvSpeedCycle3/60.0,MPS);
}
else if (node == locationCycle4){
unit.setMaximumSpeed(agvSpeedCycle4/60.0, MPS);
}
else if (node == locationCycle5){
unit.setMaximumSpeed(agvSpeedCycle5/60.0, MPS);
}
else if (node == locationCycle6){
unit.setMaximumSpeed(agvSpeedCycle6/60.0, MPS);
}
else if (node == locationCycle7){
unit.setMaximumSpeed(agvSpeedCycle7/60.0, MPS);
}
else if (node == locationCycle8){
unit.setMaximumSpeed(agvSpeedCycle8/60.0, MPS);
}
else if (node == locationCycle9){
unit.setMaximumSpeed(agvSpeedCycle9/60.0, MPS);
}
else if (node == locationCycle10){
unit.setMaximumSpeed(agvSpeedCycle10/60.0, MPS);
}
... // Goes on till locationCycle27 and variable agvSpeedCycle27```
Upvotes: 0
Views: 109
Reputation: 9376
in general you want to use maps in your simulation models, in this case in particular i don't think it makes much of a difference, but for good practice you want to define a collection of type LinkedHashMap (let's call it x), the key element will be Node and the value element class will be a double
Then in the simulation start you do this:
x.put(locationCycle1,agvSpeedCycle1);
x.put(locationCycle2,agvSpeedCycle2);
etc...
Then when you want to calculate the new maximum speed you just do this:
unit.setMaximumSpeed(x.get(node)/60.0, MPS);
Upvotes: 1