I am generating the following gams program with my c++ program
variable x(*) /1.lo = -1,1.up = 1,2.lo = -1,2.up = 1/;
variable obj; equation eqobj; eqobj.. obj =e= x['1']+x['2'];
parameter ms, ss, lbd, ubd, cpu;
model mod /all/;
option decimals = 8;
solve mod minimizing obj using minlp;
lbd=mod.objest; ubd=obj.l;
ms=mod.modelstat; ss=mod.solvestat; cpu=mod.resusd;
and using the gams-c++ api to let gams solve it. Afterwards, I want to obtain the results in c++ using this method:
auto value = m_job.outDB().getVariable(var).findRecord().level();
were job
is my GAMSJob
, which was used to solve the program above and var
is a string containing the variable name, whose value I want to obtain.
This methods works perfectly with one dimensional variables, e.g. when my variable looks as follows
variable x;
x.up = 1;
x.lo = 0;
and I am passing "x"
as var in the code above.
I have tried to access the entries of the multidimensional variables now with a string like "x['1']"
, but then always 0 is returned. What is the correct way to obtain the values I want, i.e. the entries of the multidimensional variable?