Topic
• 3 replies
• Latest Post - ‏2013-06-10T10:01:53Z by GGR
drhachmann
2 Posts

# Pinned topic Interval fragments

‏2013-06-05T19:36:56Z |

My model have several intervals with startOf and sndOf, say:

[1,30], [45,65], [186,190], in minutes

I would like to minimize the total hours of intervals.

In the above example would be 3: [1,60], [61,90], [180, 240].

How Can I model this?

Thanks.

• GGR
44 Posts

#### Re: Interval fragments

‏2013-06-06T13:14:31Z

Hi

I do think you not give enough information to have a correct answer. Nevertheless. That means

The size of the problem in number of interval for processing activities

Which is the structure of the resource that executes these interval

Is your <<hours>> to count are fixed or gliding? By fix I mean they start periodically at the same minute, by gliding that is a segment of time, idle for the processing machine.

I will now propose you some hypothesis: the processing machine is an unary resource (a sequence of intervals) such that it should not be idle for more than one hour.

That is I used the startOfNext expression on the sequence of interval (please refer to the documentation if you do not know this features.and I sum the number of time it is greater that the endOf the interval + 1 hour.

<code>

sum all(i in Intervals) (startOfNext(sequence, intervals[i], origin, origin) + 60 <= endOf(intervals[i],, origin));

<code>

• drhachmann
2 Posts

#### Re: Interval fragments

‏2013-06-06T17:53:50Z
• GGR
• ‏2013-06-06T13:14:31Z

Hi

I do think you not give enough information to have a correct answer. Nevertheless. That means

The size of the problem in number of interval for processing activities

Which is the structure of the resource that executes these interval

Is your <<hours>> to count are fixed or gliding? By fix I mean they start periodically at the same minute, by gliding that is a segment of time, idle for the processing machine.

I will now propose you some hypothesis: the processing machine is an unary resource (a sequence of intervals) such that it should not be idle for more than one hour.

That is I used the startOfNext expression on the sequence of interval (please refer to the documentation if you do not know this features.and I sum the number of time it is greater that the endOf the interval + 1 hour.

<code>

sum all(i in Intervals) (startOfNext(sequence, intervals[i], origin, origin) + 60 <= endOf(intervals[i],, origin));

<code>

So,

I have n tasks to scheduling on m machines. Each task has a duration depending on the machine where it runs.

The scheduling have granularity of minutes.

For exemple, task A can be allocated on the machine X in interval [15,25] (minutes) and task B can be allocated on the machine X in interval [30,80] (minutes).

The cost for use a machine is charged per hour. So for the example above, would be charged for 2 hours : [15,74], [75,135], although the machine is not used all the time. Like Amazon charges by use their instances (http://aws.amazon.com/ec2/)

Other exemple:

Cost per hour: \$0.10

<machine> :  <task>[<start,end>] | <total cost>

X : a[45,61]                           | \$0.10

Y:  b[125,130],  c[150,170]   | \$ 0.10

Z:  d[0,59]                             | \$ 0.10

W:  e[55,65], f[115,125]         | \$0.20

K: f[2, 200]:                           | \$0.40

Total cost: \$1.10

How Can I model this?

regards,

Diego Rodrigo Hachmann

Updated on 2013-06-06T19:19:29Z at 2013-06-06T19:19:29Z by drhachmann
• GGR
44 Posts

#### Re: Interval fragments

‏2013-06-10T10:01:53Z

So,

I have n tasks to scheduling on m machines. Each task has a duration depending on the machine where it runs.

The scheduling have granularity of minutes.

For exemple, task A can be allocated on the machine X in interval [15,25] (minutes) and task B can be allocated on the machine X in interval [30,80] (minutes).

The cost for use a machine is charged per hour. So for the example above, would be charged for 2 hours : [15,74], [75,135], although the machine is not used all the time. Like Amazon charges by use their instances (http://aws.amazon.com/ec2/)

Other exemple:

Cost per hour: \$0.10

<machine> :  <task>[<start,end>] | <total cost>

X : a[45,61]                           | \$0.10

Y:  b[125,130],  c[150,170]   | \$ 0.10

Z:  d[0,59]                             | \$ 0.10

W:  e[55,65], f[115,125]         | \$0.20

K: f[2, 200]:                           | \$0.40

Total cost: \$1.10

How Can I model this?

regards,

Diego Rodrigo Hachmann

Hi

From the samples you gave the cost expression are in OPL:

If only one interval a is involved:  (div(i, j) is the integer division of i by j)

div(lengthOf(a) + 59, 60)

if 2 intervals a and b are involved, a preceding b

div(endOf(b) - startOf(a) + 59, 60) - max_l(0, div(startOf(b) - startOf(a) , 60) - div(endOf(a)  - startOf(a) + 59 , 60) );

I figure out Amazon charges rules proposes an explicit algebraic  formulation (for their own sake and the ones of their customers). You should try to find it out.

Hope that helps