Solved

# Summation over subset of time • Supporter
• 3 replies

I am trying to implement the Rough Cut Capacity Planning for an school assignment. I currently have all constraints working except for the first constraint, since I do not know how I can loop over subset of time which is determined by two parameters release date(rj) and due date (dj).

icon

Best answer by mohansx 8 June 2021, 02:09

@diederik , building on @gdiepen ‘s response, your constraint could look something like

`constraint_1,`

`index domain: j`

`Definition: sum[t | t>= r(j) and t <= d(j), x(j, t) = 1]`

Ultimately, it depends on how you declared the set T (is it a calendar of dates or weeks, or just a plain set of time periods {1, 2, … 5} ) and how the data for r(j) and d(j) is available - is it in same format of Set T or different ?

For example, if r(j) and d(j) are in dates but Set T is a calendar of weeks, then you will need helper functions as below. I suggest you also create a calendar of dates with the same format as r(j) and s(j), and declare these two as element parameters in this calendar.

`sum[t | t >= Timeslotcharacteristic(r(j), ‘week’) and t <= Timeslotcharacteristic(d(j), ‘week’)), x(j, t) = 1]`

TimeSlotCharacteristic — AIMMS Function Reference

View original

### 4 replies

Userlevel 4 +2

The easiest might be to consider making the set T a subset of integers.

You can then combine the r_j, d_j and value of t using a parameter indicating which t’s are relevant for each j and sum over those t’s using a so-called domain condition in AIMMS (using the | or such-that operator)

Userlevel 5 +2

@diederik , building on @gdiepen ‘s response, your constraint could look something like

`constraint_1,`

`index domain: j`

`Definition: sum[t | t>= r(j) and t <= d(j), x(j, t) = 1]`

Ultimately, it depends on how you declared the set T (is it a calendar of dates or weeks, or just a plain set of time periods {1, 2, … 5} ) and how the data for r(j) and d(j) is available - is it in same format of Set T or different ?

For example, if r(j) and d(j) are in dates but Set T is a calendar of weeks, then you will need helper functions as below. I suggest you also create a calendar of dates with the same format as r(j) and s(j), and declare these two as element parameters in this calendar.

`sum[t | t >= Timeslotcharacteristic(r(j), ‘week’) and t <= Timeslotcharacteristic(d(j), ‘week’)), x(j, t) = 1]`

TimeSlotCharacteristic — AIMMS Function Reference Thank you for your answer @gdiepen. I am bit new to AIMMS and have made the set T a subset of integers, but cant figure out how the parameter should look like.

Userlevel 4 +2

@mohansx actually provided you with pretty much all of the required details ;)

You should have two parameters r and d that are indexed over the jobs j also.

Then in summations, you can use the | or such-that operator (look up domain conditions in the aimms manuals for more information) to sum over all times t such that a particular condition holds (e.g., in your case the t is between release and due date)

### Reply

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