Execute_load GDX/MATLAB/GAMS Problem

Hello Friends,

I’ve recently started trying my hands on GAMS/MATLAB data exchange.

I’ve been able to use rgdx and wgdx successfully but I’m currently
having problem with havign GAMS read the structured input correctly.

For example: I created 2 input structures into an inputfile.gdx in
MATLAB

indata1 = struct(‘name’,‘a’,‘type’,‘Parameter’,‘form’,‘full’,‘val’,
[350, 600],‘ts’,‘capacity’);

indata2 = struct(‘name’,‘b’,‘type’,‘Parameter’,‘form’,‘full’,‘val’,
[325 300 275],‘ts’,‘demand’);

wgdx(‘indata.gdx’,indata1,indata2)


Then In GAMS I tried to read the parameters:
:
:
Parameters
a(i) capacity of plant i in cases
b(j) demand at market j in cases

execute_load ‘indata.gdx’, a, b;
display a,b;
:
:

The code compiled successfully but gives the following error on
execution.
E x e c u t i o n


---- 55 PARAMETER a capacity of plant i in cases

( ALL 0.000 )


---- 55 PARAMETER b demand at market j in cases

( ALL 0.000 )


I suspect the problem is with my val field but I can’t wrap my brain
around the exact problem.

I need to pass both vector and 2D matrix into the system so I should
figure out how to make this simple one work.

Any help will be deeply appreciated.

Thanks.

\

You have got the data from Matlab into GDX, which is most of the way
there. A few suggestions:

A downloadable example is at

http://support.gams.com/lib/exe/fetch.php?id=matlab_and_gams%3Ainterfacing_optimization_and_visualization_software_via_the_gdxmrw_utilities&cache=cache&media=matlab_and_gams:trmat.zip

HTH,

-Steve
On Wed, May 23, 2012 at 3:17 AM, Crystal wrote:

Hello Friends,

I’ve recently started trying my hands on GAMS/MATLAB data exchange.

I’ve been able to use rgdx and wgdx successfully but I’m currently
having problem with havign GAMS read the structured input correctly.

For example: I created 2 input structures into an inputfile.gdx in
MATLAB

indata1 = struct(‘name’,‘a’,‘type’,‘Parameter’,‘form’,‘full’,‘val’,
[350, 600],‘ts’,‘capacity’);

indata2 = struct(‘name’,‘b’,‘type’,‘Parameter’,‘form’,‘full’,‘val’,
[325 300 275],‘ts’,‘demand’);

wgdx(‘indata.gdx’,indata1,indata2)

Then In GAMS I tried to read the parameters:
:
:
Parameters
a(i) capacity of plant i in cases
b(j) demand at market j in cases

execute_load ‘indata.gdx’, a, b;
display a,b;
:
:

The code compiled successfully but gives the following error on
execution.
E x e c u t i o n

---- 55 PARAMETER a capacity of plant i in cases

                 ( ALL       0.000 )

---- 55 PARAMETER b demand at market j in cases

                 ( ALL       0.000 )

I suspect the problem is with my val field but I can’t wrap my brain
around the exact problem.

I need to pass both vector and 2D matrix into the system so I should
figure out how to make this simple one work.

Any help will be deeply appreciated.

Thanks.


To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.

Thankx Steve,

The link to the example files trmat2.gms really helped sort out the
problem. Turned out that problem was not the reading and writing of
files as I thought but error in my actual gams code. I passed my data
to the trmat2 file and it worked fine but when I passed trdat2.gdx to
my code it failed.

How could I have known if I hadn’t posted, hadn’t tried $gdxin/$load
and hadn’t followed your links.
Hun… You rock!

Thanks.


On May 23, 9:36 pm, Steven Dirkse wrote:

You have got the data from Matlab into GDX, which is most of the way
there. A few suggestions:

  • Use the GDX viewer in the GAMS IDE or gdxdump for non-Windows
    machines to see what data you actually have in GDX.
  • Use $gdxin and $load to load your data a compile time, instead of
    the execution-time execute_load you are using.
  • There is an example with comments athttp://support.gams.com/doku.php?id=matlab_and_gams:interfacing_optim…

A downloadable example is at

http://support.gams.com/lib/exe/fetch.php?id=matlab_and_gams%3Ainterf

HTH,

-Steve

On Wed, May 23, 2012 at 3:17 AM, Crystal wrote:

Hello Friends,

I’ve recently started trying my hands on GAMS/MATLAB data exchange.

I’ve been able to use rgdx and wgdx successfully but I’m currently
having problem with havign GAMS read the structured input correctly.

For example: I created 2 input structures into an inputfile.gdx in
MATLAB

indata1 = struct(‘name’,‘a’,‘type’,‘Parameter’,‘form’,‘full’,‘val’,
[350, 600],‘ts’,‘capacity’);

indata2 = struct(‘name’,‘b’,‘type’,‘Parameter’,‘form’,‘full’,‘val’,
[325 300 275],‘ts’,‘demand’);

wgdx(‘indata.gdx’,indata1,indata2)

Then In GAMS I tried to read the parameters:
:
:
Parameters
a(i) capacity of plant i in cases
b(j) demand at market j in cases

execute_load ‘indata.gdx’, a, b;
display a,b;
:
:

The code compiled successfully but gives the following error on
execution.
E x e c u t i o n

---- 55 PARAMETER a capacity of plant i in cases

                 ( ALL       0.000 )

---- 55 PARAMETER b demand at market j in cases

                 ( ALL       0.000 )

I suspect the problem is with my val field but I can’t wrap my brain
around the exact problem.

I need to pass both vector and 2D matrix into the system so I should
figure out how to make this simple one work.

Any help will be deeply appreciated.

Thanks.


To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group athttp://groups.google.com/group/gamsworld?hl=en.

\