Contents

License. 4

Using this manual 6

Demo Programs. 7

What are genetic algorithms?. 8

Introduction. 8

Chromosomal Representation. 8

Initial Population. 9

Fitness Evaluation. 9

Selection. 9

Crossover – in optiGA.. 9

Mutation – in optiGA.. 11

Termination – in optiGA.. 12

Quick Start 14

Properties. 15

BinaryCrossoverType. 15

IntegerCrossoverType. 15

RealCrossoverType. 15

BinaryMutationType. 15

RealMutationType. 16

IntegerMutationType. 16

TerminationMode. 16

Elitism. 16

PopulationSize. 17

MutationProbability. 17

CrossoverProbability. 17

NumberOfBinaryGenes. 17

NumberOfRealGenes. 17

NumberOfIntegerGenes. 18

MaximumRunTime. 18

MaximumGenerationsWithNoChange. 18

NumberOfGenerations. 18

RandomSeed. 19

ShowErrorMessageBox 19

ReportEveryGeneration. 19

Methods. 20

RunOptiGA.. 20

ShowAboutBox 20

ResetOptiGA.. 20

ResetDefaults. 20

DefineBinaryGenes. 21

DefineRealGenes. 21

DefineIntegerGenes. 22

GetSolutionParameters. 22

Events. 24

FitnessFunction. 24

GenerationReport 24

UserDefinedCrossoverFunction. 24

UserDefinedMutationFunction. 25

Defaults. 26

Public Enumerations. 27

ogaSelectionType. 27

ogaBinaryCrossoverType. 27

ogaRealCrossoverType. 27

ogaIntegerCrossoverType. 27

ogaBinaryMutationType. 28

ogaRealMutationType. 28

ogaIntegerMutationType. 28

ogaDataType. 28

ogaObjectiveFunctionType. 28

ogaTerminationType. 29

ePrintingMethod. 29

Contacts and Registration. 30

Registration. 30

Contacts. 30

 

License

The following END USER LICENSE AGREEMENT applies to the optiGA ActiveX software package (the “SOFTWARE”).

