GeneticAlgorithm  0.5 (beta)
A python framework for rapid GA prototyping
src/examples/KnapsackDemo.py File Reference

Go to the source code of this file.

Classes

class  KnapsackDemo.Knapsack
 An evaluation operator that computes the relaxed version of the objective function used to solve a knapsack instance. More...

Namespaces

namespace  KnapsackDemo

Variables

int KnapsackDemo.nObjects = 12
list KnapsackDemo.objectVolumes = [random.randrange(1, 20) for i in xrange(nObjects)]
list KnapsackDemo.objectCosts = [random.randrange(10, 20) for i in xrange(nObjects)]
tuple KnapsackDemo.maxVolume = reduce(lambda x, y: x+y, objectVolumes)
int KnapsackDemo.volumeLambda = 10
 KnapsackDemo.maximize = True
int KnapsackDemo.nGenerations = 5
int KnapsackDemo.popSize = 10
tuple KnapsackDemo.genSize = int(math.floor( popSize/10 ))
tuple KnapsackDemo.ch = Core.Genotype(segments=[GenotypeLibrary.BinaryChromosomeSegment(nBits=1) for i in range(nObjects)])
tuple KnapsackDemo.p = Core.Population(schema=ch, popSize=popSize, genSize=genSize, maximize=maximize, mutation_probability=0.01)
tuple KnapsackDemo.ga
 All Classes Namespaces Files Functions Variables