Defining indices and sets

240 views
Skip to first unread message

LoveOptimization

unread,
Jun 19, 2011, 6:11:59 PM6/19/11
to AIMMS - The Modeling System
1) In my optimization model, I have a variable in the form of
X(i,j,t,t-1). When I define the domain index of Variable X as
(i,j,t,t), I encounter an error message saying that index t is
repeated. How can I define variables with repetitive indices?

2) Y(i,t)+Y(j,t-1)-X(i,j,t,t-1)≤1 ∀i,j,t≠1
in the above constraint, i and j represent the same set but as you can
see, i and j get different values for each constraint (i.e. ∀i,j). I
do not know how to define variable Y so that both i and j can be used
when I define the constraint. For example, when I define Y as Y(i,t),
I can not use j for the next Y in the constraint. Moreover, how can I
define t#1 or i=j while defining a constraint both in Index domain and
definition parts?

3) Y(i,t)+Y(j,t-1)-X(i,j,t,d)≤1 ∀i,j,t,d∈{1,2,..,t}
How can I define d∈{1,2,..,t}?

Thank you,

Guido Diepen

unread,
Jun 20, 2011, 4:57:04 AM6/20/11
to ai...@googlegroups.com
Hi,

1) You can do this by creating multiple indices on the same set. For example, you can define a set TimePeriods with multiple indices: t, t1, t2, t3. Now all of these indices will be the same and you can use them to have a parameter/variable with two TimePeriods by using the index domain: "(i,j,t, t2)"

2) As given in my previous answer, you can define one set with both indices i and j. If you now define a variable Y with index domain (i,t), you can also use it in a constraint with the index j, because they are both defined over the same sets.

To solve your problem of having an initial version of your constraint for t=1, and a normal version for t > 1, you can make use of domain conditions to limit the elements to only those applicable. Example:
Constraint: MyConstraintFirstPeriod
Index domain: t | ord(t) = 1   !This constraint will only be generated for those t with ordinal value 1, i.e. the first element

Constraint: MyConstraintOtherPeriods
Index domain: t | ord(t) > 1

Similarly, you can use domain conditions also to not consider the combinations where i=j

3) This can also be done with a domain condition by using a 2 dimensional binary parameter defined over t and d that has value 1 if d \in {1,2,...,t} and 0 otherwise.

You can find more information about domain conditions in the Language Reference.

Guido Diepen
AIMMS Specialist

LoveOptimization

unread,
Jun 22, 2011, 1:52:37 PM6/22/11
to AIMMS - The Modeling System
Thank you for the great information.
Reply all
Reply to author
Forward
0 new messages