Matlab <==> GAMS failed to transfer data

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 /12/,
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)

  1. 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


\

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ó:

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 /12/,
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)

  1. 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

\

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 http://groups.google.com/group/gamsworld?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.

\

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:

http://support.gams-software.com/doku.php?id=matlab_and_gams:interfacing_optimization_and_visualization_software_via_the_gdxmrw_utilities#how_can_i_construct_an_interface_between_gams_and_matlab

-Steve


On Mon, Jan 28, 2013 at 12:34 PM, Sofia wrote:

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ó:

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 /12/,
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)

  1. 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

\

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 http://groups.google.com/group/gamsworld?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.





\

Steven Dirkse, Ph.D.
GAMS Development Corp., Washington DC
Voice: (202)342-0180 Fax: (202)342-0181
sdirkse@gams.com
http://www.gams.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ó:

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 /12/,
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)

  1. 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

\

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 http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/groups/opt_out.