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
solving a model with deferent solvers

 User
 Posts: 108
 Joined: 1 year ago
Re: solving a model with deferent solvers
what is wrong with yours ?, or: what is your definition of "better" ?
Re: solving a model with deferent solvers
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
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
Re: solving a model with deferent solvers
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:
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
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';
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
 Attachments

 diceGridDifferentSolvers.gms
 (3.01 KiB) Downloaded 7 times
Re: solving a model with deferent solvers
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
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
Re: solving a model with deferent solvers
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
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