Skip to main content

Dear All,

I have a question on how to limit the range of an index and since I’m new to Aimms I can’t find a proper solution. I just want to limit certain indices to a certain range for a specific constraint.

First example (Constraint):

Index Domain:t

Definition: e(t) <= e(t-1) |t<Tmax |t>Tmin

Error Message:

In an inclusion only the middle term is allowed to contain variables, however in the inclusion e(t) <= e(t-1) $ t < Tmax $ t the left term contains variables.

 

Second Example (Constraint):

Index Domain: (i,j,k,t)

Definition: r(i,j,k,t) <= o(i,k-1,t-1)*RM(i,j) |k>1|t>1

Error Message: The operators <= and > should to be the same for numerical inclusion (or use parenthesis).

 

As I’m new to aimms I dont seem to understand the principles properly. May someone point me to the right way to do this?

Thank you very much in advance!

Best Regards

Jonas

 

 

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:

  1. 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’)
  2. 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).

 

 

 

 

 

 


Reply


Didn't find what you were looking for? Try searching on our documentation pages:

AIMMS Developer & PRO | AIMMS How-To | AIMMS SC Navigator