AnyLogic Cloud API: Python

Introducing the AnyLogic Cloud API and Python - blog

This blog is adapted from a post written by Roberto Salazar Reyna, Simulation Consultant at SimWell.

The blog AnyLogic Cloud API: New Possibilities introduced the AnyLogic Cloud API and JavaScript and how it can configure and remotely run simulation models. Now it is the turn of the AnyLogic Cloud API and Python.

Python’s popularity ranks just behind that of JavaScript as the world’s second most popular language according to GitHub. It is a popular language for machine learning, data processing, and data presentation.

For AnyLogic simulations not in the Cloud, the Pypeline connector library allows you to call Python from within a running AnyLogic simulation model — learn more in our Pypeline webinar video. In this blog we will focus on the AnyLogic Cloud API and Python.

The AnyLogic Cloud API is only available for commercial versions of the service, but anyone can evaluate its capabilities with a demo model. This blog will show you how. You will need:

  • Test key for this demo: e05a6efa-ea5f-4adf-b090-ae0ca7d16c20
  • Installed pip package manager
  • The ability to work in the console: all actions, including data input and output, are performed there

In our examples, we will use the Service System Demo model. It describes the service process: allowing you to set server capacity, analyze the average size of the service queue (the Mean queue size parameter), and resource utilization (the Server utilization parameter). The model is hosted on our test account and you connect to it via API. If you are ready, let's get started!

First, manually run the model in the Cloud.

To do this, go to the Service Systems Demo model page in AnyLogic Cloud. When you launch it, you will find the model automatically launches in virtual time mode. In the baseline scenario, the queue capacity is 3, the resource load will be 0.83, and the average service queue size will be 2.54

Now we will run the same model using the AnyLogic Cloud API and Python but with a different parameter value for Server Capacity.

Make sure you have installed the AnyLogic Cloud Python client library using the pip package manager from the command line:

pip install

Setup and run the simulation:

* Note that line 23 provides raw output. This is only needed if the other outputs, such as Server Capacity and Queue Size, are insufficient.

As a result, you will see that by increasing the queue capacity values from 3 to 8, we reduced the average service queue size (from 2.54 to 1 person) and the average resource load (from 0.83 to 0.31).

Now you know how to run cloud models remotely using the AnyLogic Cloud API and Python. Try to put your knowledge into practice and run two more demo models in the same way.

Besides Python, the Cloud API works with Java and JavaScript. Learn more about how they function with the examples in the AnyLogic Cloud reference manual.

Related posts