My favorites | Sign in
Project Home Downloads Issues Source
Search
for
writing_jobdefs  
How to write a job definition in Python from scratch.
Updated May 13, 2011 by patrick....@gmail.com

Writing job definitions

The job definition tasks

For the general user, writing a job definition involves defining the tasks that will be executed by Dexen. You need to define one master task, and one or more slave tasks. The job definition has to be written in Python, and a basic understanding of object-orientated programming is required.

A job definition is a self contained folder (or zip file) that contains all the necessary files for running the job. This folder will include the Python files that define the tasks, and any other files that are required.

The Python classes

Typically, the job definition will define the individual, the master tasks, and one or more slave tasks. In order to do this, you must sub-class certain Dexen classes. Three classes need to be sub-classed, as follows:

  • The dexen.BaseIndividual class is sub-classed once in order to define the individual. In the sub-class, you may implement the constructor, which is used to initialise the attributes that store the data for the individual.
  • The dexen.BaseSlaveTask class is sub-classed multiple times in order to define the slave tasks. In each sub-class, you must implement the execute method. This method processes the individuals it receives from the master, and then returns a set of individuals back to the master.
  • The dexen.BaseMasterTask class is sub-classed once in order to define the master task. In the sub-class, you must implement the constructor (and may also optionally implement the execute method). The constructor is used to initialise the population and to register slave tasks.

Job definition folder

The organisation of files and folders inside the job definition folder is very flexible. The only requirement is that a file named master_task.py is present in the top-level root folder, which must contain a MasterTask class.

The job definition folder can be save anywhere in your hard disk. Usually, you would create a Python test file in the job definition for testing the slave tasks before running them in Dexen. (See the examples.)

Job definition examples

The Dexen installation comes with a set of examples in the examples\python folder. The best way to get started is to look at these examples to see how they are organised. The examples are all examples of evolutionary optimization.

hello_world example

To be completed.

packing_boxes example

To be completed.

houdini example

To be completed.


Sign in to add a comment
Powered by Google Project Hosting