Skip to main content

Python bindings for the AIMMS optimization platform, built with pybind11 for seamless C++ integration. Enables efficient data exchange and interaction with AIMMS projects using pandas, polars, and pyarrow. Ideal for advanced optimization workflows requiring high-performance native code.

Reason this release was yanked:

old

Project description

AIMMS Python library

This is a BETA version of the AIMMS Python library. Any feedback, bug reports, or feature requests are welcome.

With this library its possible to interact with AIMMS models from Python.

Features

  • Seamless integration with AIMMS models from Python
  • Assign and retrieve data using Python dicts, Pandas, Polars, or Arrow tables
  • Execute AIMMS procedures and retrieve results programmatically
  • Built with pybind11 for high-performance C++ integration
  • Flexible data return types for different workflows

Note: The AIMMS Python library is tested with Python 3.10 or higher. Currently only the windows platform is supported.

Getting Started

To use the AIMMS Python library, you need to have an AIMMS installed and a correct organization license and an aimms project. Below is a step-by-step example of how to use the library to solve a simple transportation optimization problem.

Step 1: Initialize the AIMMS Project

First, initialize the AIMMS project by specifying the AIMMS executable path, project path, and other configurations.

Note: Ensure that the aimms_path points to a valid AIMMS bin folder of an installed AIMMS version. Additionally, you must have the appropriate AIMMS license configured. Failure to provide a valid path or license will result in errors.

The exposed_identifier_set_name parameter controls which AIMMS identifiers are accessible in Python. For example, setting it to "AllIdentifiers" exposes all identifiers in your AIMMS project which is an easy way to get started.

The data type preference can be set to DataReturnTypes.DICT, DataReturnTypes.ARROW DataReturnTypes.PANDAS or DataReturnTypes.POLARS. The default is DataReturnTypes.DICT.

import os
from aimms.project.project import Project

# Initialize the AIMMS project
my_aimms = Project(
    # path to the AIMMS Bin folder
    aimms_path=os.getenv("AIMMSPATH"),

    # path to the AIMMS project folder
    aimms_project_path=os.getenv("AIMMSPROJECTPATH"),

    # the name of an aimms set containing identifiers. 
    exposed_identifier_set_name="AllIdentifiers",  # Limit access to specific identifiers,
    data_type_preference=DataReturnTypes.DICT,
)

Step 2: Assign Data to Parameters

This is an example of assigning data to parameters with Pandas DataFrames.

demand_df = pd.DataFrame({
    "c": ["Houston", "Phoenix", "Philadelphia"],
    "demand": [50.0, 60.0, 40.0]
})

supply_df = pd.DataFrame(data={
    "w": ["NewYork", "LosAngeles", "Chicago"],
    "supply": [70.0, 80.0, 60.0]
})

unit_transport_cost_df = pd.DataFrame({
    "w": ["NewYork", "NewYork", "NewYork", "LosAngeles", "LosAngeles", "LosAngeles", "Chicago", "Chicago", "Chicago"],
    "c": ["Houston", "Phoenix", "Philadelphia", "Houston", "Phoenix", "Philadelphia", "Houston", "Phoenix", "Philadelphia"],
    "unit_transport_cost": [5.0, 6.0, 4.0, 3.0, 2.0, 7.0, 4.0, 5.0, 3.0]
})

my_aimms.demand.assign( demand_df)
my_aimms.supply.assign( supply_df)
my_aimms.unit_transport_cost.assign( unit_transport_cost_df)

You can assign doubles, integers, strings to AIMMS parameters. The library will automatically convert the data types to the appropriate AIMMS types. The sets will be filled automatically based on the data you assign to the parameters.

Step 3: Execute the Optimization Procedure

It is possible in AIMMS to define procedures that encapsulate the logic of your optimization model. These procedures can be executed from Python using the AIMMS Python library. In this example we run the main procedure in the AIMMS project to solve the optimization problem.

my_aimms.MainExecution()

It is also possible to run procedures with arguments for example:

my_aimms.run_procedure(test1=5.0, test2=10.0, test3="hallo")

