IBM ILOG Scheduler User's Manual > Advanced Concepts > Advanced Features and Concepts > Advanced Resources > Resources as Power versus Energy

The standard class of resource defined in Scheduler is IloDiscreteResource. Instances of that class can deal with resource capacity in two ways. You can specify that the resource capacity cannot exceed a given maximum at any point over a given interval of time; and you can specify that a resource capacity must reach a given minimum at every point over a given interval of time.

Another type of capacity limitation is the overall amount of energy (for example, work-hours) that is spent by a resource (for example, a group of nurses) over a given period (for example, a week). You may wish to limit this energy to a maximum or, in contrast, ensure that it reaches a given minimum. IloDiscreteEnergy is used to model energy resources.

Roughly, an instance of the class IloDiscreteEnergy does not represent a resource per se, but the amount of work performed by the resource over regular intervals of time. The energy of an instance of IloDiscreteEnergy is not measured as a number of machines or as a number of men and women, but as a number of machine-hours, human-hours, human-weeks, and so forth, spent in the performance of the scheduled activities.

Example

Let's assume we're creating a schedule for a group of n workers who might agree to work on week-ends, but who would not agree to work more than five days a week. The following function creates both an instance of IloDiscreteResource and an instance of IloDiscreteEnergy to represent that situation. The "theoretical" capacity of the IloDiscreteResource is defined to be n. In the case of the IloDiscreteEnergy, the code imposes a limitation on the energy of (5 * n) worker-days every week. Incidentally, it assumes that date 0 corresponds to the beginning of the first week.

void MakeDiscreteResourceAndEnergy(IloEnv env,
                                   IloInt numberOfWeeks,
                                   IloInt n) { 
   IloDiscreteResource resource(env, n); 
   IloDiscreteEnergy energy(env, 7, 5*n); 
}

Sometimes you may encounter difficulties in deciding whether a resource must be represented by an instance of IloDiscreteResource or by an instance of IloDiscreteEnergy.

There's an easy question to ask yourself in order to make that decision: "If I multiply all dates and activity durations by a given factor, then are the measures of capacity demand multiplied by the same factor?"

If the answer to this question is "yes"--multiplying dates and durations does multiply the capacity by the same factor--then the measure of capacity is a measure of energy, and the resource must be represented by an instance of IloDiscreteEnergy.

If the answer is "no"--multiplying the dates and durations does not change the capacity by the same factor--then the measure of capacity is not a measure of energy, and the resource cannot be represented by an instance of IloDiscreteEnergy.

In the example above, defining a week as a period of 14 days instead of 7 does not change the number of workers. On the other hand, it's possible that each worker would agree to work up to 10 days out of 14. The number of workers does not change, but the number of available worker-days is proportional to the length of the week. In that situation, where the workers agree to work 10 days out of 14, you should use an instance of IloDiscreteEnergy.