Call GAMS in a parfor loop?

3 views (last 30 days)
Mike Fisher
Mike Fisher on 8 Aug 2015
Commented: mangoon on 19 Jan 2017
I am trying to call GAMS within a parfor loop to perform concurrent optimizations on multiple independent datasets. The optimization routine is the same for all datasets (calls the same GAMS IDE file) and the format of the data input and output is the same for all datasets. The results of each of the GAMS runs is passed back to Matlab where I store it. I am running into an issue where all the workers are quickly "aborting" during execution of the loop.
After reading a bit about how Matlab transfers data to GAMS, I know that it creates a .gdx file for the input data and then a different .gdx file for the requested output, and it always gives these files the same name. The .gdx files appear in the same folder as the Matlab script I am running. So maybe the issue is that each of the workers is trying to write data to the same .gdx file? Either that or the workers can't see the .gdx files on the disk because they can't see the path to those files?
I know that you can write/read and name your own .gdx files with w/rgdx, but I will be running the optimization hundreds of thousands of times, so giving each optimization uniquely named .gdx files seems unwieldy. Also, each optimization routine has many hundreds of constraints (it's time series data) that will produce very large matrices. These would be difficult to construct by hand to feed to Matlab's internal optimization solvers (that's why I'm using GAMS to do it for me).
Any thoughts?
  2 Comments
Meiyour
Meiyour on 25 Aug 2015
I'm having the same problem. Can anyone help?
mangoon
mangoon on 19 Jan 2017
Not sure whether you still need an answer on that, but maybe others come across this post. I would suggest www.gamsoptimization.com.
You wrote: "and it always gives these files the same name". The GDX file that brings data to GAMS and the GDX file that reports data after the GAMS execution can be named differently, also if everything is controlled by Matlab. Check out the link above to see how that works.
Best!

Sign in to comment.

Answers (0)

Categories

Find more on Programming in Help Center and File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!