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 Project 
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.post101-cp313-cp313-win_amd64.whl (596.6 kB view details)

Uploaded CPython 3.13Windows x86-64

aimmspy-1.0.1.post101-cp313-cp313-manylinux_2_27_x86_64.whl (751.9 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.27+ x86-64

aimmspy-1.0.1.post101-cp312-cp312-win_amd64.whl (596.6 kB view details)

Uploaded CPython 3.12Windows x86-64

aimmspy-1.0.1.post101-cp312-cp312-manylinux_2_27_x86_64.whl (751.8 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.27+ x86-64

aimmspy-1.0.1.post101-cp311-cp311-win_amd64.whl (596.8 kB view details)

Uploaded CPython 3.11Windows x86-64

aimmspy-1.0.1.post101-cp311-cp311-manylinux_2_27_x86_64.whl (750.9 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.27+ x86-64

aimmspy-1.0.1.post101-cp310-cp310-win_amd64.whl (596.0 kB view details)

Uploaded CPython 3.10Windows x86-64

aimmspy-1.0.1.post101-cp310-cp310-manylinux_2_27_x86_64.whl (749.6 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.27+ x86-64

File details

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

File metadata

File hashes

Hashes for aimmspy-1.0.1.post101-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 f414b92a5c7de5313efc9588ee8a699eda0278aac73b198e16ea805b87d84e63
MD5 930665a7dc8173cd4072b597928a4311
BLAKE2b-256 504c126bc75d87fe4931819dd1d7d05339f66a4af80790ce1a0e8714fb6f9d4c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for aimmspy-1.0.1.post101-cp313-cp313-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 6b762850c65e0e9b2384b661555fb97744d5a1015a8eebfec7465814313be906
MD5 8849232e7ab70f1aa036ee025601a6f4
BLAKE2b-256 e49a3c5c3cd972c89c382d39c6c39bb30a5f10fc76499694ca8f887fe75a9df4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for aimmspy-1.0.1.post101-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 f7f1d63457d58d7d92939d8c1996339c6c77d977f54b1778715b2c62b1f41aec
MD5 b70c16b28006c8084e60eadab9c7ba4e
BLAKE2b-256 9f4ccd2892f9e341b0ff73cc2cf053a837ce7524a1bd4b9a0178f4d4324162ac

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for aimmspy-1.0.1.post101-cp312-cp312-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 cb83ef951af925f7a76590dedfa57bfc12074148bcd014c3f31cc180ea21f120
MD5 4dba79338f55e6876f1c37a1eb43aa77
BLAKE2b-256 dae8432c0139f2fe95c6dedd5dd88cb12f3742195906bb39f4bab70475616ae1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for aimmspy-1.0.1.post101-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 821820a7dc180db93ebd438d6af5b0daee3b2f0966e5b391b8ca9b0a9e0a52af
MD5 22dec7f3011a90e2e98d0f0eb796d5d2
BLAKE2b-256 d83ad91af7cda01e035d794edbd8d63761835451710d0f4ba1e4cd5d6278d228

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for aimmspy-1.0.1.post101-cp311-cp311-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 2bb343a50e0749a38b5ae3dabda43724f1468fb104e73487143bd1bd29a3ebbc
MD5 9d202fdb0cb1fd7ec2d603feb76f784c
BLAKE2b-256 830f27d5313bf12d6c940265c009c409d9d752c15b305ebe1b4c40d8a95129d2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for aimmspy-1.0.1.post101-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 922a0ccf1e2a85d63a3247696f88c4235f282772c0872aebdca5005237d0da21
MD5 3eda6d48032c9ef02cb9bc33311700ae
BLAKE2b-256 43dd7496b37f44365a4b155ce5b9e0f2380364369ef36fcfd18247a717a80fa1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for aimmspy-1.0.1.post101-cp310-cp310-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 cc414cfd8fc5a052e5979a7d4faf6ea5e1d31d99bde586f3abe66e47e64ef043
MD5 520f605b91ee4b64dda57d9e89c533ad
BLAKE2b-256 89c5660af87c21130a244dc83e553e134b3e3d55b60f22200f23226b2d752871

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