0
votes

I am just starting with Anylogic & Java. Could you please help me with my simple issue?

I have two windows: Main & Trucks

The trucks are entities generated on my model using a "source" within "Main".

I asked the model to create 10 trucks at the same time. It creates the trucks and then they move to another defined point at different speeds. When they arrive at the final point I want to know which truck arrived first (1, 2, ... or 10).

So... I am assuming that there is a way to assign a number to each truck when they are created. And I am also assuming I can read this number at the final point to know which one arrived first.

How can I do this?

1

1 Answers

1
votes

Yes it is possible. Use a parameter. Truck is an agent and it can have multiple parameters. The easiest way to use parameters is to drag them from the Agent pallet into the Truck window. You define its name and type (in your case will be integer). When the truck is generated at the source you can give the parameter the value you want. If you want to have a sequential number, create a variable in your main window called ID with initial value 1 and then, in the source object, on the On Exit code area you type something like:

Agent.parameter = ID++;

Note that "parameter" should be the name of the parameter you created in Truck window.

Hope that helps.