Java Reference
In-Depth Information
Class Problem describes the scheduling problem in terms of tasks and
resources. It is an abstract class that must be specialized in order to describe
specific problems. Every subclass must implement method init() .
package scheduler;
import java.util.*;
public abstract class Problem {
private ArrayList tasks # new ArrayList();
private ArrayList resources # new ArrayList();
public Resource getResource( int i) {
return (Resource) resources.get(i);
public Iterator getResources() {
return resources.iterator();
public void addTask(Task task) {
public void addResource(Resource resource) {
public void clear() {
public Activity getActivity( int taskID, int activityID) {
Task task # (Task) tasks.get(taskID);
if (task ## null ) return null ;
Activity activity #
(Activity) task.getActivity(activityID);
return activity;
public abstract void init();
Class Scheduler is the main class of the architecture. It is initialized with
an instance of a concrete problem and supervises the execution of the
scheduling algorithm by the resources.
The schedule() method simply iterates the basic scheduling step, which
requests the resources to schedule their activities, evaluates the per-
formance at each step, and stores the solution corresponding to the best
performance computed so far. The algorithm terminates after a predefined
number of iterations (80 in this case). A better implementation of this
method could define a more general termination clause. At the end of the
algorithm's execution, the method restores the solution corresponding to
the best performance value, which is the final values of the activities'
temporal parameters.
Search WWH ::

Custom Search