Drag the Action Chart element from the Actionchart palette onto the graphical diagram of the agent. You will see new action chart (the basic construction consisting of a starting point and "return" block) drawn.
Action charts are called in the same way as functions - you write the action chart name followed by parenthesis. In the case action chart has some arguments, you should pass argument values separated by commas inside the paraenthesis. The values should be provided in the order they are defined in the action chart element, in the Arguments table.
Name – The name of the action chart. The name is used to identify and call the function defined by this action chart from code.
Show name – If selected, the name of the action chart is displayed on a presentation diagram.
Ignore – If selected, the action chart is excluded from the model.
– If selected, the action
chart is visible
on the presentation at runtime.
Just action (returns nothing) – If selected, this actionchart just executes some action(s) and does not return any value.
– If selected, this actionchart returns a value (a result of
calculations and actions). You specify the type of the return
value using the control below.
– Specify here the type of the function's return
value. Function can return value of some most-used types (int, double, boolean, String), or of
Java class (in this case specify Java class name in the neighboring
Here you can define some optional arguments for the function
defined by this action chart to enable passing some
additional input data
Each row of the table specifies one particular argument. To remove argument, select the corresponding row in the table and click the "cross" button. Rearrange arguments in the table using "arrow" buttons.
Fill color– Sets the fill color for this action chart element. Click inside the control and choose a color from the set of most used ones, or choose some custom color using the Colors dialog box.
Static – If selected, the function defined by this action chart is static. Static function does not need creating any instances of the agent type, in whose code it is defined. Static function defined in agent type MyClass can be accessed from any place of the model as MyClass.function().
Visible on upper level – Defines, whether the action chart is visible on a presentation diagram of the owner of this agent type. Since action charts cannot appear on owner class' presentation, this checkbox is always deselected and disabled.
Access - The access
type of the function defined by this action
There are four access types:
public - the function can be accessed from anywhere
private - the function can be accessed from this agent type only
protected - the function can be accessed from this agent type and its subclasses
default - the function can be accessed anywhere within this model.
System dynamics units - If selected, you will be able to specify units of measurements for the value returned by this actionchart in the edit box to the right. Having specified units for elements of your model, you may perform unit checking to find out dimension inconsistencies in the model.
You may define arguments for your action chart to enable passing some additional input data necessary for calculations. Arguments are visible from any block within the action chart.To define arguments for the action chart
If you have defined any arguments for the function, you should pass argument values any time you call the function. The values should be provided in the order they are defined in the Arguments table.
Since the order of arguments in the table is
enables changing the argument order just moving them up or
To remove argument, select the corresponding row of the table and click the button.
If your action chart contains a considerable amount of code defined with the help of the Code elements, the more convenient way to work on this algorithm could be by converting the action chart to a simple AnyLogic function and continue with coding in text format. For such cases AnyLogic offers a conversion option. Note, that this is a one-way conversion: you cannot turn the function back into the action chart.To convert action chart to function
Action charts. Defining algorithms visually
Editing action chart blocks