Make sure the order of the arguments is correct as well as the types.

Step 4: Retrieve and Display Results

Retrieve the results of the optimization, such as the total transport cost and the transport plan.

# Retrieve results
print(f"Total Transport Cost: {my_aimms.total_transport_cost.data()}")
print(f"Transport Plan: {my_aimms.transport.data()}")

The .data() function is used to fetch the current value of an AIMMS identifier (e.g., a parameter, variable, or set) into Python. This function is efficient and only fetches data if it has changed since the last fetch.

Data Types Returned by .data()

depending on the data_type_preference you set in the Project constructor, the .data() function will return different types of Python objects:

Sets always return a list of strings.

For parameters and variables, .data() can return:

  • A scalar value (e.g., float or int or string) if the parameter or variable is scalar.
  • A dictionary where the keys are tuples of strings (representing indices) and the values are float, int, string.
  • A Arrow Table or Pandas or Polars DataFrame depending on the data_type_preference set in the Project constructor.

Example Output

Depending on you return type preference the python object returned from the .data() function will be different, the output for dictionaries can look like this:

Total Transport Cost: 150.0
Transport: {("NewYork", "Houston"): 30, ("LosAngeles", "Phoenix"): 50, ...}

for Pandas DataFrames can look like this:

Total Transport Cost: 150.0
Transport:
        w               c               transport
    0   NewYork         Houston         30
    1   LosAngeles      Phoenix         50
    2   Chicago         Philadelphia    40
    3   NewYork         Philadelphia    20

extra

it is possible to generate a stub file for your project which can greatly help with autocompletion in your IDE. This stub file contains all the identifiers in your AIMMS project and their types. You can generate this stub file by running the following command:

my_aimms.generate_stub_file( "my_project_stub.py" )

To use this stub file you can the following to the top of your python script:

from typing import TYPE_CHECKING
if TYPE_CHECKING:
    from my_project_stub import Project

License

This project is licensed under the MIT License.

Support

