summation over an index subset

695 views
Skip to first unread message

ursula challita

unread,
Dec 15, 2012, 7:56:48 PM12/15/12
to ai...@googlegroups.com
Hello,

I have the following scenario:
I have a set of users:k, and a set of base stations:i. each user k is served by a specific base station i.
In one of my constraints, i want to do the summation over the users served by a given base station and for all the base stations.
How can I index my summation? shall I create a new set and make it a subset of users? 

Thank you.

Regards,
Ursula

Guido Diepen

unread,
Dec 16, 2012, 7:13:59 AM12/16/12
to ai...@googlegroups.com
Hi Ursula,

you could create additional indexed subsets. However, it might be easier to have a binary parameter UserLinkedToBaseStation(k,i), which gets the value 1 if the user k is linked to base station i and 0 otherwise.

Then in some constraint that is indexed over all basestations i, you can do the summation in the definition as follows:

sum(k | UserLinkedToBaseStation(k,i) ,   theVariable(k) ) <= someValue

Guido Diepen
AIMMS Specialist

ursula challita

unread,
Dec 16, 2012, 1:31:34 PM12/16/12
to ai...@googlegroups.com
Hello Guido,

I created the binary variable and called it s(i,k).
The definition of my constraint is: sum(k | k in s(i,k,t), w(m,k,t)) = 1
However, I am getting the following error: The variable "s" is not a set which is required for the RHS of the IN operator.

Thank you.

ursula challita

unread,
Dec 16, 2012, 1:40:09 PM12/16/12
to ai...@googlegroups.com
Hi Guido,

I corrected the constraint to :sum(k | s(i,k,t), w(m,k,t)) = 1
I still get the error: The condition "s(i,k,t) $ s.index domain(k,t)" in sum cannot contain variables.
note that s(i,k,t) is a variable in my problem and not a parameter.

Thanks again.
Ursula

Guido Diepen

unread,
Dec 16, 2012, 1:48:17 PM12/16/12
to ai...@googlegroups.com
Hi Ursula,

good to hear that you found the problem with the error about the in operator.

Regarding your new question, there is no way around this: you cannot use a variable as a domain condition. Is this s(i,k,t) something that your model decides? Does the value change during a solve?

If so, and you want to achieve such a thing, you will have to formulate this with additional (linear) constraints and variables.

If not, you can make the variable s(i,k,t) a parameter and ensure it gets the correct values before the solve and the error should disappear :)

Guido Diepen
AIMMS Specialist

ursula challita

unread,
Dec 16, 2012, 3:10:10 PM12/16/12
to ai...@googlegroups.com
Hi Guido,

Unfortunately, s(i,k,t) something that the model decides. However, I did not understand what u mean by "formulate this with additional (linear) constraints and variables".

Thanks for the help:)
Ursula

Guido Diepen

unread,
Dec 17, 2012, 9:11:50 AM12/17/12
to ai...@googlegroups.com
Hi Ursula,

what I meant with that is that you will have to do some additional modeling to achieve this. 

In a nonlinear way, you could write down something like:
 sum(k , s(i,k,t) *  w(m,k,t) ) = 1

If you want to stick with a linear problem, you will have to reformulate your problem in such a way that you achieve the above, but without the multiplication of the two variables.  To do this, typically you will need some additional variables and constraints.

Guido Diepen
AIMMS Specialist

ursula challita

unread,
Dec 20, 2012, 8:07:26 PM12/20/12
to ai...@googlegroups.com
Hello Guido,

I have added a new constraint! The problem is running correctly.

Thanks:)
Ursula
Reply all
Reply to author
Forward
Message has been deleted
0 new messages