Can I use multithreading to run multiple iterative solves?

Problems with modeling
Post Reply
Hammani
User
User
Posts: 1
Joined: 2 weeks ago

Can I use multithreading to run multiple iterative solves?

Post by Hammani »

Hi, I am new to GAMS and I want to apply a (quite) unusual decomposition to my problem.
I have a problem that decomposes naturally into multiple time steps that are independent. However, in each time step I need to solve the same model iteratively (as the results of one iteration are used as parameters to the next). Here is a general idea of the pseudo code:
- define model
- for each time step
----- initialize parameters of the current time step
----- while (termination condition)
--------- solve model
--------- get results
--------- update parameters based on the results
--------- update termination condition
----- store final iteration results in gdx (for example)

As you can see, I run the same procedure for all time steps and for now I do this sequentially. I would like to parallelize it according to the time step loop, while maintaining my iterative procedure for each one.
P.S : I checked the Grid and Multi-Threading Solve Facility page, but it doesn't quite work...

Thank you in advance for your time.
User avatar
bussieck
Moderator
Moderator
Posts: 1048
Joined: 7 years ago

Re: Can I use multithreading to run multiple iterative solves?

Post by bussieck »

Correct, async solves (solveLink=3/6) won't help because you want to run some GAMS code in parallel. This can be done by running GAMS asynchronously. There is a complex example in the GAMS Model Library that shows how to do this: asyncloop (https://www.gams.com/latest/gamslib_ml/ ... cloop.html). The loop body here is only a solve, but in principle this can be your sequential while loop.

Hope this helps,
-Michael
Post Reply