Page 1 of 1

### solving a model with deferent solvers

Posted: Mon Jun 04, 2018 5:13 pm
Hello
I try to solve a model with deferent solver simultaneously. for example, with cplex, xpress, lindo.
My code is:
Scalar iter;
Parameter solution;
for(iter=1 to 1,
******************************************************
OPTION MIP=cplex;
SOLVE FCTP USING MIP MIN obj;
if (FCTP.modelstat<>%modelstat.Optimal%,
abort 'no feasible solution for FCTP');
solution=obj.l;
DISPLAY "cplex solution is", solution;
******************************************************
OPTION MIP=xpress;
SOLVE FCTP USING MIP MIN obj;
if (FCTP.modelstat<>%modelstat.Optimal%,
abort 'no feasible solution for FCTP');
solution=obj.l;
DISPLAY "xpress solution is", solution;
******************************************************
OPTION MIP=lindo;
SOLVE FCTP USING MIP MIN obj;
if (FCTP.modelstat<>%modelstat.Optimal%,
abort 'no feasible solution for FCTP');
solution=obj.l;
DISPLAY "lindo solution is", solution;
);

Do you know the better way to code it?

Best regards

### Re: solving a model with deferent solvers

Posted: Tue Jun 05, 2018 12:32 am
what is wrong with yours ?, or: what is your definition of "better" ?

### Re: solving a model with deferent solvers

Posted: Tue Jun 05, 2018 1:48 am
Hello
My means that, have a specific syntax for write easy or better this subject?
(For example I know that, optfile syntax can replace with option=solver.name)

Best regards

### Re: solving a model with deferent solvers

Posted: Tue Jun 05, 2018 7:53 am
Hi,

You mention that you try to solve one model with different solvers simultaneously but in your example the solve statements are carried out sequentially. I also do not get the point with the for loop. You can just remove it. After the solve statement you check for optimality. If it turns out that no proven optimal solution was found your abort message claims that there is no feasible solution. This conclusion is wrong. You might want to check modelstat 8 (integer solution) as well, e.g. as follows:

Code: Select all

``abort\$(FCTP.modelstat<>%modelstat.Optimal% and FCTP.modelstat<>%modelstat.integerSolution%) 'no integer solution for FCTP';``
There are ways to solve models in parallel in GAMS. For example you might want to read the chapter about the GAMS Grid Facility: https://www.gams.com/latest/docs/UG_GridComputing.html
This is an advanced feature that requires some GAMS programming skills. I attached a simple example (modification of dice from the model library https://www.gams.com/latest/gamslib_ml/ ... _dice.html) that makes use of the corresponding solvelink option (https://www.gams.com/latest/docs/UG_Gam ... Osolvelink).

I hope this helps!

Fred

### Re: solving a model with deferent solvers

Posted: Tue Jun 05, 2018 1:08 pm
Dear Fred

Please let me describe my problem. I want to solve my model with three deferent solvers using for loop. I coded it with for statement but I want to know, do exist the better way to code it?

Best regards

### Re: solving a model with deferent solvers

Posted: Wed Jun 06, 2018 10:05 am
Hi,

I still do not understand why you want to use a for loop. I also do not understand what you meant in your second post when you wrote For example I know that, optfile syntax can replace with option=solver.name.

There are ways to implement what you want to do in a loop (not necessarily a for loop) but I doubt that this will be any more convenient for you than what you are doing right now.

Fred