Java Reference
In-Depth Information
public void
copy(Activity clone) {
this
.name
#
clone.name;
this
.releaseTime
#
clone.releaseTime;
this
.activationTime
#
clone.activationTime;
this
.terminationTime
#
clone.terminationTime;
this
.dueTime
#
clone.dueTime;
this
.duration
#
terminationTime - activationTime;
}
}
public class
Scheduler {
. . .
private
ArrayList performances
#
new
ArrayList();
public void
setProblem(Problem problem) {
. . .
performances.removeAll(performances);
Iterator iterator
#
problem.getResources();
Resource resource;
while
(iterator.hasNext()) {
iterator.next();
double
perf[]
#
new
double[STEPS];
performances.add(perf);
}
}
public void
schedule(
double
gain) {
// repeats the scheduling step 80 times
for
(
int
step
#
0; step < STEPS; step
!!
) {
double
totPerformance
#
0.0;
// every resource schedules its activities
iterator
#
problem.getResources();
while
(iterator.hasNext())
((Resource) iterator.next()).schedule();
// evaluates the total performance
iterator
#
problem.getResources();
int
i
#
0;
while
(iterator.hasNext()) {
double
p[]
#
(
double
[]) performances.get(i
!!
);
p[step]
#
((Resource) iterator.next()).getPerformance();
totPerformance
!#
p[step];
}
// evaluates the performance of this scheduling step
if
(totPerformance < bestValue) {
bestValue
#
totPerformance;
// this is the best performance up to now
iterator
#
problem.getResources();