You do not want to declare the variables over a dynamic set, but
rather use them in the model in such a way that they only exist for
members of your dynamic set. For example, do this:
set i /1*1000/
set gen(i);
variable test(i);
equation genLim(i);
genLim(gen(i))... test(i) =L= someFunction(i);
This will only generate equations and variables for i in gen(i).
To repeat, your strategy should be: declare variables and equations
over static sets, but define the equations and use the variables over
the dynamic sets to appropriately limit the variables and equations
that actually exist.
-Steve
> --
> You received this message because you are subscribed to the Google Groups "gamsworld" group.
> To post to this group, send email to gams...@googlegroups.com.
> To unsubscribe from this group, send email to gamsworld+...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.
>
>
--
Steven Dirkse, Ph.D.
GAMS Development Corp., Washington DC
Voice: (202)342-0180 Fax: (202)342-0181
sdi...@gams.com
http://www.gams.com
Short version: change your equation definition from
testEq1(i).. testVar1(i) - testVar2(i) =L= 7;
to
testEq1b(i).. testVar1(i) - testVar2(i)$dynamicSet(i) =L= 7;
It has been suggested many times that we introduce a way to declare a
variable so there is a restriction on the tuples that appear. For
example, if we said
variable testVar2(dynamicSet(i));
then all occurrences of testVar2(i) would act like we had written
testVar2(i)$dynamicSet(i). I won't get into the reasons we haven't
done this, but it sounds like that's what you're looking for.
Unfortunately, you can't do this directly.
Here's a working model showing the failing and working instances.
-Steve
set i /1*5/
set dynamicSet(i);
parameter cond(i) /1 1,2 1,3 2,4 1,5 2/;
dynamicSet(i)=yes$(cond(i)=2);
variable testVar1(i),testVar2(i);
equation testEq1(i),testEq2(i),testEq1b(i);
testEq1(i).. testVar1(i) - testVar2(i) =L= 7;
testEq1b(i).. testVar1(i) - testVar2(i)$dynamicSet(i) =L= 7;
testEq2(dynamicSet(i)).. testVar1(i)+testVar2(i) =L= 3;
model testModel / testEq1.testVar1
testEq2.testVar2 /;
model test2 / testEq1b.testVar1
testEq2.testVar2 /;
maxexecerror = 1;
solve testModel using mcp;
abort$[not execerror] 'unmatched testVar2 should trigger error';
execerror = 0;
solve test2 using mcp;
abort$[execerror] 'test2 should be working';