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 it is 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

Getting Started

To use the AIMMS Python library, you need to have an AIMMS developer version installed (see https://www.aimms.com/support/downloads/), a valid license (see https://licensing.aimms.cloud/license) and an already existing 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 (or Lib on linux) folder of an installed AIMMS version. You use can the utility function find_aimms_path to automatically search your system for that path.

import os

from aimmspy.project.project import DataReturnTypes, Project, AimmsException, AimmsPyException, Model
from aimmspy.utils import find_aimms_path


# Initialize the AIMMS project
project = Project(
    # path to the AIMMS Bin folder (on linux the Lib folder)
    aimms_path=find_aimms_path("25.4.3.3"),

    # path to the AIMMS project
    aimms_project_file=R"C:\AimmsProjects\MyAimmsProject\MyAimmsProject.aimms",

    # url
    license_url=R"wss://licensing.aimms.cloud/license-ws/license?profile=community&license=12345678-90ab-cdef-1234-567890abcdef"
)
my_aimms : Model = project.get_model(__file__)

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="hello")

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 Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

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

aimmspy-1.0.1.post133-cp313-cp313-win_amd64.whl (583.7 kB view details)

Uploaded CPython 3.13Windows x86-64

aimmspy-1.0.1.post133-cp313-cp313-manylinux_2_27_x86_64.whl (740.9 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.27+ x86-64

aimmspy-1.0.1.post133-cp312-cp312-win_amd64.whl (583.8 kB view details)

Uploaded CPython 3.12Windows x86-64

aimmspy-1.0.1.post133-cp312-cp312-manylinux_2_27_x86_64.whl (741.5 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.27+ x86-64

aimmspy-1.0.1.post133-cp311-cp311-win_amd64.whl (583.9 kB view details)

Uploaded CPython 3.11Windows x86-64

aimmspy-1.0.1.post133-cp311-cp311-manylinux_2_27_x86_64.whl (739.2 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.27+ x86-64

aimmspy-1.0.1.post133-cp310-cp310-win_amd64.whl (583.0 kB view details)

Uploaded CPython 3.10Windows x86-64

aimmspy-1.0.1.post133-cp310-cp310-manylinux_2_27_x86_64.whl (738.5 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.27+ x86-64

File details

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

File metadata

File hashes

Hashes for aimmspy-1.0.1.post133-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 621fd6620fe15d316a742c46a80384baa0c094bbef6492a4726c2550e39fd5b6
MD5 2075d9dd58acace306d75fd0d554173f
BLAKE2b-256 2339fef8cc87284c3b2a616ec131794a5e1a8a9d77580005d93a7e01eed491eb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for aimmspy-1.0.1.post133-cp313-cp313-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 1db3588d3fec0c55d07aba86a924dfd1ed76a37166a9c0846bd40b9f440628c8
MD5 a60e2ac30b25dcb68001e5d822e00a77
BLAKE2b-256 6f612bee4c99b113d533eca68db9feb269d70a9ce3e75accf673f8856bbfc28c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for aimmspy-1.0.1.post133-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 77acd01cdd43480731c9c4be5b779645421ccb0f9dc49ca6a7f80ff9970f23dd
MD5 23bce6c5453fb7732f5690bf85579ed5
BLAKE2b-256 6f878e064fa109fba0d99db29d59274e57a2409b92ceb5e2d55b4e8c04e7af93

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for aimmspy-1.0.1.post133-cp312-cp312-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 5080bb31f7c49a80d5d7dc808efe692b1f95df8797accb45fa5735ff3d6a1120
MD5 0596ddbeefa77e0b2fdbcbc3f5af5dbe
BLAKE2b-256 2c9599640d67d57fd8ae0684a51f534a81aa4a6ce5e02b8bde73b0996380e4de

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for aimmspy-1.0.1.post133-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 e1e7d9d9d9b0ca02e80589c126ffb768b12de770da5b157ad502b8273b0279a1
MD5 e4f1baf01a00ded2515c0f97fa887ec9
BLAKE2b-256 84dda1875cf0f447c5b69b44066b2268ea7be817223be2649e68425a5c3e76cb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for aimmspy-1.0.1.post133-cp311-cp311-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 7a92c6127c581ca2e126dbf6ae3f48c131f03bfa3ee253f5d99e23fc936c5c8c
MD5 a50fe94e07edae217d6320a81b5b678c
BLAKE2b-256 aa12b51071eea445a5b4ac50eaed15e91e710891029113c95911976bceb0fcae

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for aimmspy-1.0.1.post133-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 9dfa11da4371b5259051720f95d45e87151e3324cb87e9223af3aed0f12f7ad4
MD5 f46fb86076e1c1e09f6658bb08a985fb
BLAKE2b-256 d70627b483f0d52b27d056223c1f8ed1aa5bb60baf827f22963654497a0aff10

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for aimmspy-1.0.1.post133-cp310-cp310-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 bdf613c3aa359beca2bc6b1cc07c940b1b74fad7ddc85d65fd1b0f5cb3df1afd
MD5 b728674201c30e9ea25bb83845b30846
BLAKE2b-256 58a5d91409543d5bde08d4c16afa2bf9287ad40d3bd5c8b23faf87cfd1f50aaf

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