You should specify the conditions in the index domain. For example, for the first:

Index Domain: t | (Tmin < t < Tmax)

Definition: e(t) <= e(t-1)

The condition depends a little on how you specified the time set with index t. If they are a set of integer values this works; if they are more something like tp-001… tp-100 or some other named period, you would need to use the ord(t) function to count the element number. Eg

Index Domain: t | (Tmin < ord(t) < Tmax)

Definition: e(t) <= e(t-1)

in above cases the constraint generation will only by for those t that fall within the condition specified.

@jounas

Were you able to figure out the solution to your question based on Gertjan’s response?

Thank you for your answers! I was able to solve the problem!

I have one follow up question:

I have a set (index i,j) with four elements: A,B,C,D

I want two access A,B and C,D separatly in a constraint.

First I tried to limit the index domain of the constraint like this:

(i) | (3> ord(i)) so that i just uses A and B

Definition: o(i)=EF(i)-sum(j|(2 > ord(j)),r(i,j)) so that j uses C and D

Secondly I tried to use subsets:

Subset 1 Elements: A and B and index i

Subset 2 Elements: C and D and index j

Constraint:

Index Domain: (i,j)

Definition: o(i)=EF(i)-sum(j,r(i,j))

There was no error occuring but it seems like the program isn’t working as expected.

Therefore I would like to inquire on how to do this correctly.

Thank you again for your answers!

Best regards,

Jonas

Or to specify my question further:

How can I use the the index of a base set and limit it to the scope of a subset?

And how do I use default binding in this context?

Hi @jounas ,

You are not adding full context, so not sure if answer below is sufficient. Anyhow, your ideas posted about sound perfectly fine; guess it’s about fixing some details. Here some more info for you that I think will help:

- Limiting scope of constraint index could be done using index ( i | ord(i) <= 2 ) to get A and B. You could also (if elements are fixed) just use actual values ( i | i = ‘A’ or i = ‘B’)
- You could index also use subsets. Just make sure these subsets have their own index; so e.g subset1AB with index i_1, j_1 and subset2CD with index i_2,j_2. Now you can use those subset indices to specify the range of a constraint (over i_1) or the limited sum-calculation (over i_2)

Please notice that now the master set {A,B,C, D} has indices i, j while subsets have and underscore with respectively _1 (subset {A,B}) and _2 (subset {C,D}). No need to have a constraint over both indices; just i (or if over subset i_1 or i _2) is sufficient. You can use the j for the summations.

Hope it does help.

PS: Best to start a new thread for a new question to assure the community sees it and can reply (instead to adding it below this ‘solved’ question).