Cplex Working Directory in Temp folder. Can't read parameter file

Questions on using the GAMS APIs (Python, .NET, etc.)
Post Reply
tedmed
User
User
Posts: 1
Joined: 2 months ago

Cplex Working Directory in Temp folder. Can't read parameter file

Post by tedmed » 2 months ago

Hey everyone,

I am running a GAMS code from my python script. The GAMS code contains a cplex.opt file to adjust the CPLEX parameters when the GAMS code is running. However, when I run the python code, the CPLEX WORKDIR is for some reason the temporary files in windows. I've tried explicitly changing the option file directory with 'Optdir' property in Python yet to no avail, the GAMS code gives me the following error :

*** Error Cannot open parameter file "C:\Users\...\AppData\Local\Temp\tmps5srmhnw\cplex.opt"
*** Error Error code = 2; No such file or directory


I've also tried specfiying the workdirectory from the terminal by using the 'InteractiveSolver' property in python but also doesn't seen to work.

Since temp folders are random, I can't ofcourse place my cplex.opt file in these folder since it's always changing.

Any help would be more than welcome

User avatar
bussieck
Moderator
Moderator
Posts: 105
Joined: 1 year ago

Re: Cplex Working Directory in Temp folder. Can't read parameter file

Post by bussieck » 2 months ago

Hi,

I tried this out and opt.optdir = r'c:\tmp' works well. I have attached (rename .txt to .py) a fully working example (that assumes a c:\tmp\cplex.opt).

The GAMS working directory (and therefore also for GAMS/Cplex) is the working directory specified in the constructor of GamsWorkspace. By default some temporary directory.

I also like to create my solver option file inside the GAMS program itself then it is by definition in the correct directory:

Code: Select all

$onecho > cplex.opt
lpmethod 4
$offecho
option lp=cplex; mymodel.optfile=1;
solve mymodel min obj us lp;
Hope this helps,
-Michael
Attachments
transport1_py.txt
(934 Bytes) Downloaded 22 times

Post Reply