Skip to content

Tutorial

John Hu edited this page May 10, 2017 · 2 revisions

Prepare the environment

Before we start our tutorial, we must have a runnable environment installed. Please follow our README to prepare the environment.

Install OpenCLGA

We can use pip3 install git+git://github.com/PyOCL/OpenCLGA.git command to install OpenCLGA. Once installed, we can download the example code from our repository to test it.

Define the problem

It is important to define the problem before solving a problem. According to Artificial Intelligence book, the common procedure to define a problem for Genetic Algorithm is:

  1. Specify the problem, define constraints and optimum criteria.
  2. Represent the problem domain as a chromosome.
  3. Define a fitness function to evaluate the chromosome's performance.
  4. Construct the genetic operators.
  5. Run the GA and tune its parameters.

In this section, we will cover 1, 2, and 3. Item 4 and 5 will be left at next section.

Objective

The problem in this tutorial is a typical scheduling problem, which is also the same example at Artificial Intelligence book. A power station has 7 power generation units. The power generated by this power station should be continuous which means 24x7 running, even if we stop some units for maintenance.

The output of each units are 20, 15, 35, 40, 15, 15, and 10. The maximum power load of 4 seasons are: 80, 90, 65 and 70 MW. For unit 1 and unit 2, we need 2 seasons for maintenance and others are 1 season. Every units should be maintained once a year. During the maintenance, the power reserve must be sufficient which means all power output must cover power load of every season.

The objective of this problem is to find a maintenance schedule which gives us the maximum power reserve. The constraints of this problem are:

  • The maintenance must be at adjacent season for unit 1 and unit 2.
  • The power reserve must be greater than or equal to 0.

The minimum power reserve is the best way to evaluate a maintenance schedule. For example, if we have power reserve for each seasons: 20, 10, 30, and 5 MW, the minimum power reserve is 5 MW at winter.

Chromosome

...

Fitness function

...

Implementation

...

Python

...

OpenCL

...

Clone this wiki locally