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
Cplex Working Directory in Temp folder. Can't read parameter file
Re: Cplex Working Directory in Temp folder. Can't read parameter file
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:
Hope this helps,
-Michael
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;
-Michael
- Attachments
-
- transport1_py.txt
- (934 Bytes) Downloaded 398 times