This End-User license Agreement ("EULA”) is a legal agreement between you (the “USER” - either an individual or a single entity) and Elad Salomons (the “AUTHOR”) for the use of the SOFTWARE.  By installing, copying, or otherwise using the SOFTWARE, you agree to be bound by the terms of this EULA.

Trial Version

The trial (Shareware) version of this software may be used for evaluation purposes at the USER's own risk for a period of 30 days from the date of installation. At the end of the trial period, the USER must either purchase a license (register) to continue using the software, or remove it from his/her system.  Software developed using the trial version must not be distributed to end-users for profit or otherwise, except so far as this is for demonstration purposes

Registered (Commercial) Version

GRANT OF LICENSE. The SOFTWARE PRODUCT is protected by copyright laws and international copyright treaties, as well as by other intellectual property laws and treaties. The SOFTWARE is licensed, not sold.  You may install and use the SOFTWARE on a single computer to design, develop, and test software application products ("Application").

COPYRIGHT. All right, title, and copyright in and to the SOFTWARE and any copies of the SOFTWARE, are owned by the AUTHOR. The SOFTWARE is protected by copyright laws and international treaty provisions. Therefore, you may either (a) copy the SOFTWARE solely for backup or archival purposes, or (b) install the SOFTWARE on a single computer provided you keep the original solely for backup or archival purposes. You may not copy the printed materials which might accompany the SOFTWARE.

LIMITED WARRANTY. The AUTHOR warrants that in the case of a CDROM disk being sent to you, the original distribution media is free from defects for 90 days from the date of delivery of the SOFTWARE.  This limited warranty does not apply in the case of online download of the SOFTWARE.

NO OTHER WARRANTIES. To the maximum extent permitted by applicable law, the AUTHOR expressly disclaims any warranty for the SOFTWARE. The SOFTWARE and any related documentation is provided "as is" without warranty of any kind, either express or implied, including, without limitation, the implied warranties or merchantability of fitness for a particular purpose. The entire risk arising out of use or performance of the SOFTWARE remains with you.

LIMITATION OF LIABILITY AND CUSTOMER REMEDIES. The AUTHOR’s entire liability and your exclusive remedy under this EULA shall be, at the AUTHOR’s option, either (a) return of the price paid for the SOFTWARE or (b) replacement of the SOFTWARE which does not meet the AUTHOR’s Limited Warranty and which is returned to the AUTHOR’s with a copy of your receipt. Any replacement SOFTWARE will be warranted for the remainder of the original warranty period or 30 days, whichever is longer.

NO LIABILITY FOR CONSEQUENTIAL DAMAGES. To the maximum extent permitted by applicable law, in no event shall the AUTHOR be liable for any damages whatsoever (including, without limitation, damages for loss of business profit, business interruption, loss of business information, or any other pecuniary loss) arising out of the use or inability to use this product, even if the AUTHOR has been advised of the possibility of such damages. Because some states/jurisdictions do not allow the exclusion or limitation of liability for consequential or incidental damages, the above limitation may not apply to you.

Using this manual

The manual is best viewed in MSWord 2000 to get full use of the hypertext links liberally sprinkled throughout the text.  Or you can open Manual.htm in you browser of choice and get the same functionality.

This is the format for code snippets in the text.

Demo Programs

 

What are genetic algorithms?

 

Introduction

Genetic algorithms were invented by Holland to mimic some of the processes of natural evolution and selection. In nature, each species needs to adapt to a complicated and changing environment in order to maximize the likelihood of its survival. The knowledge that each species gains is encoded in its chromosomes, which undergo transformations when reproduction occurs. Over a period of time, these changes to the chromosomes give rise to species that are more likely to survive, and so have a greater chance of passing their improved characteristics on to future generations. Of course, not all changes will be beneficial but those that are not tend to die out.

Holland's genetic algorithm attempts to simulate nature's genetic algorithm in the following manner. The first step is to represent a legal solution to the problem you are solving by a string of genes that can take on some value from a specified finite range or alphabet. This string of genes, which represents a solution, is known as a chromosome. Then an initial population of legal chromosomes is constructed at random. At each generation, the fitness of each chromosome in the population is measured. The fitter chromosomes are then selected to produce offspring for the next generation, which inherit the best characteristics of both the parents. After many generations of selection for the fitter chromosomes, the result is hopefully a population that is substantially fitter than the original. All genetic algorithms consist of the following main components:

 

Chromosomal Representation

Each chromosome represents a legal solution to the problem and is composed of a string of genes. The binary alphabet {0,1} is often used to represent these genes but sometimes, depending on the application, integers or real numbers are used. In fact, almost any representation can be used that enables a solution to be encoded as a finite length string.

 

Initial Population

Once a suitable representation has been decided upon for the chromosomes, it is necessary to create an initial population to serve as the starting point for the genetic algorithm. This initial population is usually created randomly. From empirical studies, over a wide range of function optimization problems, a population size of between 30 and 100 is usually recommended.

 

Fitness Evaluation

Fitness evaluation involves defining an objective or fitness function against which each chromosome is tested for suitability for the environment under consideration. As the algorithm proceeds we would expect the individual fitness of the "best" chromosome to increase as well as the total fitness of the population as a whole.

 

Selection

We need to select chromosomes from the current population for reproduction. If we have a population of size 2N, the selection procedure picks out two parent chromosomes, based on their fitness values, which are then used by the crossover and mutation operators (described below) to produce two offspring for the new population. This selection/crossover/mutation cycle is repeated until the new population contains 2N chromosomes i.e. after cycles. The higher the fitness value the higher the probability of that chromosome being selected for reproduction.

 

Crossover – in optiGA

After two parents have been selected by the selection method, crossover takes place. Crossover is an operator that mates the two parents (chromosomes) to produce twp offsprings. The two newborn chromosomes may be better then their parents and the evolution process may continue. The crossover in carried out according to the crossover probability.

Here are the crossover methods implemented by optiGA:

 

One point

A random crossover point is selected. The first part of the first parents is hooked up with the second part of the second parent to make the first offspring. The second offspring is build from the first part of the second parent and the second part of the first parent (the crossover point is noted by the | sign):

Parent #1: 011101|0101

Parent #2: 100111|0111

Offspring #1: 011101|0111

Offspring #2: 100111|0101

Implemented for binary genes only!

 

Two points

The two points crossover operator differs from the one point crossover in the fact that two crossover points are selected randomly:

Parent #1: 011|101|0101

Parent #2: 100|111|0111

Offspring #1: 011|101|0111

Offspring #2: 100|111|0101

Implemented for binary genes only!

 

Uniform

In the uniform crossover each bit/gene is selected randomly, either from the first parent or from the second one:

Parent #1: 0111010101

Parent #2: 1001110111

Offspring #1: 0111010111

Offspring #2: 1001110101

 

Blending

This crossover operator is a kind of linear combination of the two parents that uses the following equations for each gene:

Offspring #1 = parent1 – b * (parent1 – parent2)

Offspring #2 = parent2 + b * (parent1 – parent2)

Were b is a random value between 0 and 1.

Implemented for real and integers genes only!

 

User defined

The user defined crossover method is the most powerful one. With this method the user may code his own crossover operator, so the sky is the limit.

 

Mutation – in optiGA

Mutation is the genetic operator that randomly changes one or more of the chromosome’s gene. The purpose of the mutation operator is to prevent the genetic population from converging to a local minimum and to introduce to the population new possible solutions. The mutation is carried out according to the mutation probability.

Here are the mutation methods implemented by optiGA:

 

Flip bit

This mutation method simply changes (flips) a randomly selected bit:

Before mutation:           0111010101

After mutation:  0111000101

Implemented for binary genes only!

 

Random

The random mutation operator exchange’s a random selected gene with a random value within the range of the gene’s minimum value and the gene’s maximum value.

Implemented for real and integers genes only!

 

Min-max

The min-max mutation operator exchange’s a random selected gene with the gene’s minimum value or with the gene’s maximum value, selected randomly.

Implemented for real and integers genes only!

 

User defined

The user defined mutation method is the most powerful one. With this method the user may code his own mutation operator, so the sky is the limit.

 

Termination – in optiGA

The termination method determines when will the genetic process stop evolving.

Here are the termination methods implemented by optiGA:

 

Maximum generations

The genetic process will end when the specified number of generation’s have evolved.

 

Elapsed time

The genetic process will end when a specified time has elapsed.

Note: if the maximum number of generation has been reached before the specified time has elapsed, the process will end.

 

No change in fitness

The genetic process will end if there is no change to the population’s best fitness for a specified number of generations.

Note: if the maximum number of generation has been reached before the specified number of generation with no changes has been reached, the process will end.

 

Quick Start

If you to get going fast you can do it by using optiGA’s build in defaults. Setting up a model is very simple with optiGA. You just have to follow these few steps:

  1. Define your parameters (genes) – parameters can be binary, real or integer, or any combination on these types. To define the parameters use the definition methods: DefineBinaryGenes, DefineRealGenes or DefineIntegerGenes.
  2. Code your fitness function – the fitness function should be coded under the FitnessFunction event.
  3. Run opriGA – run the model by using the RunOptiGA method.

That is it!!!

 

On the other hand, if you want more control over the genetic algorithm process use optiGA’s many properties to get the results you want. optiGA's properties are introduced in the Properties section of this manual.

 

Properties

BinaryCrossoverType

ogaBinaryCrossoverType.  Read/Write.

Return or sets the binary portion of the chromosomes crossover type. Available types: OnePoint, TwoPoints, Uniform, UserDefined.

Default: TwoPoints

 

IntegerCrossoverType

ogaIntegerCrossoverType.  Read/Write.

Return or sets the Integer portion of the chromosomes crossover type. Available types: Blending, Uniform, UserDefined.

Default: Blending.

 

RealCrossoverType

ogaRealCrossoverType.  Read/Write.

Return or sets the real portion of the chromosomes crossover type. Available types: Blending, Uniform, UserDefined.

Default: Blending.

 

BinaryMutationType

ogaBinaryMutationType.  Read/Write.

Return or sets the binary portion of the chromosomes mutation type. Available types: FlipBit, UserDefined.

Default: FlipBit.

 

RealMutationType

ogaRealMutationType.  Read/Write.

Return or sets the real portion of the chromosomes mutation type. Available types: Random, MinMax, UserDefined.

Default: Random.

 

IntegerMutationType

ogaIntegerMutationType.  Read/Write.

Return or sets the integer portion of the chromosomes mutation type. Available types: Random, MinMax, UserDefined.

Default: Random.

 

TerminationMode

ogaTerminationType.  Read/Write.

Return or sets the termination mode for the genetic algorithm. Available types: MaximumGenerations, ElapsedTime, NoChangeInFitness.

Default: MaximumGenerations.

 

Elitism

Boolean.  Read/Write.

Determines whether the best chromosome in each generation will be included unchanged in the next generation.

Default: True.

PopulationSize

Long.  Read/Write.

Return or sets the populations size.

Default: 100.

 

MutationProbability

Single.  Read/Write.

Returns or sets the probability for a bit (in binary genes) and a gene (in real and integer data) to be mutated. The probability should be between 0 and 1.

 Default: 0.10.

 

CrossoverProbability

Single.  Read/Write.

Return or sets the probability for two chosen chromosomes to get crossed over. The probability should be between 0 and 1.

Default: 0.95.

 

NumberOfBinaryGenes

Long.  Read.

Returns the number of binary genes defined by the DefineBinaryGenes method.

 

NumberOfRealGenes

Long.  Read.

Returns the number of real genes defined by the DefineRealGenes method.

 

NumberOfIntegerGenes

Long.  Read.

Returns the number of integer genes defined by the DefineIntegerGenes method.

 

MaximumRunTime

Long.  Read/Write.

Return or sets the maximum time, in seconds, allowed for the genetic algorithm to run. Only used when TerminationMode is set to ogaElapsedTime.

Default: 3600.

 

MaximumGenerationsWithNoChange

Long.  Read/Write.

Return or sets the maximum number of generation allowed with no change in the best fitness. Only used when TerminationMode is set to ogaNoChangeFitness.

Default: 50.

 

NumberOfGenerations

Long.  Read/Write.

Return or sets the number of generations to run.

Default: 300.

 

RandomSeed

Single.  Read/Write.

Initializes the random number generator with the seed entered. If the RandomSeed is set 0 then the systems timer is used to generate the seed. By setting this property to a value different then 0, you can set the random numbers generator to come up with the same “random” numbers each run. This option is very important for debugging.

Default: 0.

 

ShowErrorMessageBox

Boolean.  Read/Write.

Determines whether a message box will be shown in case of an error.

Default: True.

 

ReportEveryGeneration

Long.  Read/Write.

Return or sets the frequency of the GenerationReport event. The event will be fired every ReportEveryGeneration generations have passed. If 0 is used then the event will never be fired.

Default: 1.

 

 

Methods

RunOptiGA

Syntax: RunOptiGA() As Variant

Runs the genetic process. The method returns 0 if successful, 1 if not.

I=optiGA.RunOptiGA

 

ShowAboutBox

Syntax: ShowAboutBox() As Variant

Opens optiGA’s about box

OptiGA.ShowAboutBox

 

ResetOptiGA

Syntax: ResetOptiGA() As Integer

Resets all entered parameters to their initial values. You should use this method before any new parameter definitions are made!

optiGA.ResetOptiGA

 

ResetDefaults

Syntax: ResetDefaults() As Variant

Resets all parameters to their default values.

optiGA.ResetDefaults

 

DefineBinaryGenes

Syntax: DefineBinaryGenes(NumberOfGenes As Long, GeneNumberOfBits As Variant) As Integer

This method is used to define binary parameters (genes). NumberOfGenes is the number of parameters being defined. GeneNumberOfBits is an array containing NumberOfGenes elements. Each element is the number of binary bits to be used with the specific gene. For example, if the number of genes is 2 and you specify the number of bits for each gene as 10, then the range of each gene is 0 to 1023 (2^10-1). The method returns 0 if successful, 1 if not.

Dim BinaryGenes As Variant, I As Integer

BinaryGenes = Array(10, 10)

I = DefineBinaryGenes(2, BinaryGenes)

 

DefineRealGenes

Syntax: DefineRealGenes(NumberOfGenes As Long, GeneMinValue As Variant, GeneMaxValue As Variant) As Integer

This method is used to define real parameters (genes). NumberOfGenes is the number of parameters being defined. GeneMinValue and GeneMaxValue are arrays containing NumberOfGenes elements. They define the parameters boundaries. The method returns 0 if successful, 1 if not.

Dim vMin As Variant, vMax As Variant

Dim I As Integer

vMin = Array(0, 0)

vMax = Array(10, 10)

I = DefineRealGenes(2, vMin, Vmax)

 

DefineIntegerGenes

Syntax: DefineIntegerGenes(NumberOfGenes As Long, GeneMinValue As Variant, GeneMaxValue As Variant) As Integer

This method is used to define integer parameters (genes). NumberOfGenes is the number of parameters being defined. GeneMinValue and GeneMaxValue are arrays containing NumberOfGenes elements. They define the parameters boundaries. The method returns 0 if successful, 1 if not.

Dim vMin As Variant, vMax As Variant

Dim I As Integer

vMin = Array(0, 0)

vMax = Array(10, 10)

I = DefineIntegerGenes(2, vMin, Vmax)

 

GetSolutionParameters

Syntax: GetSolutionParameters(Optional RunTime As Long, Optional BestFitness As Single, Optional BinaryGenes As Variant, Optional RealGenes As Variant, Optional IntegerGenes As Variant) As Integer

The method is to be used after the genetic process had been ran. It retrieves the run’s solution. All of the argument are optional, so you can retrieve only the parameters you need:

The method returns 0 if successful, 1 if not.

Dim T As Long, OptimalFitness As Single

Dim BinaryGenes As Variant

Dim I As Integer

I = GetSolutionParameters(T, OptimalFitness, _

     BinaryGenes, ,)

 

 

Events

FitnessFunction

Syntax: FitnessFunction(BinaryGenes As Variant, RealGenes As Variant, IntegerGenes As Variant, GenerationNumber As Long, Fitness As Single)

This event is fired every time the algorithm needs to evaluate the fitness function. You must supply the fitness function value for the chromosome presented in the argument list:

Here is an example of the code under the FitnessFunction event:

 

 

 

GenerationReport

Syntax: GenerationReport(BestFitness As Single, GenerationNumber As Long, BinaryGenes As Variant, RealGenes As Variant, IntegerGenes As Variant, ElapsedTime As Long, GenerationMeanFitness As Single)

 

UserDefinedCrossoverFunction

Syntax: Syntax: UserDefinedCrossoverFunction(DataType As ogaDataType, ParentsParam As Variant, OffspringParam As Variant)

 

UserDefinedMutationFunction

Syntax: UserDefinedMutationFunction(DataType As ogaDataType, BeforeMutation As Variant, AfterMutation As Variant)

 

Defaults

 

Public Enumerations

ogaSelectionType

ogaTopMate = 0

ogaRouletRank = 1

ogaRouletCost = 2

ogaTournament = 3

ogaRandom = 4

 

ogaBinaryCrossoverType

ogaOnePointBCO = 0

ogaTwoPointsBCO = 1

ogaUniformBCO = 2

ogaUserDefinedBCO = 3

 

ogaRealCrossoverType

ogaBlendingRCO = 0

ogaUniformRCO = 1

ogaUserDefinedRCO = 2

 

ogaIntegerCrossoverType

ogaBlendingICO = 0

ogaUniformICO = 1

ogaUserDefinedICO = 2

 

ogaBinaryMutationType

ogaFlipBitBMU = 0

ogaUserDefinedBMU = 1

 

ogaRealMutationType

ogaRandomRMU = 0

ogaMinMaxRMU = 1

ogaUserDefinedRMU = 2

 

ogaIntegerMutationType

ogaRandomIMU = 0

ogaMinMaxIMU = 1

ogaUserDefinedIMU = 2

 

ogaDataType

ogaBinary = 0

ogaReal = 1

ogaInteger = 2

 

ogaObjectiveFunctionType

ogaMinimum = 0

ogaMaximum = 1

 

ogaTerminationType

ogaMaximumGenerations = 0

ogaElapsedTime = 1

ogaNoChangeInFitness = 2

 

ePrintingMethod

Used in PrintingMethod and has the following members:

epOriginalSize = 1

epZoomed = 2

epWantedPagesFull = 3

epWantedPagesProportional = 4

Contacts and Registration

Registration

Registering your own copy of optiGA is easy to do at:

http://www.optiwater.com/optiga/register.html

You will be given all the payment options:

Full details are found on the site.

Contacts

The best place for information is the optiGA web site at:

http://www.optiwater.com/optiga.html

Or you can mail me at: support@optiwater.com with requests for information, technical assistance or bug reports.