Page 1 of 1

bounds on sum for looping through sets

Posted: Tue Mar 26, 2019 10:01 am
by suprafluid
Hello everyone, it is me again,

I have a second issue when modeling my application for the purpose of finding out the maximum power needed. My objects i are moving in a circle and need to keep a minimum distance dMin between each other at all timesteps t. I store if an object i is at a location l at a specific timestep t in a binary variable c(i,l,t). Hence, the sum over all c(i,l,t) should be 1 for a sequence of locations defined by the minimum distance dMin. So for all specific locations l*, the lower bound should be l*-dMin/2 and the upper bound should be l*+dMin/2.

1. I can't figure out how to implement lower and upper bounds. It feels like I need to use sth like

Code: Select all

minDistance(l,t)..  sum(i,(sum(l $ ord(l-dMin/2) to ord(l+dMin/2), c(i,l,t))) =l= 1
2. I am trying to have dMin/2 expressed as a number of locations in positive and negative direction. But how can I go from the starting point of my circle, location 1, backwards to the ending point, location N? Does sth like location 1-4 give location N-3?

I am looking forward to any suggestions, ideas and answers!

Best regards
supra

Re: bounds on sum for looping through sets

Posted: Tue Mar 26, 2019 4:42 pm
by suprafluid
UPDATE:

I tried further coming up with the following, still not working code (Error 125: Set is under control already):

Code: Select all

minDistance(lc,t) ..   sum(i,sum(lc $ (ord(lc) ge ord(lc-dMinlc) and ord(lc) le ord(lc+dMinlc)),c(i,lc,t))) =l= 1
I replaced set l by set lc, just beacuse it is easier to distinguish from the number 1. dMinlc is now the minimum distance measured in a number of locations lc. I understand the error message, i.e. that the set is already under control, but thats exactly my point here. I don't know how to handle such a situation. The bounds of the sum are dependent on lc, and the whole constraint is supposed to hold for all lc.

Re: bounds on sum for looping through sets

Posted: Wed Mar 27, 2019 8:33 am
by suprafluid
UPDATE 2:

Found a working but not satisfying solution by hardcoding the number of lags that represent a minimum that I have to determine in advance. So I get sth like this:

Code: Select all

minDistance(lc,t) ..   sum(i, c(i,lc-dMinlc,t) + c(i,lc-(dMinlc-1),t) + ... + c(i,lc,t) + ... + c(i,lc+dMinlc,t)) =l= 1
So I am still looking forward to any suggestions on how to implement this without hardcoding all lags in advance.

Best regards
supra

Re: bounds on sum for looping through sets

Posted: Tue Apr 09, 2019 9:06 am
by Fred
Hi,

To me it seems that basically your problem is that you need to refer to different elements of set lc in the equation. One element of lc is controlled by the equation domain and then you need to sum over other elements of lc in the euqation body. The alias statement should help you to do that: https://www.gams.com/latest/docs/UG_Set ... mesForASet

I hope this helps!

Fred

Re: bounds on sum for looping through sets

Posted: Tue Apr 09, 2019 2:24 pm
by mogue92
Hi Supra,

Fred solved my/our problem:

viewtopic.php?f=2&t=10791&p=25228#p25228

Moritz