Matlab and GAMS

1,282 views
Skip to first unread message

DLL

unread,
Mar 24, 2011, 5:03:57 PM3/24/11
to gamsworld
Hi Friends:

I met issues in the first step to connect Matlab and GAMS.

My Matlab is installed at 'c:\program files\Matlab'; my GAMS is
installed at 'c:\program files\GAMS23.6'.

When i followed the instruction to add the GAMS directory to the
Matlab path.

>> addpath 'c:\program files\GAMS23.6'; savepath;

I was informed that

Warning: unable to save path to file 'c:\program files\Matlab\R2010b
\local\pathdef.m'

I do not know what I should do?

Can anybody help me?

Thanks,

Ehsan

unread,
Mar 26, 2011, 3:52:17 AM3/26/11
to gamsworld

Lili Du

unread,
Mar 29, 2011, 10:55:59 AM3/29/11
to gams...@googlegroups.com, Lili Du
Hi Ehsan:
 
Thanks  a lot for your suggestion. It solved my problem. I mean i installed both mathlab and gams under c:\, then, I can add the path of GAMS to Matlab now.
 
However, when I run the test gdxmrw03 and gdxmrw04, i still got the error informaiton below (I gave out the gdxmrw04.log  here).  I really do not know what I should do next. Could you please help me?
 
--- Job gdxmrw04.gms Start 03/29/11 10:44:46 WEX-WEI 23.6.3 x86_64/MS Windows    
GAMS Rev 236  Copyright (C) 1987-2011 GAMS Development. All rights reserved
Licensee: Gary Goldstein                                 G010614:2121CA-WIN
          Decision Ware, Inc.                                        DC2807
--- Starting compilation
--- gdxmrw04.gms(10) 2 Mb
--- call =rm writeset.gdx
--- gdxmrw04.gms(11) 2 Mb
--- call =rm writepar.gdx
--- gdxmrw04.gms(14) 2 Mb
--- call =matlab -r w_batch -logfile w_batch.log -nosplash -nodisplay /wait
--- gdxmrw04.gms(14) 2 Mb 1 Error
*** above call failed: Unknown error
*** ERRORLEVEL set to 1
*** Error 330 in C:\Users\ldu\Documents\gamsdir\projdir\gdxmrw04.gms
    CALL failed
--- gdxmrw04.gms(19) 2 Mb 2 Errors
*** Error 333 in C:\Users\ldu\Documents\gamsdir\projdir\gdxmrw04.gms
    $Error encountered - see listing for detailsrm: writeset.gdx: No such file or directory
rm: writepar.gdx: No such file or directory
--- gdxmrw04.gms(20) 2 Mb
--- call =gdxdiff writeset writeset_
GDXDIFF          Dec 13, 2010 23.6.3 WEX 22848.22869 WEI x86_64/MS Windows   
File1 : writeset
File2 : writeset_
GDXDIFF error: Input file not found writeset.gdx
--- gdxmrw04.gms(21) 2 Mb 3 Errors
*** Error 333 in C:\Users\ldu\Documents\gamsdir\projdir\gdxmrw04.gms
    $Error encountered - see listing for details
--- gdxmrw04.gms(23) 2 Mb 4 Errors
*** Error 333 in C:\Users\ldu\Documents\gamsdir\projdir\gdxmrw04.gms
    $Error encountered - see listing for details
--- gdxmrw04.gms(24) 2 Mb
--- call =gdxdiff writepar writepar_
GDXDIFF          Dec 13, 2010 23.6.3 WEX 22848.22869 WEI x86_64/MS Windows   
File1 : writepar
File2 : writepar_
GDXDIFF error: Input file not found writepar.gdx
--- gdxmrw04.gms(25) 2 Mb 5 Errors
*** Error 333 in C:\Users\ldu\Documents\gamsdir\projdir\gdxmrw04.gms
    $Error encountered - see listing for details
There were errors: not all tests passed
--- gdxmrw04.gms(28) 2 Mb 5 Errors
*** Status: Compilation error(s)
--- Job gdxmrw04.gms Stop 03/29/11 10:44:46 elapsed 0:00:00.180
Exit code = 2


--
You received this message because you are subscribed to the Google Groups "gamsworld" group.
To post to this group, send email to gams...@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.




--
Lili Du
Research Associate

NEXTRANS CENTER
USDOT Region V Regional UTC
3000 Kent Avenue
West Lafayette, IN 47906
765-496-9768 (office)
l...@purdue.edu

Ehsan

unread,
Mar 29, 2011, 5:53:36 PM3/29/11
to gamsworld
Dear Lili

I was able to partially reproduce you error for the gdxmrw04.gms file
on Win7 x64 with GAMS 23.6 and Matlab 2010Rb. As discussed in the link
below, some people believe it's an issue related to GAMS 23.6 and if
you use an older version of GAMS like 23.3, you might have a
workaround.

The link between Matlab and Gams Options:
http://groups.google.com/group/gamsworld/browse_thread/thread/d9cbf96e77acb3d9/4ef19ed26b798807

Good Luck,
Ehsan
> >http://www.mathworks.com/support/solutions/en/data/1-9574H9/index.htm...
> l...@purdue.edu- Hide quoted text -
>
> - Show quoted text -

Steven Dirkse

unread,
Apr 1, 2011, 12:25:15 AM4/1/11
to gams...@googlegroups.com
Lili,

