Running GAMS from MATLAB

hey guys,

I am trying to call GAMS from a MATLAB code. I have done this a lot of times before, but this time it returns an error that I cannot solve it.

MATLAB returns the error below:

Error using gams
Could not write data with gdxDataWriteMapStart

Error in UIMA_GAMS (line 51)
gams(‘UIMA_GAMS_Function.gms’,vs,bs,ts,A,I,RD,cHT,cWT,cLD,Dv,Lv,Pv,Ph,Db,Lb,HT);

My files have been attached. It would be greatly appreciated if you check it and help me. As I cannot attach an m-file here, I changed the extension of the file UIMA_GAMS.m to .gms and attach it. Please kindly change the extension to .m to use the file.

Thank you

Masoud
UIMA_GAMS.gms (64.4 KB)
UIMA_GAMS_Function.gms (2.65 KB)

Masoud,

I would advise you not to use the gams Mex-function. It’s nice when it works, but if there is any error - and the error state is the normal state when you’re developing a model or source code anywhere - it doesn’t help you find and fix the error. In your example, where should you start looking? The Matlab code? The GAMS source you wrote? The GAMS source written by the gams Mex-function?

You can find some suggestions - I would say good and helpful ones - about a better way to do this on the GAMS wiki page about GDXMRW:

https://support.gams.com/matlab_and_gams:interfacing_optimization_and_visualization_software_via_the_gdxmrw_utilities#how_can_i_construct_an_interface_between_gams_and_matlab

BTW, if you choose to persist in using the gams Mex-function, you should start by removing the space from the name of the Pv and Ph parameters. This won’t work:

Pv.name=' Pv';

HTH,

-Steve

Hi, Steve.

Thank you so much for your attention. My problem was about that space that you correctly have mentioned. I should have been more attentive.

Thank you again

Masoud