10
$\begingroup$

I want to run a model written in Pyomo language with CPLEX solver of GAMS. However I get the following error:

"No 'gams' command found on system PATH - GAMS shell"
NameError: No 'gams' command found on system PATH - GAMS shell solver 
functionality is not available. "

I have added the folder (C:\GAMS\win64\25.1) to environmental variables of system. Pyomo version is 5.6.5. Python is 3.5.2. and GAMS is 25.1.2

I would be grateful if you could provide me with help.

solvername = 'gams'
opt = SolverFactory(solvername)
results = opt.solve(
    instance, solver='cplex', keepfiles=True, tee=True)
$\endgroup$
  • 1
    $\begingroup$ Welcome to OR.SE, you wrote a model in PYOMO and want to solve it using the solvers in GAMS, right? This link (gams.com/latest/docs/S_PYOMO.html) explained the opposite. Which one is the model solving environment for you, Python or GAMS? $\endgroup$ – Oguz Toragay Aug 7 '19 at 13:46
  • 1
    $\begingroup$ @OguzToragay Hi. Thank you. I want to use cplex solver of GAMS from a code written in Python. $\endgroup$ – rgholizadehr Aug 7 '19 at 14:11
  • $\begingroup$ look at this question which is very similar to what you have asked. stackoverflow.com/q/48222658 $\endgroup$ – Oguz Toragay Aug 7 '19 at 14:45
  • $\begingroup$ Welcome to OR.SE, GAMS is a powerful modelling language and it has a specific python API. would you try this? $\endgroup$ – A.Omidi Aug 8 '19 at 19:20
4
$\begingroup$

The syntax that you are using in your Pyomo code is correct and you should be able to access the GAMS solvers once Pyomo is able to find GAMS. As the error mentions, the GAMS command is not found in the system PATH. I would double check if the GAMS path is correctly added to the system PATH. A way of doing so is opening a command prompt (since you are using Windows cmd.exe or the PowerShell) and writing gams. It should show your license details as follows

PS C:\Users\debernal> gams
--- Job ? Start 08/08
/19 03:32:16 25.1.0 r944b73f WEX-WEI x86 64bit/MS Windows
*** GAMS Base Module 27.2.0 r944b73f Released May 23, 2019 WEI x86 64bit/MS Window
***
*** GAMS Development Corporation
...

The Pyomo-GAMS interface is able to access both the GAMSShell solver (through the environment variable) and the GAMSDirect solver (which is GAMS Python API). To install the last one you need to run the code python setup.py install in the directory C:\GAMS\win64\25.1\apifiles\Python\api_36\ (adjust if you use different versions of Python/GAMS than the ones mentioned by the OP). More instructions can be found here.

| improve this answer | |
$\endgroup$
2
$\begingroup$

One way to use CPLEX solver of GAMS in Pyomo (I am assuming you have a license for GAMS and CPLEX itself licensed for your GAMS, In other words, your CPLEX solver can only be used by GAMS) is that:

You can use GAMS Writer in Pyomo to translate your model from Pyomo into a format that can be read by GAMS and then use GAMS to solve the model.

In this link, there are two more ways by them you can use GAMS solvers in Pyomo.

| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.