Here, you'll learn how to set up your model to translate the action decisions prescribed by Pathmind into a format that your AnyLogic model can interpret. We'll explain what that means below.

Step 1 - First, determine the number of actions that your simulation requires. It may take many iterations to get this right.

@Discrete is one of several types of action spaces that Pathmind supports. We'll only cover discrete action spaces in this article to keep things simple.

n is total number of possible actions that a single agent can perform. For example, in the case of a street light, it'd be n = 2 (stop or go).

size indicates the total number of decision points in your model. For example, if your simulation contains three street lights that require an action for each at any given moment, then size = 3 (a decision for each of the three street lights).

Now create a new function and assign it the name doAction.  

Next, click the doAction function to inspect its properties. 

Step 2 - Accept action as an argument in doAction.

First, ensure that Just action (returns nothing) radio button is selected.

Then inside "Arguments"...

  • Set the Name to action.
  • Set the Type to whatever data type you had specified in Pathmind Helper. In this case, it was an int[].

Step 3 - Write your doAction function.

Your doAction function will accept an argument from Pathmind which inform the agent what to do next.

Some Examples:

Action returns 1  - Agent to do action 1 .
Action returns [5, 2]  - Agent 0 to do action 5 and Agent 1 to do action 2.
etc. etc.

The job of doAction is to map this number into something that AnyLogic can interpret.

Finally, you can inspect your doAction by following the instructions here.

Did this answer your question?