For questions, bug reports, or feature requests, please contact AIMMS B.V. via support. Or post an question on the AIMMS Community. We are happy to help you with any issues or questions you may have.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aimmspy-1.0.1.post33.tar.gz (24.1 MB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

aimmspy-1.0.1.post33-cp313-cp313-win_amd64.whl (563.0 kB view details)

Uploaded CPython 3.13Windows x86-64

aimmspy-1.0.1.post33-cp313-cp313-manylinux_2_27_x86_64.whl (10.8 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.27+ x86-64

aimmspy-1.0.1.post33-cp312-cp312-win_amd64.whl (563.1 kB view details)

Uploaded CPython 3.12Windows x86-64

aimmspy-1.0.1.post33-cp312-cp312-manylinux_2_27_x86_64.whl (10.8 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.27+ x86-64

aimmspy-1.0.1.post33-cp311-cp311-win_amd64.whl (561.3 kB view details)

Uploaded CPython 3.11Windows x86-64

aimmspy-1.0.1.post33-cp311-cp311-manylinux_2_27_x86_64.whl (10.8 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.27+ x86-64

aimmspy-1.0.1.post33-cp310-cp310-win_amd64.whl (560.8 kB view details)

Uploaded CPython 3.10Windows x86-64

aimmspy-1.0.1.post33-cp310-cp310-manylinux_2_27_x86_64.whl (10.8 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.27+ x86-64

File details

Details for the file aimmspy-1.0.1.post33.tar.gz.

File metadata

  • Download URL: aimmspy-1.0.1.post33.tar.gz
  • Upload date:
  • Size: 24.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for aimmspy-1.0.1.post33.tar.gz
Algorithm Hash digest
SHA256 00aa5fb42288a222cf883536b7f166a74786c5cc15d2781638df272016b541fd
MD5 16521b946b64c30ebe2b23e690a582cf
BLAKE2b-256 41772c24f1a9b37acd167fe73f29d53775468464c3ef7a641d99515449ef1e2f

See more details on using hashes here.

File details

Details for the file aimmspy-1.0.1.post33-cp313-cp313-win_amd64.whl.

File metadata

File hashes

Hashes for aimmspy-1.0.1.post33-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 4ff9a9fbf7e361b760dd73019effaffba24ff01cbdd3715c1f5808285f2f0b2c
MD5 32016c4a78b97c82465c341cd4c2c5fc
BLAKE2b-256 3b474d1d050e608733390101b3e91083d0361d5ff03acee6aa2314440b8dfee1

See more details on using hashes here.

File details

Details for the file aimmspy-1.0.1.post33-cp313-cp313-manylinux_2_27_x86_64.whl.

File metadata

File hashes

Hashes for aimmspy-1.0.1.post33-cp313-cp313-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 3a9e8124bd860337b1b512c674e1aa88ad06341be40c2b309826c7fb17e4bd6b
MD5 1bf8f4b90333579cef3b07f816a11405
BLAKE2b-256 b0977d31fd6ea8492623dec87e3ed2dc36db672113a68c1c74d0065028753331

See more details on using hashes here.

File details

Details for the file aimmspy-1.0.1.post33-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for aimmspy-1.0.1.post33-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 245928800f0dead0c156d566b87e0b9ea80e60949031f0167679f917561cffc5
MD5 b6049e6f2f93234bdc95f7dbfb4dfb9b
BLAKE2b-256 6cdcd56deb1eba2c0d482c522bd0e12735adc4ddf1e8265efb42bfda6c6d1e25

See more details on using hashes here.

File details

Details for the file aimmspy-1.0.1.post33-cp312-cp312-manylinux_2_27_x86_64.whl.

File metadata

File hashes

Hashes for aimmspy-1.0.1.post33-cp312-cp312-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 6585b20962bce69a0753e93cb4c77f6df8881dd61b53a7ee2ff8fb5d408fc40e
MD5 b4dec444900874e5b938a5fad274d309
BLAKE2b-256 afdfdc4349cf095b718ae8a9d65c8dd69e3986da962aac4423d5820fcfef2090

See more details on using hashes here.

File details

Details for the file aimmspy-1.0.1.post33-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for aimmspy-1.0.1.post33-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 d4e2a4d6e6fc8b898798e972e541f5fd27e36e7f0327da65e225e25e9c72dee8
MD5 2c7d26a51c5dd0a04f2c83546d451a99
BLAKE2b-256 02081659877bf9fdfc06ddb3b0656123cbb30d1b14a77d5436a7f80f7e1c3250

See more details on using hashes here.

File details

Details for the file aimmspy-1.0.1.post33-cp311-cp311-manylinux_2_27_x86_64.whl.

File metadata

File hashes

Hashes for aimmspy-1.0.1.post33-cp311-cp311-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 d4be863d1d5dedef042997f760f88f16c000a4fc88de0304763ba1174edec3a9
MD5 628bac51af2776f7822baa7b5703eb02
BLAKE2b-256 a9934a248b0aacf6316a5521ab87c04f73f27fbdb7346bd6d64458974cc39c7a

See more details on using hashes here.

File details

Details for the file aimmspy-1.0.1.post33-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for aimmspy-1.0.1.post33-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 a90b98d9b6b87975dd37403e2bdf09187533dc170289c1d7e13d9407dc5dc504
MD5 917cebd5e3e36835da8cd0daad9d6ac5
BLAKE2b-256 c4885d5685ce974429a554a8c850e1da28a74736aa41fad8f75630bc030fbb6a

See more details on using hashes here.

File details

Details for the file aimmspy-1.0.1.post33-cp310-cp310-manylinux_2_27_x86_64.whl.

File metadata

File hashes

Hashes for aimmspy-1.0.1.post33-cp310-cp310-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 04e3d453efe1dea9fedda0fe102ec455d7bb06af957a52bbc72deed15c3913b0
MD5 2fd2174ce46b4541f2ddf48194edaaf8
BLAKE2b-256 7675ea3e598af3248ccdbb358fc56b79940e35a8f2320d322f663a6b06b8cba3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page