Read Model Status in Matlab and record it 1->optimal & 0 O.W.

Archive of Gamsworld Google Group
Archiver
User
User
Posts: 7876
Joined: 1 year ago

Read Model Status in Matlab and record it 1->optimal & 0 O.W.

Postby Archiver » 1 year ago


Hello All

I have a MILP model solving by CPLEX.
I'm linking Matlab with GAMS using WGDX and having many runs. Would like to record the number of feasible solutions, and also reading non optimal and infeasible using RGDX.
I want to do that for the record and rerun if feasible.
How to read Model Status?

Thanks all

--
To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at https://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.

Archiver
User
User
Posts: 7876
Joined: 1 year ago

Re: Read Model Status in Matlab and record it 1->optimal & 0 O.W.

Postby Archiver » 1 year ago


Hi,

Store the model/solvestatus in a scalar and interpret this in MATLAB:

scalar modstat, solstat;
modstat = mymodel.modelstat;
solstat = mymodel.solvestat;

Hope this helps,
Michael Bussieck - GAMSWorld Coordinator

On Wednesday, April 13, 2016 at 2:28:33 AM UTC-4, thefooox1 wrote:

Hello All

I have a MILP model solving by CPLEX.
I'm linking Matlab with GAMS using WGDX and having many runs. Would like to record the number of feasible solutions, and also reading non optimal and infeasible using RGDX.
I want to do that for the record and rerun if feasible.
How to read Model Status?

Thanks all

--
To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at https://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.

Archiver
User
User
Posts: 7876
Joined: 1 year ago

Re: Read Model Status in Matlab and record it 1->optimal & 0 O.W.

Postby Archiver » 1 year ago


Hi

It's working fine in GAMS. However, I couldn't read it in Matlab and getting error
Error using rgdx
GDX file G2M.gdx contains no symbol named 'modstat'

I checked using GDXWhos 'G2M' and these two parameters are not on the list!!
Why is that? What did I miss?

Thanks a lot


On Wednesday, April 13, 2016 at 2:00:32 PM UTC+3, Michael Bussieck wrote:

Hi,

Store the model/solvestatus in a scalar and interpret this in MATLAB:

scalar modstat, solstat;
modstat = mymodel.modelstat;
solstat = mymodel.solvestat;

Hope this helps,
Michael Bussieck - GAMSWorld Coordinator

On Wednesday, April 13, 2016 at 2:28:33 AM UTC-4, thefooox1 wrote:

Hello All

I have a MILP model solving by CPLEX.
I'm linking Matlab with GAMS using WGDX and having many runs. Would like to record the number of feasible solutions, and also reading non optimal and infeasible using RGDX.
I want to do that for the record and rerun if feasible.
How to read Model Status?

Thanks all

--
To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at https://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.

Archiver
User
User
Posts: 7876
Joined: 1 year ago

Re: Read Model Status in Matlab and record it 1->optimal & 0 O.W.

Postby Archiver » 1 year ago


Hello fooox1.

"I checked using GDXWhos 'G2M' and these two parameters are not on the list!!
Why is that? What did I miss?"

If the symbols are not listed (and others are), then probably they weren't loaded into the gdx. You can double check this by opening the .gdx with the GAMS IDE. Another obvious problem that is frequent is that you are opening an older gdx and not that which you just generated.

Have into account this from https://www.gams.com/help/index.jsp?topic=%2Fgams.doc%2Fuserguides%2Fmccarl%2Funload.htm

•Unload outputs the data at compile time and will write the data present at the time that the statement is encountered during the compilation. The results of calculations and solves will not be reflected.

•Unload should not ordinarily be used, it is safer to use the execution time counterparts Execute_Unload or Execute_Unloaddi as calculations and solves affect the results.

Conclusion: You should be using Execute_Unload. Then, if you are only unloading some items, you need to make sure you are listing this scalar (modstat). If space is not a problem, you can just use Execute_Unload 'filename' so that all symbols get unloaded.

ohter linked ref: https://www.gams.com/help/index.jsp?topic=%2Fgams.doc%2Fuserguides%2Fmccarl%2Funload.htm

Hope to help!
Regards
Claudio


On Wed, Apr 13, 2016 at 11:56 AM, thefooox1 wrote:

Hi

It's working fine in GAMS. However, I couldn't read it in Matlab and getting error
Error using rgdx
GDX file G2M.gdx contains no symbol named 'modstat'

I checked using GDXWhos 'G2M' and these two parameters are not on the list!!
Why is that? What did I miss?

Thanks a lot


On Wednesday, April 13, 2016 at 2:00:32 PM UTC+3, Michael Bussieck wrote:

Hi,

Store the model/solvestatus in a scalar and interpret this in MATLAB:

scalar modstat, solstat;
modstat = mymodel.modelstat;
solstat = mymodel.solvestat;

Hope this helps,
Michael Bussieck - GAMSWorld Coordinator

On Wednesday, April 13, 2016 at 2:28:33 AM UTC-4, thefooox1 wrote:

Hello All

