Page 1 of 1

Subscript range

Posted: Fri Jul 20, 2012 9:16 pm
by mikdale
Hi there,

I'm having an issue trying to build a model with multiple ranges of subscripts.

I have a variable, call it "variable" which has two subscript ranges, "A" and "B" attached to it, such that:

"variable"[A,B]

Within the two subscript ranges are a number of distinct elements, call them "A1", "A2", "B1" and "B2". These are defined in variables, "variable A1", ..., "variable B2"

The value of these variables are combined into two variables (one for each range), "variable A" and "variable B", such that

Eqn 1: "variable A"[A1] = "variable A1"
...
Eqn 4: "variable B"[B2] = "variable B2"

I now want to combine the two variables, "variable A" and "variable B", into "variable" using a similar method:

Eqn 1: "variable"[A] = "variable A"
Eqn 2: "variable" = "variable B"

However, when I try to do this in the equation editor, it removes one of the subscript ranges assigned to "variable" and when checking the model I get the error message:

"Subscript 1 of variable -variable- is a member of -B- family when it should be a member of the -A- family."

Am I using completely the wrong method to assign ranges to different Equations for a variable? Is it not allowed to have different equations within the same variable using different subscript ranges?

I'm lost and would really appreciate any help anyone can offer.

Cheers,


Mik

Re: Subscript range

Posted: Fri Jul 20, 2012 10:11 pm
by Administrator
If you want to combine the two ranges into a single range, you will need to define it something like

a and b : "A1", "A2", "B1" , "B2"

Then your syntax for the following would be correct
Eqn 1: "variable"[A] = "variable A"
Eqn 2: "variable" = "variable B"

Hope this makes sense.

Re: Subscript range

Posted: Sat Jul 21, 2012 5:46 am
by tomfid
To simplify maintenance a bit, you can build up your ranges hierarchically, like

Code: Select all

a : a1,a2
b : (b1-b10)
a and b : a, b
This really only makes sense if a and b represent subsets of the same kind of thing, like cities in France, and cities in England. If what you're really after is a two-dimensional matrix, where A=product and B=market, for example, then a different approach is needed.