Skip to main content

Alpyne

The AnyLogic-Python connector

This is a Python library for interactively running models exported from the RL experiment.

Currently, this library released as a public beta (so please excuse any rough edges). If you have problems or bugs, please file them in the Issues tab. For general talk or questions, there's the Discussions tab.

Full documentation (with background information, getting started guide, and class docs) can be found @ https://the-anylogic-company.github.io/Alpyne

All contributions, including new or improved example models and training scripts, are thoroughly welcomed! See the note at the end for more specifics.

Installation

Alpyne supports Python 3.10+ and requirements the latest version of AnyLogic (natively was created on Mar 2024: v8.8.6).

To install this library with its base minimum components, use pip install anylogic-alpyne

To include the requirements necessary for running the examples, use pip install anylogic-alpyne[examples]

Preparing an AnyLogic model

You can use any edition of AnyLogic (PLE, University, or Professional) with this library. However, be aware that limitations of the edition will still apply. For example, PLE users executing models which utilize industry-specific libraries have their runs limited to 1-hour simulation time.

You will need to setup your model with the following components.

  1. RL experiment, with the Configuration, Observation, Action, and stopping conditions filled out, as per your specifications
  2. A call to the RL experiment's takeAction method, at the moment you wish an action to be taken

To export the model, navigate to the properties of your RL experiment and click the export button at the top.

Basic idea/usage

In your Python code, you will create a single AnyLogicSim object which represents a connection to a single instance of your simulation model.

In creating the AnyLogicSim, you pass a reference to where your exported model is located, in addition to options for log level, engine settings, and other behavioral options. This object then gives you access to functions for interacting with the model run, including resetting it, querying its status, applying some action, and getting outputs.

You can learn more about the specifics and deeper background information from reviewing the documentation or referencing the provided examples.

Note that some examples require additional libraries to be added in your AnyLogic environment; see their individual READMEs for more details.

Before running the example scripts, you'll need to first export them from AnyLogic. To run them without any modifications, you'll need to do the following:

  1. Open the given model in AnyLogic (e.g., examples/Pathfinder/Pathfinder.alp)
  2. In the properties of its RL Experiment, click the export button at the top; save the zip file inside a folder named "ModelExported"
  3. Most examples are setup expecting the zip file to be unpacked in-place (such that the file ModelExported/model.jar is valid); see the individual models' README for more specifics
  4. Run the associated Python script

Contributing

Feel free to submit contributions (in the library, its documentation, or the example models or scripts) via pull requests.

General guidelines for examples:

  • Training scripts should, by default, be able to run in 10 minutes or less and be able to produce results that are better than random
    • Having commandline arguments for longer / more robust training is completely acceptable
  • Simpler, semi-realistic models are best; more complex ones are OK if they are understandable by people from different industries
  • Models should ideally have implementations/toggles for running in non-RL, training, and testing "modes" (the specific terminology is not important); others can be freely added (e.g., heuristic)
  • Models and scripts should be reasonably organized or structured (e.g., for models: aligned elements, clean flowchart connectors)
  • Use standard conventions where relevant (e.g., TitledClassNames, camelCaseJavaVariables, snake_case_python_variables)

вљ  It's suggested to make a discussion post before spending too much time on an idea to avoid chancing it being rejected down the line

Metadata

Release files for anylogic-alpyne 1.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for anylogic-alpyne 1.2.1
File Size Uploaded
anylogic_alpyne-1.2.1.tar.gz 8.5 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for anylogic-alpyne 1.2.1
File Interpreter ABI Platform
anylogic_alpyne-1.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 17.0 MB

Release files / anylogic_alpyne-1.2.1.tar.gz

Download URL anylogic_alpyne-1.2.1.tar.gz
Size 8.5 MB
Tags Source
SHA-256 checksum
How to use checksums
1d7781a1497afe27a073b1f583d38a309975afe73d8bd3450548114fb8946f82
BLAKE2b-256 checksum
How to use checksums
9e695f00a02a4f6cdbc7f89ac28511145a6710e925050fef8bf3c958a8bfebe2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.9.6

Release files / anylogic_alpyne-1.2.1-py3-none-any.whl

Download URL anylogic_alpyne-1.2.1-py3-none-any.whl
Size 8.5 MB
Tags Python 3
SHA-256 checksum
How to use checksums
46e9087cedaad4a5ac02670c83099d4e7fef6fa472fac3490f73baedc10c0fe1
BLAKE2b-256 checksum
How to use checksums
ff00d22ea0037e49119950655c8fe621bc1bba5fca21f54e5d2b537c610f853b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.9.6

Release history Release notifications | RSS feed

This release

1.2.1 This release

2 release files

1.2.0

2 release files

1.0.0

1 release file

0.2.0

1 release file

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page