I have a MILP model solving by CPLEX.
I'm linking Matlab with GAMS using WGDX and having many runs. Would like to record the number of feasible solutions, and also reading non optimal and infeasible using RGDX.
I want to do that for the record and rerun if feasible.
How to read Model Status?

Thanks all

--
To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at https://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.


--
To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at https://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.

Archiver
User
User
Posts: 7876
Joined: 1 year ago

Re: Read Model Status in Matlab and record it 1->optimal & 0 O.W.

Postby Archiver » 1 year ago


Thanks a lot
It's working fine.
Wrong path.
Thanks again

On Wednesday, April 13, 2016 at 2:00:32 PM UTC+3, Michael Bussieck wrote:

Hi,

Store the model/solvestatus in a scalar and interpret this in MATLAB:

scalar modstat, solstat;
modstat = mymodel.modelstat;
solstat = mymodel.solvestat;

Hope this helps,
Michael Bussieck - GAMSWorld Coordinator

On Wednesday, April 13, 2016 at 2:28:33 AM UTC-4, thefooox1 wrote:

Hello All

I have a MILP model solving by CPLEX.
I'm linking Matlab with GAMS using WGDX and having many runs. Would like to record the number of feasible solutions, and also reading non optimal and infeasible using RGDX.
I want to do that for the record and rerun if feasible.
How to read Model Status?

Thanks all

--
To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at https://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.

Archiver
User
User
Posts: 7876
Joined: 1 year ago

Re: Read Model Status in Matlab and record it 1->optimal & 0 O.W.

Postby Archiver » 1 year ago


Hi Claudio
I solved the problem.
Thanks for your efforts.
You are very active here.
Really appreciate that.

On Thursday, April 14, 2016 at 9:00:06 AM UTC+3, Claudio Delpino wrote:

Hello fooox1.

"I checked using GDXWhos 'G2M' and these two parameters are not on the list!!
Why is that? What did I miss?"

If the symbols are not listed (and others are), then probably they weren't loaded into the gdx. You can double check this by opening the .gdx with the GAMS IDE. Another obvious problem that is frequent is that you are opening an older gdx and not that which you just generated.

Have into account this from https://www.gams.com/help/index.jsp?topic=%2Fgams.doc%2Fuserguides%2Fmccarl%2Funload.htm

•Unload outputs the data at compile time and will write the data present at the time that the statement is encountered during the compilation. The results of calculations and solves will not be reflected.

•Unload should not ordinarily be used, it is safer to use the execution time counterparts Execute_Unload or Execute_Unloaddi as calculations and solves affect the results.

Conclusion: You should be using Execute_Unload. Then, if you are only unloading some items, you need to make sure you are listing this scalar (modstat). If space is not a problem, you can just use Execute_Unload 'filename' so that all symbols get unloaded.

ohter linked ref: https://www.gams.com/help/index.jsp?topic=%2Fgams.doc%2Fuserguides%2Fmccarl%2Funload.htm

Hope to help!
Regards
Claudio


On Wed, Apr 13, 2016 at 11:56 AM, thefooox1 wrote:

Hi

It's working fine in GAMS. However, I couldn't read it in Matlab and getting error
Error using rgdx
GDX file G2M.gdx contains no symbol named 'modstat'

I checked using GDXWhos 'G2M' and these two parameters are not on the list!!
Why is that? What did I miss?

Thanks a lot


On Wednesday, April 13, 2016 at 2:00:32 PM UTC+3, Michael Bussieck wrote:

Hi,

Store the model/solvestatus in a scalar and interpret this in MATLAB:

scalar modstat, solstat;
modstat = mymodel.modelstat;
solstat = mymodel.solvestat;

Hope this helps,
Michael Bussieck - GAMSWorld Coordinator

On Wednesday, April 13, 2016 at 2:28:33 AM UTC-4, thefooox1 wrote:

Hello All

I have a MILP model solving by CPLEX.
I'm linking Matlab with GAMS using WGDX and having many runs. Would like to record the number of feasible solutions, and also reading non optimal and infeasible using RGDX.
I want to do that for the record and rerun if feasible.
How to read Model Status?

Thanks all

--
To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+...@googlegroups.com.
To post to this group, send email to gams...@googlegroups.com.
Visit this group at https://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.


--
To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at https://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.

berry12150
User
User
Posts: 2
Joined: 2 weeks ago

Re: Read Model Status in Matlab and record it 1->optimal & 0 O.W.

Postby berry12150 » 2 weeks ago

Hi Archiver,

I am also trying to output GAMS model status in matlab. I read your posts, but still don't know how to set model status and solve status to variables in gams. In my gams codes, it is shown that "modelstat" is an unknown symbol. Can you explain your method with more details? I am really grateful if you could offer some help.

Thank you.

Berry12150

berry12150
User
User
Posts: 2
Joined: 2 weeks ago

Re: Read Model Status in Matlab and record it 1->optimal & 0 O.W.

Postby berry12150 » 2 weeks ago

I just figured out how to use .ModelStat in gams. It works.

Thank you.

Berry12150


Return to “Archive Google Group”

Who is online

Users browsing this forum: No registered users and 3 guests