0
votes

In AnyLogic...I am building a model where an Agent A (living in Main) will move to Agent B (living inside another Agent C, such as a home) once Agent B sends A a message. I have troubles when setting the "initial location" of Agents B. How can I point to his particular "home" (Agent C)?

I have tried: "in the specified point": X = this.getLongitude() ... "in the node": this

But no luck. Any ideas? Does this make any sense?

2

2 Answers

0
votes

It can be implemented in several ways. The most common is flowchart-based: agent leaves flowchart at Main through Exit block. In On Exit action of Exit block, call:

agentC.enter.take( agent );

AgentC type should have Enter block. In properties of the block, specify the initial location of entering agent. Enter can be considered as "gates" of agents who enter from another space (like Main).

0
votes

Gregory talks about a possible 'architecture' for the communication and movement but, to answer at the more general level of agent movement and embedding:

If your Agent types are AgentA, AgentB and AgentC with embedding as you say (population of AgentBs in their 'home' AgentC) then every AgentB instance will automatically have a link (a Link to upper level agent) to the embedding AgentC called agentC.

So, when an AgentA receives a message from an AgentB, you can just do something like

moveTo(sender.agentC)

or

jumpTo(sender.agentC.getX(), sender.agentC.getY())

(The sender is a special keyword referring to the sending agent in "On message received" code blocks. jumpTo moves instantly to somewhere rather than moving with whatever speed the agent has. Unfortunately moveTo lets you specify another agent as the target but jumpTo has to use coordinates or nodes.)

See the following help sections:

  • AnyLogic Help > Agent Based Modeling > Agent interaction > Communication between agents
  • AnyLogic Help > Release Notes > What's new in previous releases > What's new in AnyLogic 7 > Link to upper level agent [section]
  • AnyLogic Help > Agent Based Modeling > Agent movement > Movement in Continuous Space