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 /13/;
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:
- 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)
- 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
\