Java Reference
In-Depth Information
if (activationTime < releaseTime)
pe # (releaseTime - activationTime);
return pe ! pt;
}
// The store() method is used to store an activity's
// temporal parameters that correspond to the best
// performance solution found by the scheduling algorithm
// during a given iteration step.
public void store() {
tempActivationTime # activationTime;
tempTerminationTime # terminationTime;
}
// The restore() method is invoked at the end of the
// scheduling process to copy into an activity's
// temporal parameters the values corresponding to the
// best performance solution.
public void restore() {
activationTime # tempActivationTime;
terminationTime # tempTerminationTime;
}
}
Class Resource aggregates Activity objects. We use class ArrayList to imple-
ment the containment relationship. Since the Resource needs to sort the list
of activities according to their activation time, we define the inner class
CompareActivities that implements the Comparator interface.
The core of class Resource is the schedule() method that enforces the
temporal and resource constraints of the scheduling problem. The method
executes three basic operations. First, it requests its activities to update
their temporal parameters. They could have been modified by the previous
iteration of the scheduling algorithm. As a consequence, the activities do not
necessarily enforce the temporal and resource constraints of this resource.
Thus, the schedule() method re-orders the activities according to their new
activation time. Finally, the method sequences the activities in such a way
that they do not overlap. This operation requires modifying the temporal
parameters of the activities.
Since the schedule() method modifies the values of the activities' temporal
parameters, it is important to evaluate how these values enforce the tem-
poral constraints represented by the release time and the due time of each
activity. The getPerformance() method computes the performance of the
scheduling algorithm with regard to all the activities.
package scheduler;
import java.util.*;
public class Resource {
class CompareActivity implements Comparator {
public int compare(Object o1, Object o2) {
Search WWH ::




Custom Search