Integrating Python with AnyLogic for Simulation Modeling
Python + AnyLogic
The Python API for AnyLogic provides a powerful way to take your simulation models to the next level.
Python represents one of the world’s most popular programming languages. According to the analyst firm RedMonk, Python ranks second on the latest ranking of programming language popularity, just below JavaScript. Being a free open-source language, having a large variety of libraries for multiple purposes (e.g. data science, machine learning, artificial intelligence, big data, data visualization, optimization, statistics) and its compatibility with other programs have contributed to its increasing popularity among professionals and academics from multiple fields.
AnyLogic, a leading simulation software for business applications utilized worldwide by over 40% of Fortune 100 companies, has recently integrated a Python API for AnyLogic to work on simulation models stored on your personal AnyLogic Cloud. This new functionality is expected to bring potential benefits to AnyLogic and Python users in the development, configuration and experimentation of their simulation models.
Python API for AnyLogic
AnyLogic simulation models stored in your personal AnyLogic Cloud account can be configured and run programmatically through a Python API for AnyLogic to obtain experimental results and evaluate multiple scenarios by changing parameters values.
This Python new functionality with AnyLogic represents a great tool for when required to run and experiment with AnyLogic simulation models in a computer that do not has the AnyLogic software installed.
To start using the Python API for AnyLogic, install the AnyLogic cloud client library using pip package installer:
Minimalistic Simulation Model
The model analyzed in this tutorial (i.e. Service System Demo) can be found in AnyLogic cloud website.
The Service System Demo model consists in a single source, a service module, a check point and one sink. The time agents spend in the system is measured and the goal is to obtain the mean total time agents spend in the system, the server utilization and mean queue size.’
Follow the next steps to run to run the Service System Demo model on AnyLogic Clod website:
- Type ‘Service Systems Demo’ in AnyLogic Cloud website search bar. The model will be displayed in the screen as follows:
- Click on the Service Systems Demo model to open it.
- Click play to run the simulation model and obtain the results.
Baseline Results:
According to the baseline model’s results, the mean total time in the system is 4.63, the server utilization 0.83 and the mean queue size 2.54.
Now, let us run the same simulation model using the Python API for AnyLogic by linking it with the AnyLogic model in the cloud. Follow the next steps to run to run the Service System Demo model:
Python Code:
Results:
Comparison with Baseline Model:
By increasing the server capacity from 3 to 8, the mean queue size was reduced from 2.54 to 1 agents. In addition, the mean server utilization was also reduced from 0.83 to 0.31, representing additional idle time that should be further optimized.
What will come next?
Python’s new capabilities with AnyLogic are expected to increase its functionality for simulation projects. While its current applications are still limited, we can expect new functionalities in the near future considering Python’s popularity between programmers and engineers. For help on the Python API for AnyLogic click here to schedule a call.
For additional information, consult AnyLogic’s Cloud official documentation here and Python codes here.
Interested in obtaining an AnyLogic license? Click here to schedule a call.
About SimWell
At SimWell, we know you're a trailblazing business leader, and it's your job to make confident, informed decisions. The problem is you have a complex operation with infinite variables and interactions that just don't fit on a pivot table. This leaves you utterly underwhelmed by the predictive tools at your disposal, and completely overwhelmed by the massive decisions looming.
We understand the all-consuming nature of big decisions, and the sleepless nights that surely follow. We know the pressure you're feeling and we're here to help. You need REAL answers based on the complexities of your operation. With cutting-edge simulation software from SimWell, you get just that.
We help you accurately predict the outcome of your decisions, giving back years of trial and error, saving you countless costs, and setting you free to be a trailblazing business leader. Press fast-forward on your big decisions with SimWell.