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

Uploaded CPython 3.13Windows x86-64

aimmspy-1.0.1.post113-cp313-cp313-manylinux_2_27_x86_64.whl (740.7 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.27+ x86-64

aimmspy-1.0.1.post113-cp312-cp312-win_amd64.whl (583.6 kB view details)

Uploaded CPython 3.12Windows x86-64

aimmspy-1.0.1.post113-cp312-cp312-manylinux_2_27_x86_64.whl (741.2 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.27+ x86-64

aimmspy-1.0.1.post113-cp311-cp311-win_amd64.whl (583.7 kB view details)

Uploaded CPython 3.11Windows x86-64

aimmspy-1.0.1.post113-cp311-cp311-manylinux_2_27_x86_64.whl (739.0 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.27+ x86-64

aimmspy-1.0.1.post113-cp310-cp310-win_amd64.whl (582.7 kB view details)

Uploaded CPython 3.10Windows x86-64

aimmspy-1.0.1.post113-cp310-cp310-manylinux_2_27_x86_64.whl (738.3 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.27+ x86-64

File details

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

File metadata

File hashes

Hashes for aimmspy-1.0.1.post113-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 05b3f2af55d29eca1f6f9745605e59bcb9275d3145797d63bb1ecb591b74029a
MD5 c26d74acbc3794fc3ec6f5d3931f0ebf
BLAKE2b-256 5f2b8be79d18d4a2d197cabb04d5c2a072357da0a556a1ddadd29489fca10c5a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for aimmspy-1.0.1.post113-cp313-cp313-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 79f9485e511b8971be59422d908eca371a167c861996b29294ae1145d8f31c21
MD5 26b7ae7ae8f9416a18334417eb58f589
BLAKE2b-256 f1161e4b608a5a192eee4fa960673ec725c4640d016177e75d48714195e62558

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for aimmspy-1.0.1.post113-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 b459f52c72726c57e3091ff190a02624991d900ceff902290b58c7061d1957c1
MD5 cf37093808bcbc2531a43918e2de6e72
BLAKE2b-256 e61102b04f59e647137c45e509be207ffc67eba5446fdb79dc347a7ef8601bf2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for aimmspy-1.0.1.post113-cp312-cp312-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 39cb4b77d9714da3709e07cd73dcebb5e548a052cea2e51c26db796557825424
MD5 ecfbac8579ebd4c7359f44d7d11b68ee
BLAKE2b-256 79e7359b99c499042854e7f6ab492fcee800ba61f30b14cec7a19308e6b0cd34

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for aimmspy-1.0.1.post113-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 227e7d18f04e68628e21ac8f0560872164ecb6792dcd2bb3d47780e8be0eca53
MD5 88ba63994bf07e841c85dca54d8b66d3
BLAKE2b-256 79d18f57d8cff2d9fbdceac275febc8d1b7a4e060f4895604ab01638530afb3d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for aimmspy-1.0.1.post113-cp311-cp311-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 7351ba3a0911ee6601f7405969a1ed72160560ac8b2c252f14d4f02065e1b7a6
MD5 8022f354d1feca90ddb5cf425f83b880
BLAKE2b-256 61f35072b58b1747acd08d0448c7a2fc8d80d59f42465e9a4237e364509c7491

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for aimmspy-1.0.1.post113-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 96f061705a93a3541b4a41ff4efe11a5c6c45cb13d213847d489beb37c8cbee8
MD5 96e67aa1adac47bdfbb23bb8c73074f9
BLAKE2b-256 949f76941855837fc11170fb5485af9f1ae55558a419579ab70de2e4a1b6c24b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for aimmspy-1.0.1.post113-cp310-cp310-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 6be9ffe92a0cfbd9b835cc8fcabc50355b36a7626482b8ae5709ebb57f743a45
MD5 ea5cbea0a6926f313de5d50d688a86cc
BLAKE2b-256 3aff136773c66401036b8eb5fd3216241c5d7297602bbeccf212eb7073dd095f

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