Hi,
I have a main GAMS program that iteratively calls different GAMS programs. It needs to process the data from these programs. These programs take processed data as input from the main program.
The following code portion will help to understand the problem more clearly.
Since Dollar control statements are processed during compilation and NOT during execution. So, the Hfeasible_data.gdx file (generated from NG_nonConvex.gms) can’t be opened as it will be available only after executing NG_nonConvex.gms. The same goes for RelaxedNG_output.gdx file. Now, I can’t use parameter err (and others) from RelaxedNG_output.gdx file. So, it can’t process any data.
Is there any way to do this? or is any material available that I can use to understand such scenarios?
Set k 'Heating Network nodes';
Alias(k,l);
$GDXIN F:\MES 13 bus Code\ginput_data.gdx
$LOAD k
$GDXIN
*initial bounds
$call gdxxrw MES_Data.xlsx output = massflowBounds.gdx par=LineHydroBounds rng=HSSystemdata!B1:F30 cDim=1 rDim=2 ignoreColumns=D par=ioHydroBounds rng=HSLoadData!B1:H18 cDim=1 rDim=1 ignoreColumns=C,F
Set
mhb 'line flow bounds' /Mkl_low, Mkl_up/
mhlb 'In/out flow bounds' /Mk_inLow, Mk_outUp, Mk_inUP, Mk_outlow/;
Parameter LineHydroBounds(k,l, mhb);
Parameter ioHydroBounds(k, mhlb);
$gdxin massflowBounds.gdx
$load LineHydroBounds, ioHydroBounds
$gdxin
Parameters m_in, m_out, m_kl;
[b]execute.checkErrorLevel 'gams NG_nonConvex.gms lo=4';[/b]
[b]$GDXIN F:\MES 13 bus Code\Hfeasible_data.gdx
$LOAD m_in=mw_in.l, m_out=mw_out.l, m_kl=mw_kl.l
$GDXIN[/b]
Parameter err, tol;
tol = 0.001;
Scalar del1 /0.5/
del2 /0.2/;
scalar stopped /0/
counter /1/;
Set count /1*10/;
loop(count$(not stopped),
put_utility 'exec.checkErrorLevel' / 'gams NGsystem.gms lo=4';
put_utility 'exec.checkErrorLevel' / 'gams DHS_directional.gms lo=4';
$GDXIN F:\MES 13 bus Code\RelaxedNG_output.gdx
$LOAD err
$GDXIN
if(err < tol,
stopped = 1;
else
Parameter m_in(k), m_out(k), m_kl(k,l);
$GDXIN F:\MES 13 bus Code\Hfeasible_data.gdx
$LOAD m_in=mw_in.l, m_out=mw_out.l, m_kl=mw_kl.l
$GDXIN
display m_in, m_out, m_kl;
ioHydroBounds(k, 'Mk_inLow') = (1-del2)*ioHydroBounds(k, 'Mk_inLow')+del2*m_in(k);
LineHydroBounds(k,l,'Mkl_up') = (1-del1)*LineHydroBounds(k,l,'Mkl_up')+del1*m_kl.l(k,l);
execute_unload 'massflowBounds', LineHydroBounds, ioHydroBounds;
);
counter = counter + 1;
display counter, err;
);