Hi all
I have a quick question regarding dynamically assigning variable bounds in a loop. As an example I started with:
##############
set i /a0*a3/ ;
variable test_a(i);
variable test_b(i);
set lim / FX,LO/;
parameter tofix(i,lim)/
a0.FX 5
a1.FX 10
a2.LO 3
a3.FX 70
/;
test_a.FX(i)=tofix(i,“FX”);
test_a.LO(i)=tofix(i,“LO”);
##############
I then tried to put the variable bound assignments into a loop by trying a variety of things. In essence what I want is something like:
loop(lim,
$batinclude test1.gms “.” lim tofix(i,lim)
);
where test1.gms would be:
test_b%1%2(i)=tofix(i,%2) ;
But that won’t work unless I change it to:
loop(lim,
$batinclude test1.gms “.” FX lim tofix(i,lim)
);
and update test1.gms to:
test_b%1%2(i)=tofix(i,%3) ;
But that doesn’t give me what I want either. That “FX” (aka %2 above) needs to be dynamic in the loop and I can’t figure out how to get control variables to be dynamic. Is it possible? Any thoughts?
Many thanks
James
–
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 https://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.