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

what is wrong with yours ?, or: what is your definition of “better” ?

Hello

Thanks for your reply.

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

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:

```
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/libhtml/gamslib_dice.html) that makes use of the corresponding solvelink option (https://www.gams.com/latest/docs/UG_GamsCall.html#GAMSAOsolvelink).

I hope this helps!

Fred

diceGridDifferentSolvers.gms (3.01 KB)

Dear Fred

Thanks for your replay.

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

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