Name | aimmspy JSON |
Version |
1.0.1.post101
JSON |
| download |
home_page | None |
Summary | 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. |
upload_time | 2025-07-11 08:20:56 |
maintainer | AIMMS B.V. |
docs_url | None |
author | AIMMS B.V. |
requires_python | >=3.10 |
license | MIT |
keywords |
aimms
api
python
optimization
operations research
pybind11
c++
bindings
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# 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.
```python
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.
```python
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.
```python
my_aimms.MainExecution()
```
It is also possible to run procedures with arguments for example:
```python
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.
```python
# 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:
```plaintext
Total Transport Cost: 150.0
Transport: {("NewYork", "Houston"): 30, ("LosAngeles", "Phoenix"): 50, ...}
```
for Pandas DataFrames can look like this:
```plaintext
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:
```python
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:
```python
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](https://community.aimms.com/p/developer-support). Or post an question on the [AIMMS Community](https://community.aimms.com/). We are happy to help you with any issues or questions you may have.
Raw data
{
"_id": null,
"home_page": null,
"name": "aimmspy",
"maintainer": "AIMMS B.V.",
"docs_url": null,
"requires_python": ">=3.10",
"maintainer_email": null,
"keywords": "AIMMS, API, Python, Optimization, Operations Research, pybind11, C++, bindings",
"author": "AIMMS B.V.",
"author_email": null,
"download_url": null,
"platform": null,
"description": "# AIMMS Python library\n\nThis is a **BETA** version of the AIMMS Python library. Any feedback, bug reports, or feature requests are welcome.\n\nWith this library it is possible to interact with AIMMS models from Python.\n\n## Features\n\n- Seamless integration with AIMMS models from Python\n- Assign and retrieve data using Python dicts, Pandas, Polars, or Arrow tables\n- Execute AIMMS procedures and retrieve results programmatically\n- Built with pybind11 for high-performance C++ integration\n- Flexible data return types for different workflows\n\n## Getting Started\n\nTo 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.\n\n### Step 1: Initialize the AIMMS Project\n\nFirst, initialize the AIMMS project by specifying the AIMMS executable path, project path, and other configurations.\n\n> **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.\n\n```python\nimport os\nfrom aimmspy.project.project import Project \nfrom aimmspy.utils import find_aimms_path\n\n# Initialize the AIMMS project\nproject = Project(\n # path to the AIMMS Bin folder (on linux the Lib folder)\n aimms_path=find_aimms_path(\"25.4.3.3\"),\n\n # path to the AIMMS project\n aimms_project_file=R\"C:\\AimmsProjects\\MyAimmsProject\\MyAimmsProject.aimms\",\n\n # url\n license_url=R\"wss://licensing.aimms.cloud/license-ws/license?profile=community&license=12345678-90ab-cdef-1234-567890abcdef\"\n)\nmy_aimms : Model = project.get_model(__file__)\n```\n\n### Step 2: Assign Data to Parameters\n\nThis is an example of assigning data to parameters with Pandas DataFrames.\n\n```python\ndemand_df = pd.DataFrame({\n \"c\": [\"Houston\", \"Phoenix\", \"Philadelphia\"],\n \"demand\": [50.0, 60.0, 40.0]\n})\n\nsupply_df = pd.DataFrame(data={\n \"w\": [\"NewYork\", \"LosAngeles\", \"Chicago\"],\n \"supply\": [70.0, 80.0, 60.0]\n})\n\nunit_transport_cost_df = pd.DataFrame({\n \"w\": [\"NewYork\", \"NewYork\", \"NewYork\", \"LosAngeles\", \"LosAngeles\", \"LosAngeles\", \"Chicago\", \"Chicago\", \"Chicago\"],\n \"c\": [\"Houston\", \"Phoenix\", \"Philadelphia\", \"Houston\", \"Phoenix\", \"Philadelphia\", \"Houston\", \"Phoenix\", \"Philadelphia\"],\n \"unit_transport_cost\": [5.0, 6.0, 4.0, 3.0, 2.0, 7.0, 4.0, 5.0, 3.0]\n})\n\nmy_aimms.demand.assign( demand_df)\nmy_aimms.supply.assign( supply_df)\nmy_aimms.unit_transport_cost.assign( unit_transport_cost_df)\n```\n\nYou 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.\n\n### Step 3: Execute the Optimization Procedure\n\nIt 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.\nIn this example we run the main procedure in the AIMMS project to solve the optimization problem.\n\n```python\nmy_aimms.MainExecution()\n```\n\nIt is also possible to run procedures with arguments for example:\n\n```python\nmy_aimms.run_procedure(test1=5.0, test2=10.0, test3=\"hello\")\n```\n\nMake sure the order of the arguments is correct, as well as the types.\n\n### Step 4: Retrieve and Display Results\n\nRetrieve the results of the optimization, such as the total transport cost and the transport plan.\n\n```python\n# Retrieve results\nprint(f\"Total Transport Cost: {my_aimms.total_transport_cost.data()}\")\nprint(f\"Transport Plan: {my_aimms.transport.data()}\")\n```\n\nThe `.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.\n\n#### Data Types Returned by `.data()`\n\ndepending on the data_type_preference you set in the `Project` constructor, the `.data()` function will return different types of Python objects:\n\n**Sets** always return a list of strings.\n\nFor **parameters** and **variables**, `.data()` can return:\n\n- A **scalar value** (e.g., `float` or `int` or `string`) if the parameter or variable is scalar.\n- A **dictionary** where the keys are tuples of strings (representing indices) and the values are `float`, `int`, `string`.\n- A **Arrow Table** or **Pandas or Polars DataFrame** depending on the data_type_preference set in the `Project` constructor.\n\n### Example Output\n\nDepending on you return type preference the python object returned from the `.data()` function will be different, the output for dictionaries can look like this:\n\n```plaintext\nTotal Transport Cost: 150.0\nTransport: {(\"NewYork\", \"Houston\"): 30, (\"LosAngeles\", \"Phoenix\"): 50, ...}\n```\n\nfor Pandas DataFrames can look like this:\n\n```plaintext\nTotal Transport Cost: 150.0\nTransport:\n w c transport\n 0 NewYork Houston 30\n 1 LosAngeles Phoenix 50\n 2 Chicago Philadelphia 40\n 3 NewYork Philadelphia 20\n```\n\n---\n\n## extra\n\nit 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:\n\n```python\nmy_aimms.generate_stub_file( \"my_project_stub.py\" )\n```\n\nTo use this stub file you can the following to the top of your python script:\n\n```python\nfrom typing import TYPE_CHECKING\nif TYPE_CHECKING:\n from my_project_stub import Project\n```\n\n## License\n\nThis project is licensed under the MIT License.\n\n## Support\n\nFor questions, bug reports, or feature requests, please contact AIMMS B.V. via [support](https://community.aimms.com/p/developer-support). Or post an question on the [AIMMS Community](https://community.aimms.com/). We are happy to help you with any issues or questions you may have.\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "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.",
"version": "1.0.1.post101",
"project_urls": null,
"split_keywords": [
"aimms",
" api",
" python",
" optimization",
" operations research",
" pybind11",
" c++",
" bindings"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "89c5660af87c21130a244dc83e553e134b3e3d55b60f22200f23226b2d752871",
"md5": "520f605b91ee4b64dda57d9e89c533ad",
"sha256": "cc414cfd8fc5a052e5979a7d4faf6ea5e1d31d99bde586f3abe66e47e64ef043"
},
"downloads": -1,
"filename": "aimmspy-1.0.1.post101-cp310-cp310-manylinux_2_27_x86_64.whl",
"has_sig": false,
"md5_digest": "520f605b91ee4b64dda57d9e89c533ad",
"packagetype": "bdist_wheel",
"python_version": "cp310",
"requires_python": ">=3.10",
"size": 749604,
"upload_time": "2025-07-11T08:20:56",
"upload_time_iso_8601": "2025-07-11T08:20:56.190952Z",
"url": "https://files.pythonhosted.org/packages/89/c5/660af87c21130a244dc83e553e134b3e3d55b60f22200f23226b2d752871/aimmspy-1.0.1.post101-cp310-cp310-manylinux_2_27_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "43dd7496b37f44365a4b155ce5b9e0f2380364369ef36fcfd18247a717a80fa1",
"md5": "3eda6d48032c9ef02cb9bc33311700ae",
"sha256": "922a0ccf1e2a85d63a3247696f88c4235f282772c0872aebdca5005237d0da21"
},
"downloads": -1,
"filename": "aimmspy-1.0.1.post101-cp310-cp310-win_amd64.whl",
"has_sig": false,
"md5_digest": "3eda6d48032c9ef02cb9bc33311700ae",
"packagetype": "bdist_wheel",
"python_version": "cp310",
"requires_python": ">=3.10",
"size": 596018,
"upload_time": "2025-07-11T08:21:02",
"upload_time_iso_8601": "2025-07-11T08:21:02.112533Z",
"url": "https://files.pythonhosted.org/packages/43/dd/7496b37f44365a4b155ce5b9e0f2380364369ef36fcfd18247a717a80fa1/aimmspy-1.0.1.post101-cp310-cp310-win_amd64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "830f27d5313bf12d6c940265c009c409d9d752c15b305ebe1b4c40d8a95129d2",
"md5": "9d202fdb0cb1fd7ec2d603feb76f784c",
"sha256": "2bb343a50e0749a38b5ae3dabda43724f1468fb104e73487143bd1bd29a3ebbc"
},
"downloads": -1,
"filename": "aimmspy-1.0.1.post101-cp311-cp311-manylinux_2_27_x86_64.whl",
"has_sig": false,
"md5_digest": "9d202fdb0cb1fd7ec2d603feb76f784c",
"packagetype": "bdist_wheel",
"python_version": "cp311",
"requires_python": ">=3.10",
"size": 750939,
"upload_time": "2025-07-11T08:21:00",
"upload_time_iso_8601": "2025-07-11T08:21:00.785866Z",
"url": "https://files.pythonhosted.org/packages/83/0f/27d5313bf12d6c940265c009c409d9d752c15b305ebe1b4c40d8a95129d2/aimmspy-1.0.1.post101-cp311-cp311-manylinux_2_27_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "d83ad91af7cda01e035d794edbd8d63761835451710d0f4ba1e4cd5d6278d228",
"md5": "22dec7f3011a90e2e98d0f0eb796d5d2",
"sha256": "821820a7dc180db93ebd438d6af5b0daee3b2f0966e5b391b8ca9b0a9e0a52af"
},
"downloads": -1,
"filename": "aimmspy-1.0.1.post101-cp311-cp311-win_amd64.whl",
"has_sig": false,
"md5_digest": "22dec7f3011a90e2e98d0f0eb796d5d2",
"packagetype": "bdist_wheel",
"python_version": "cp311",
"requires_python": ">=3.10",
"size": 596809,
"upload_time": "2025-07-11T08:20:54",
"upload_time_iso_8601": "2025-07-11T08:20:54.237761Z",
"url": "https://files.pythonhosted.org/packages/d8/3a/d91af7cda01e035d794edbd8d63761835451710d0f4ba1e4cd5d6278d228/aimmspy-1.0.1.post101-cp311-cp311-win_amd64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "dae8432c0139f2fe95c6dedd5dd88cb12f3742195906bb39f4bab70475616ae1",
"md5": "4dba79338f55e6876f1c37a1eb43aa77",
"sha256": "cb83ef951af925f7a76590dedfa57bfc12074148bcd014c3f31cc180ea21f120"
},
"downloads": -1,
"filename": "aimmspy-1.0.1.post101-cp312-cp312-manylinux_2_27_x86_64.whl",
"has_sig": false,
"md5_digest": "4dba79338f55e6876f1c37a1eb43aa77",
"packagetype": "bdist_wheel",
"python_version": "cp312",
"requires_python": ">=3.10",
"size": 751823,
"upload_time": "2025-07-11T08:21:05",
"upload_time_iso_8601": "2025-07-11T08:21:05.187098Z",
"url": "https://files.pythonhosted.org/packages/da/e8/432c0139f2fe95c6dedd5dd88cb12f3742195906bb39f4bab70475616ae1/aimmspy-1.0.1.post101-cp312-cp312-manylinux_2_27_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "9f4ccd2892f9e341b0ff73cc2cf053a837ce7524a1bd4b9a0178f4d4324162ac",
"md5": "b70c16b28006c8084e60eadab9c7ba4e",
"sha256": "f7f1d63457d58d7d92939d8c1996339c6c77d977f54b1778715b2c62b1f41aec"
},
"downloads": -1,
"filename": "aimmspy-1.0.1.post101-cp312-cp312-win_amd64.whl",
"has_sig": false,
"md5_digest": "b70c16b28006c8084e60eadab9c7ba4e",
"packagetype": "bdist_wheel",
"python_version": "cp312",
"requires_python": ">=3.10",
"size": 596610,
"upload_time": "2025-07-11T08:21:03",
"upload_time_iso_8601": "2025-07-11T08:21:03.614967Z",
"url": "https://files.pythonhosted.org/packages/9f/4c/cd2892f9e341b0ff73cc2cf053a837ce7524a1bd4b9a0178f4d4324162ac/aimmspy-1.0.1.post101-cp312-cp312-win_amd64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "e49a3c5c3cd972c89c382d39c6c39bb30a5f10fc76499694ca8f887fe75a9df4",
"md5": "8849232e7ab70f1aa036ee025601a6f4",
"sha256": "6b762850c65e0e9b2384b661555fb97744d5a1015a8eebfec7465814313be906"
},
"downloads": -1,
"filename": "aimmspy-1.0.1.post101-cp313-cp313-manylinux_2_27_x86_64.whl",
"has_sig": false,
"md5_digest": "8849232e7ab70f1aa036ee025601a6f4",
"packagetype": "bdist_wheel",
"python_version": "cp313",
"requires_python": ">=3.10",
"size": 751928,
"upload_time": "2025-07-11T08:20:57",
"upload_time_iso_8601": "2025-07-11T08:20:57.596485Z",
"url": "https://files.pythonhosted.org/packages/e4/9a/3c5c3cd972c89c382d39c6c39bb30a5f10fc76499694ca8f887fe75a9df4/aimmspy-1.0.1.post101-cp313-cp313-manylinux_2_27_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "504c126bc75d87fe4931819dd1d7d05339f66a4af80790ce1a0e8714fb6f9d4c",
"md5": "930665a7dc8173cd4072b597928a4311",
"sha256": "f414b92a5c7de5313efc9588ee8a699eda0278aac73b198e16ea805b87d84e63"
},
"downloads": -1,
"filename": "aimmspy-1.0.1.post101-cp313-cp313-win_amd64.whl",
"has_sig": false,
"md5_digest": "930665a7dc8173cd4072b597928a4311",
"packagetype": "bdist_wheel",
"python_version": "cp313",
"requires_python": ">=3.10",
"size": 596567,
"upload_time": "2025-07-11T08:20:58",
"upload_time_iso_8601": "2025-07-11T08:20:58.963849Z",
"url": "https://files.pythonhosted.org/packages/50/4c/126bc75d87fe4931819dd1d7d05339f66a4af80790ce1a0e8714fb6f9d4c/aimmspy-1.0.1.post101-cp313-cp313-win_amd64.whl",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-07-11 08:20:56",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "aimmspy"
}