Running GAMS from MATLAB

Problems with modeling
Post Reply
masoudkavoosi
User
User
Posts: 5
Joined: 5 years ago

Running GAMS from MATLAB

Post by masoudkavoosi »

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
Attachments
UIMA_GAMS.gms
(64.38 KiB) Downloaded 247 times
UIMA_GAMS_Function.gms
(2.65 KiB) Downloaded 241 times
User avatar
dirkse
Moderator
Moderator
Posts: 214
Joined: 7 years ago
Location: Fairfax, VA

Re: Running GAMS from MATLAB

Post by dirkse »

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_gam ... 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:

Code: Select all

Pv.name=' Pv';
HTH,

-Steve
masoudkavoosi
User
User
Posts: 5
Joined: 5 years ago

Re: Running GAMS from MATLAB

Post by masoudkavoosi »

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
Post Reply