Skip to main content

This year we will develop and release aimmspy, a Python library that will allow you to combine the power and convenience of Python with the well-known strengths of AIMMS

We already spent quite a lot of time designing the functionality of this library, but we are keen to hear your thoughts and ideas. And we are purposely not sharing our ideas to prevent directing your thinking 😎.

Can you please share your thoughts on what you would like to see in such a library, as reply to this post? And if you prefer to share your ideas in a live conversation, please email me at j.w.van.crevel@aimms.com. I will then reach out to make an appointment.

Looking forward to hearing your thoughts, needs, etcetera!

This is great - I’m really looking forward to this. To answer your question, it would be great to be able to access directly the AIMMS data tables (for both parameters and variables) as data frames in Pandas.


Thank you!


What I could see myself using this for would be:

  • Use python as a “conductor”:
    • Load/transform data, apply a (non-optimization) model to the data, then output my dataframes directly into AIMMS parameters
    • Execute the optimization model
    • Read AIMMS results back into dataframes for analysis
  • Alter sets programmatically (e.g., if I have a subset of AllConstraints, add or remove values)
  • Scenario analysis: flag a parameter, set a value range, then loop through executions and write results to a dataframe

Thanks John! Really nice ideas.


Another suggestion: it would be nice if in aimmspy, we can use the AIMMS modelling language directly in the Python IDE to define our model, so for us who prefer to use Python we don’t have to switch between different environments and can do everything in Python.


I would love to see the following workflows:

  1. An AIMMS (WebUI button) procedure triggering a Python procedure to do data  manipulations: 1) grab data from somewhere, make transformations, return to AIMMS or 2) make transformations and send data somewhere. I wonder if things being stateful on the Python side is useful, for e.g., some authentication steps that need not be repeated. The key benefit we see with Python is leveraging MSAL (Microsoft Authentication Library) and other libs for databricks, etc. to authenticate and do data ETL steps.
  2. An external Python app that can call AIMMS app just for optimization (as a background job/service): Currently, this can be done via a REST API served on the AIMMS app side but some of these XML mappings for data transfer can be tricky. I wonder if a sidecar Python app deployed along with AIMMS app can simplify this orchestration on the AIMMS optimization service server side.
  3. Bringing in a Python optimization model constraints into AIMMS: It would be great to bring in optimization model variables and constraints in Pyomo or other standard math programming notation into AIMMS as a runtime lib and integrated with AIMMS optimization model. This would be significant for ML+Opt applications. For e.g., we could accomplish the following:
    1. We could have a data science team developing surrogate models for their applications in scikit-learn or other Python packages and maintaining pickle files for these models.
    2. The AIMMS user can indicate a specific ML model to select in the AIMMS WebUI. The Python procedure can grab the corresponding pickle file and load that into memory.
    3. A package like OMLT, which is actively developed by the community, can generate math programming formulation (In Pyomo or other modeling system convention) to represent these ML based surrogate models.
    4. Use the string representation of these constraints and the set of variables to automatically generate AIMMS optimization model as a runtime library. These sets of constraints can then be included in the larger AIMMS optimization model.

I believe having a 1:1 AIMMS:DataFrame in Python would enable #1 and #2 above and could unlock other potential workflows. I understand there may be opinions on the Python side in terms of libraries but hopefully Pandas and Polars should suffice with support for any other Python packages.

The reason for #3 is that the surrogate model itself is a small portion of the AIMMS optimization model. And these models are developed and maintained by data scientists who do not have a background in AIMMS and/or math programming to formulate them as constraints, which also may not be straightforward. Keeping the overall application in AIMMS helps us build the web app faster with a focus on the rest of the math program. In fact, this is a real application use-case for us today! We spent quite a bit of time to get the parameters of a trained neural network ML model modeled as constraints in an AIMMS math program. And often, the architecture of the neural network or even the type of ML models change (for e.g., random forests instead of neural networks).

Looking forward to the February 6th session to learn more and discuss about this topic. Cheers!


Others have covered important features for the aimmspy library.

In addition to the python library, the ability to install Python virtual environment within an AIMMS app’s execution environment by pointing to a requirements.txt file in the AIMMS project folder can be helpful. That way Execute(‘python python_script.py’) can be used to perform multiple helper tasks


Reply


Didn't find what you were looking for? Try searching on our documentation pages:

AIMMS Developer & PRO | AIMMS How-To | AIMMS SC Navigator