ec.eval
Class JobQueue

java.lang.Object
  extended byec.eval.JobQueue

public class JobQueue
extends java.lang.Object

JobQueue.java The queue of jobs that are assigned to a slave (there is a one-to-one mapping between slaves and job queues. The system keeps track of all jobs assigned to a slave such that, if that slave crashed, the jobs can be rescheduled for execution on other threads. As evaluated individuals (or only their fitness) are read back from the slaves, the queue of jobs is continuously updated. For regular evolution, a job consists of an individual that needs to be evaluated, and as such, a job is removed from the queue of jobs each time an individual is read back from the slave. On the other hand, coevolutionary settings involve multiple individuals that are evaluated together; in this case, the queue of jobs keeps track how many more individuals need to be read back from the slave before the current job is finished. Of course, a slave that crashes in the middle of the run requires that the entire job needs to be rescheduled to another slave. The queue is a first-in-first-out data structure. This implies that the jobs are expected to be read back from the slave in exactly the same order as they were sent there.


Constructor Summary
JobQueue(SlaveMonitor sm)
          A simple constructor.
 
Method Summary
 EvaluationData finishReadingIndividual(EvolutionState state, ec.eval.SlaveData slaveData)
          Once an evaluated individual has been read back from a slave, the job queue might undergo certain updates.
 Individual getIndividual(EvolutionState state)
          As the slave executes jobs, it sends back individuals that have been evaluated (or only their fitness).
 int numJobs()
          Returns the number of jobs that a slave is in charge of.
 void rescheduleJobs(EvolutionState state)
          Reschedules the jobs in this job queue to other slaves in the system.
 void reset()
          Resets the state of the queue (empties the queue of jobs)
 void scheduleJob(EvaluationData ed)
          Adds a new jobs to the queue.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JobQueue

public JobQueue(SlaveMonitor sm)
A simple constructor. A pointer to the slave monitor is necessary for synchronization purposes.

Method Detail

reset

public void reset()
Resets the state of the queue (empties the queue of jobs)


scheduleJob

public void scheduleJob(EvaluationData ed)
Adds a new jobs to the queue. This implies that the slave will be in charge of executing this particular job.


getIndividual

public Individual getIndividual(EvolutionState state)
As the slave executes jobs, it sends back individuals that have been evaluated (or only their fitness). This function returns a pointer to the next individual that has to be read back from the slave (only individuals know how to read themselves). In a traditional evolutionary algorithm, this pointer is the one to the only individual associated with the job (the one that was sent to the slave to be evaluated). However, multiple individuals could be sent to the slave for evaluation in a coevolutionary algorithm. In this case, the function uses the information on how many individuals in this current job have been read back from the slave, and returns a pointer to the next individual that is expected from the slave.


finishReadingIndividual

public EvaluationData finishReadingIndividual(EvolutionState state,
                                              ec.eval.SlaveData slaveData)
Once an evaluated individual has been read back from a slave, the job queue might undergo certain updates. In a traditional evolutionary algorithm, a job is finished once the individual is read back, and as such, the job should be removed from the list of jobs that the slave is currently in charge of. In a coevolutionary algorithm, each job consists of multiple individuals. In this case, a job is finished only when all individuals associated with a job have been received back from the slave. The function returns the job that has just finished, or null if no job was finished (only for coevolutionary algorithms).


rescheduleJobs

public void rescheduleJobs(EvolutionState state)
Reschedules the jobs in this job queue to other slaves in the system. It assumes that the slave associated with this queue has already been removed from the available slaves, such that it is not assigned its own jobs.


numJobs

public int numJobs()
Returns the number of jobs that a slave is in charge of.