How to: create a sequenced (asterisked) set when the final value isnt known until runtime
Posted: Wed Jun 27, 2018 5:02 am
Hello
We would like to use the * set definition, for example
set abc / t1*t100/;
Unfortunately we wont know that the final value is to be 100 until during the execution, it could be 100, it could be 500. We have saved the value we want it to be into a scalar during execution, for example:
Is there a way to do this? Basically we want something along the lines of (psuedo code):
:
run some gams code
:
calculate myScalar
set abc / t1*t<myScalar?>/;
One idea I had was to use an include file during execution, but couldn't get it to work - the file doesn't seem to be produced. Something like:
scalar iTemp;
iTemp = sum(a, myParameter(a));
put_utility 'shell' / 'echo t1*t', iTemp, ' >expandedTrdBlk.inc';
set trdBlk /
$include "expandedTrdBlk.inc";
/;
All help appreciated
Cheers
AndyC
We would like to use the * set definition, for example
set abc / t1*t100/;
Unfortunately we wont know that the final value is to be 100 until during the execution, it could be 100, it could be 500. We have saved the value we want it to be into a scalar during execution, for example:
Is there a way to do this? Basically we want something along the lines of (psuedo code):
:
run some gams code
:
calculate myScalar
set abc / t1*t<myScalar?>/;
One idea I had was to use an include file during execution, but couldn't get it to work - the file doesn't seem to be produced. Something like:
scalar iTemp;
iTemp = sum(a, myParameter(a));
put_utility 'shell' / 'echo t1*t', iTemp, ' >expandedTrdBlk.inc';
set trdBlk /
$include "expandedTrdBlk.inc";
/;
All help appreciated
Cheers
AndyC