You can expose variable to the agent interface and connect it to a dependent variable of other agent. Connected variables will have the same value at any moment of time; i.e., changes of one variable will be immediately propagated to another variable declared as dependent one. This provides for continuous and/or discrete time object interaction.
You can connect:
- Two public variables of two embedded objects;
- A variable of a container object with a public variable of an embedded object.
The figure below is the screenshot from the Population model. It illustrates the case when two embedded objects interact via connected variables.
- Only the variables of compatible types can be connected.
- You cannot connect two variables of the same object.
- AnyLogic allows connection of several dependent variables to one variable. But to prevent collisions, only one variable can be connected to a dependent variable.
When connecting two variables, one variable should be necessarily defined as dependent one. The dependent variable always gets value of another variable.
To make a variable dependent
- Select the variable in the graphical editor or in the Projects view.
- In the Properties view, select the Dependent check box.
When finished, connect variables graphically with connectors.
To connect two variables
- Double-click the Connector element in the Agent palette to activate its drawing mode.
- In the graphical editor, subsequently click both variables that you want to connect.
When drawing connectors, you can notice that connector’s point put correctly inside variable icon is indicated with a small green circle. In the case you do not see the green circle, it probably means that you are trying to connect variables that cannot be connected, or you have put connector’s point close by a variable and you need to move it onto it.
How can we improve this article?