semvec/pypi-packages huggingface dataset:
al-pyne 0.1
A library for running exported AnyLogic models
Requires Python: >=3

# ALPyne

ALPyne is a Python library for running exported AnyLogic models


## Usage

You will need to export your AnyLogic model as a standalone Java application. The only change you may need to make in your model is to set the access to any functions you want to call to "public".

Furthermore, as the server has the latest AnyLogic libraries built into it, you only need the model's jar file and the database/cache folders (if applicable).

The following is some sample Python code showing some of the available functionality. 
```python
from random import randint
import alpyne
from alpyne.constants import TimeUnits


server = alpyne.connect(r"MyModel Exported\model.jar", path_db=r"MyModel Exported\database")
inst1 = server.new_instance()
# set the next run's seed to 1 and the parameter called "arrivalRate" to 2
inst1.initialize(seed=1, arrivalRate=2)
# reset back to time = 0
inst1.reset()
# get the current model state from a custom public function 
_, start_obs = inst1.run_function("getObservation", return_type="double[]")
# execute a custom public function to take an action in the model
rand_action = randint(0, 3)
inst1.run_function("takeAction", arg_values=rand_action)
# advance the run 10 seconds
_, curr_time = run.run_for(10)
# advance the run for another 10 seconds
_, curr_time = run.run_for(10, TimeUnits.SECOND)
# get the model's datasets
_, datasets = run.get_datasets()

# set the next run's seed to a random value and revert arrivalRate parameter to default
inst1.initialize(seed=1, arrivalRate=None)
inst1.reset()
# ...

server.close()
```

As the server runs as a separate process, it will check every 60 seconds for any live instances and will shut itself down if there are none connected.

_See the complete user guide on the GitHub page for more information._

## Contributing
Feel free to discuss desired changes or problems in a new issues ticket. 
Pull requests are welcome - though please ensure the libraries you use in the server are up to date with the latest version of AnyLogic. 

## License
[MIT](https://choosealicense.com/licenses/mit/)