If you are having problems getting started with GDXMRW, you should
look at the mini-FAQ at http://www.gams.com/~steve/gdxmrw.html. The
last topic there addresses this issue.

-Steve

--
Steven Dirkse, Ph.D.
GAMS Development Corp.,  Washington DC
Voice: (202)342-0180     Fax: (202)342-0181
sdi...@gams.com
http://www.gams.com

Ehsan

unread,
Apr 1, 2011, 5:43:58 PM4/1/11
to gamsworld
Dear Steve

Installing the gmsmt_.zip update solved my problem. Thanks for the
pointer.

Bests,
Ehsan



On Apr 1, 7:25 am, Steven Dirkse <sdir...@gams.com> wrote:
> Lili,
>
> If you are having problems getting started with GDXMRW, you should
> look at the mini-FAQ athttp://www.gams.com/~steve/gdxmrw.html.  The
> last topic there addresses this issue.
>
> -Steve
>
>
>
>
>
> On Tue, Mar 29, 2011 at 5:53 PM, Ehsan <ehsan.nikbak...@gmail.com> wrote:
> > Dear Lili
>
> > I was able to partially reproduce you error for the gdxmrw04.gms file
> > on Win7 x64 with GAMS 23.6 and Matlab 2010Rb. As discussed in the link
> > below, some people believe it's an issue related to GAMS 23.6 and if
> > you use an older version of GAMS like 23.3, you might have a
> > workaround.
>
> > The link between Matlab and Gams Options:
> >http://groups.google.com/group/gamsworld/browse_thread/thread/d9cbf96...
> > For more options, visit this group athttp://groups.google.com/group/gamsworld?hl=en.
>
> --
> Steven Dirkse, Ph.D.
> GAMS Development Corp.,  Washington DC
> Voice: (202)342-0180     Fax: (202)342-0181
> sdir...@gams.comhttp://www.gams.com- Hide quoted text -

Lili Du

unread,
Apr 4, 2011, 11:52:43 AM4/4/11
to gams...@googlegroups.com
Dear Steve:

GAMS 23.6.4 (Windows-64bit) solves the issues. I mean I can
run the test gdxmrw05 successfully now. Thanks,

Lili

Lili Du

unread,
Apr 5, 2011, 5:59:55 PM4/5/11
to gams...@googlegroups.com
Hi all,

I'm was trying to transfer some data between Matlab and
GAMS. The original GAMS model is the very typical example
from Dr. Steven Dirkse's documentation.

$set matout "'matsol.gdx', x, dual ";
set i /1*2/,
j /1*3/;
alias (j1,j);

parameter
Q(j,j1) /
1 .1 1.0
2 .2 1.0
3 .3 1.0 /,
A(i,j) /
1 .1 1.0
1 .2 1.0
1 .3 1.0
2 .1 -1.0
2 .3 1.0 /,
b(i) /
1 1.0
2 1.0 /,

c(j) /
1 2.0 /;

$if exist matdata.gms $include matdata.gms

variables obj;

positive variable x(j);

equation cost, dual(i);

cost.. obj =e= 0.5*sum(j,x(j)*sum(j1,Q(j,j1)*x(j1))) +
sum(j,c(j)*x(j));
dual(i).. sum(j, A(i,j)*x(j)) =g= b(i);

model qp /cost,dual/;

solve qp using nlp minimizing obj;

execute_unload %matout%;

------------------------------------------------

I want to replace the parameters of A, Q, b and c from
Matlab.

First, I successfully replaced A and Q by using the
following codes:

>> s.name = 'A'; s.val = [1 1 2; -1 0 2]; s.type =
'parameter'; s.form = 'full';
>> x = gams('qp_test',s)

Then, I failed to replaced vector b and c by using both of
below codes:
1. set b as column vector

>> s.name = 'b'; s.val = [2.0; 2.0]; s.type = 'parameter';
s.form = 'full';
>> x = gams('qp_test',s)

2. set b as row vector

>> s.name = 'b'; s.val = [2.0 2.0]; s.type = 'parameter';
s.form = 'full';
>> x = gams('qp_test',s)

------------------------------------

The errors of (1) and (2) are the same:
??? Error using ==> gams
abnormal GAMS termination running C:\Program
Files\GAMS23.6\gams.exe qp_test lo=0: check listing file


I checked the .lst file, but the hint information in .lst is
not helping at all.

Please help.

--
Best regards,

Lili


Steven Dirkse

unread,
Jan 28, 2013, 4:43:59 PM1/28/13
to gams...@googlegroups.com
Sofia,

You should be using the latest version of GAMS: we are at 24.0.1 now.  Possibly updating will fix things, or at least give you a better message.  I don't think it likely for this error.

Also, I don't recommend that you use the gams() function to pass data.  It makes it difficult to find and fix problems.  Suggestions for a better approach are found here:

--
You received this message because you are subscribed to the Google Groups "gamsworld" group.
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.



--
Steven Dirkse, Ph.D.
GAMS Development Corp.,  Washington DC
Voice: (202)342-0180     Fax: (202)342-0181

strug...@hotmail.com

unread,
Sep 23, 2013, 9:57:52 PM9/23/13
to gams...@googlegroups.com
Have you solved this problem? 

在 2013年1月29日星期二UTC+8上午1时34分11秒,Sofia写道:
LL,


could you solve the problem because I have the same and I don't know the reason.



El martes, 5 de abril de 2011 15:59:55 UTC-6, LL escribió:
Reply all
Reply to author
Forward
0 new messages