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

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.cloud.aimms.com/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.

import os
from aimms.project.project import DataReturnTypes, Project 

# Initialize the AIMMS project
my_aimms = Project(
    # path to the AIMMS Bin folder (on linux the Lib folder)
    aimms_path=os.path.join(os.getenv("LOCALAPPDATA"), "AIMMS", "IFA", "Aimms", "25.4.3.3-x64-VS2022", "Bin"),

    # 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"
)

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.post49-cp313-cp313-win_amd64.whl (563.1 kB view details)

Uploaded CPython 3.13Windows x86-64

aimmspy-1.0.1.post49-cp313-cp313-manylinux_2_27_x86_64.whl (717.9 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.27+ x86-64

aimmspy-1.0.1.post49-cp312-cp312-win_amd64.whl (563.2 kB view details)

Uploaded CPython 3.12Windows x86-64

aimmspy-1.0.1.post49-cp312-cp312-manylinux_2_27_x86_64.whl (717.5 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.27+ x86-64

aimmspy-1.0.1.post49-cp311-cp311-win_amd64.whl (561.4 kB view details)

Uploaded CPython 3.11Windows x86-64

aimmspy-1.0.1.post49-cp311-cp311-manylinux_2_27_x86_64.whl (717.1 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.27+ x86-64

aimmspy-1.0.1.post49-cp310-cp310-win_amd64.whl (560.9 kB view details)

Uploaded CPython 3.10Windows x86-64

aimmspy-1.0.1.post49-cp310-cp310-manylinux_2_27_x86_64.whl (716.1 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.27+ x86-64

File details

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

File metadata

File hashes

Hashes for aimmspy-1.0.1.post49-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 0c4126d815b8169212a14da5f716efe1984c7174c8c9adf95c7a5d919078dd91
MD5 665edb555d6e08271e73e8877d654aef
BLAKE2b-256 474a3a95113a4a2634dfca9df3be7ad830b80d9a4cfa779c30df79d2eab4aa12

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for aimmspy-1.0.1.post49-cp313-cp313-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 64308b66f89b9bd2a1cacd181d6111b1138b418cfea631c8225a8726b026d828
MD5 746b0de3fad29e6296e6f5a7d6fb1017
BLAKE2b-256 fee4c14964c1928774678d57c8d13b2e2d214323e8e729fc5385bd4bfaf78e65

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for aimmspy-1.0.1.post49-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 84cad4801dc80d0b88a4bf81823155bdc51c47d5dceb6dca4b736438a230ef36
MD5 953eff0435675ae8eab0a00f17087a6e
BLAKE2b-256 31e4457138798f0ab66aad31e6b8a5c4cb5531bd39b6897ec7a184d47f8d833b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for aimmspy-1.0.1.post49-cp312-cp312-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 8985f316173e247f258d07cb24fde3deacb69e9dc2c1a4be8f25eadbd5b822db
MD5 cd5c6dce041231f8cf20a0c9a4fae451
BLAKE2b-256 95400dac8b44f813d45d605c7082354ce4c3be65a843face8dc27f622bf92ee6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for aimmspy-1.0.1.post49-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 dcf42f5ecd66e0deefcca1b523f1af680cb0e55c11f997c5570e334f4cb56a29
MD5 ca9dca919bf605ad6c1d53799a29e237
BLAKE2b-256 ca6e84c60cbdcc5451a3264a618ba9e2b4f4be675b104b042d019f9f879df9bf

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for aimmspy-1.0.1.post49-cp311-cp311-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 85347e17b1fbc9083d1fe37ff151af8caba8cc04792f8780829d18e3774422c9
MD5 a5d85f03879aae7fe13f3fdc8a23ec9f
BLAKE2b-256 d37d2ddc0aa1c2292451a871780d81782d21b50dac9b0d96a5782222af8cd8fd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for aimmspy-1.0.1.post49-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 bdae6d875b70b3bb833eaac8d109f09e9fdaf83f614ea46ddaae1ac2da44addb
MD5 1e2818314d65422b862093a925efbb64
BLAKE2b-256 95cacd989e3a5e72cdbb37241ce6da7e755391b490e2b46e98be3999bf500770

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for aimmspy-1.0.1.post49-cp310-cp310-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 1d1876be44ee434d6a4aefc316df71875b991fd940aa1ec09b99f58b83c8a7c8
MD5 a611eef6f1c12a4c8bec55433c338d00
BLAKE2b-256 2c90735284ea957e769d7ca3a716b0c16be6a56a1002030c77efbcc2c5a91436

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