I am rather new at Anylogic and I have these populations of agents:
- Customer (parameters: name, latitude, longitude)
- Terminal (parameters: name, latitude, longitude)
- Order (parameters: Customer, Terminal)
- Truck (statechart to first moveTo order.terminal and then to order.customer)
For every different terminal (I have 5) there is a different order rate per customer. So, I created (within Customer) five schedules for the rate of orders for every terminal. Now I want to create an event in Customer to create orders (one event per terminal). I have this now for the terminial with the name terminalA:
Order order = new Order(this, terminal.name("terminalA"));
Truck truck = getNearestAgentByRoute(filter(main.trucks,
v -> v.inState(Truck.Free)));
if (truck != null)
send(order, truck);
However, the part terminal.name("terminalA") does not work, as it can not be resolved to a variable. How do I create an order per terminal and tell Anylogic what terminal (with what name) it should create orders for?
Thanks in advance for your help!
Kind regards, Ella
CodePudding user response:
You don't need to use terminal.name("terminalA")
, just use terminalA
if you have named that specific agent as terminalA
; otherwise you need to access them by index, such as main.terminals(0)
. The parameter type inside the Order agent should be set to Terminal
. For example, below I create an order agent with a lot of different parameters & variables, each with a custom type.
Edit. You also need to make sure that your agent list is not empty: