Font size

Multimethod models with SD

AnyLogic is the only tool that allows you to combine SD model components with components developed using agent based or discrete event methods. For example, you can model the consumer market using SD and the supply chain using AB approach. You can model the population of a city in a disaggregated way (as agents) and the underlying economic or infrastructural background in SD style. You can even put SD diagrams inside agents: e.g. SD can model the production process inside a company, whereas the company may be an agent at a higher level.

Technically, interfaces and feedbacks between SD and AB or DE are very easy: some SD variables can be used in the decision logic of agents or be parameters of process flowcharts, and the latter in turn may modify other SD variables.

You can study the given simple model that demonstrates one of the methods you can use to link continuous system dynamics model components with discrete ones. In this example we have a very simple system dynamics structure: a stock and a constant incoming flow filling the stock. The event with condition-type trigger waits for the stock to reach the level of 100 units and closes the inflow at that time.

Demo model: Event Triggered by Stock Reaching Threshold Open the model page in AnyLogic Cloud. There you can run the model or download it (by clicking Model source files).

Optimizing performance of multi-method models with SD

If you have a model containing both system dynamics equations and discrete event and/or agent-based parts, you may significantly improve the model performance by running it in the special “event-unaware” mode.

For example, you have an agent-based model where each agent has system dynamics elements inside. If the number of agents is huge, the engine will have both to solve SD equations and manage a great number of asynchronous events.

You can programmatically switch your model with both System Dynamics equations and dense discrete events to a higher performance mode. In this mode, system dynamics solver does not stop on each discrete event.

Use the following method of the AnyLogic Engine:

getEngine().setEventAwareSolver(boolean EventAwareSolver) — If the function argument is false, the AnyLogic engine turns on the "event-unaware" option for speeding up execution of the combined SD AB (or SD DE) model. Otherwise, it runs in the default model execution mode.

If true, SD equations will be solved with respect to each event occurrence time. This is the most precise technique, but in some cases it may significantly slow down the model, e.g. when many asynchronous agents generate dense events on the timeline.

If false, SD equations will be solved with fixed steps regardless event occurrences. As a result, an event will operate with some recent (not quite actual) values of continuous variables, namely, corresponding to the last result of numeric integration step. In the worst case, the values will be htol time units late. And similarly, in this mode SD formulas aren’t evaluated after each event execution, this is done only on fixed steps of the solver.

How can we improve this article?