Solved

Getting a 'Starting up Aimms failed' error when linking to Python

  • 17 February 2021
  • 4 replies
  • 139 views

Hiya! I’m completely new to AIMMS so apologies if this is a really fundamental thing to ask. 

I’ve been working on a model that I would like to call from within Python using AimmsCmd - for now while I’m just trying to get it to work, my code in Python linking to AIMMS is pretty much identical to the script in the guide to running batch commands:

aimmsPath = "C:\\Users\\44750\\AppData\\Local\\AIMMS\\IFA\\Aimms\\4.77.4.5-x64-VS2017\\Bin\\AimmsCmd.exe"

command = aimmsPath + " solver.aimms < cmds.txt > log.txt"

solve = subprocess.call(command, shell=True)

log = open("log.txt","r")

print(log.read())

log.close()

When I execute it however, I get this error:

Error: Unable to open AIMMS with "--as-server --ignore-dialogs --hidden  "solver.aimms"": Starting up Aimms failed. Program initialization error.

Thinking it was probably my model or my code that was flagging up the error, I downloaded the StandAlone example from that same guide and copypasted the Python script - but it returned the exact same error. Does anyone have any idea how I could fix this?

Just in case it is my model after all, I’ll paste my cmds.txt file and model here too.

 

Model Main_solver {     
Parameter s {         
IndexDomain: (i,j);         
Range: free;     
}     
Parameter t {         
IndexDomain: i;         
Range: free;     
}     
Parameter r {         
IndexDomain: i;         
Range: free;     
}     
Variable x {         
IndexDomain: j;         
Range: {             
{0..2}         
}     
}     
Variable y {         
IndexDomain: i;         
Range: {             
{0..2}         
}     
}     
Variable totalTiles {         
Range: free;         
Definition: sum[ i, y(i) ];     
}     
Set setsJ {         
Index: j;         
Definition: {             
{ 1 .. 1173 }         
}     
}     
Set tilesI {         
Index: i;         
Definition: {             
{ 1 .. 53 }         
}     
}     
Constraint constraint1 {         
IndexDomain: i;         
Definition: sum[ j, s(i,j) * x(j) ] = t(i) + y(i);     
}     
Constraint constraint2 {         
IndexDomain: i;         
Definition: y(i) <= r(i);     
}     
MathematicalProgram rummikubProblem {         
Objective: totalTiles;         
Direction: maximize;         
Constraints: AllConstraints;         
Variables: AllVariables;         
Type: Automatic;     
}

 

Many thanks in advance!

 

icon

Best answer by MarcelRoelofs 28 May 2021, 15:17

View original

4 replies

Userlevel 3
Badge +4

Hi May,

Thanks for reporting this. This is one of the cases of using the new academic licensing scheme we just introduced, that needs some work on our side to support well. 

I need to do some thinking and adaptations and will get back to you when I have a solution.

Although it may delay your work a little bit, you’re providing us with very valuable use cases how we can improve the new academic licensing scheme.

 

No worries at all, thank you very much for your response! In the meantime, is there an alternative way to call AIMMS from Python that would work with my license? @MarcelRoelofs 

Userlevel 3
Badge +4

Hi @m.bui03

We've released version 1.2 of the Data Exchange library which offers the capability to expose your model via a REST API, you can find the documentation on https://documentation.aimms.com/dataexchange/rest.html.

To call your model from within your Python code, you can use the Python requests module.

Prior to making the request, you can call the AIMMS launcher with your project from within Python to get the model ready to accept requests if need be (notice that you will have to accept the use conditions once every day, preventing completely automated continuous runs). You can skip this step if you already have opened your AIMMS project manually.

When calling the REST API, you can either use query parameters in the POST URL to pass e.g. the location of a data file to use or other parameters to configure the optimization, or you can pass the data as the request body and use the Data Exchange library to read it into identifiers in your model, and similarly for the model output.

Badge

Hi May,

Thanks for reporting this. This is one of the cases of using the new academic licensing scheme we just introduced, that needs some work on our side to support well. 

I need to do some thinking and adaptations and will get back to you when I have a solution.

Although it may delay your work a little bit, you’re providing us with very valuable use cases how we can improve the new academic licensing scheme.

 

Hi Marcel, have you been able to resolve this? I aslo have an academic license and encountering the same problem. the reason I am trying to run aimms from cmd line is to try to encrypt part of my model (a library) so i can share my part encrypted model. Perhaps anyone could help with the question of encrypting part of a source code?

many thanks

Reply


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

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