MCScheduling 1.0
Set of Algorithms for Solving Mixed-Criticality Scheduling
Classes | Public Member Functions | Protected Member Functions | Properties
MCScheduling.GeneticAlgorithm.CPopulation Class Reference

A population consist of a individual chromosomes that forms potential solutions to a problem. More...

List of all members.

Classes

class  FittestChromosomeEnumerator
 FittestChromosomeEnumerator may be used to enumerate fittest chromosomes of a population in memory efficient way. More...

Public Member Functions

 CPopulation (CConfiguration configuration)
 Creates a new empty population.
 CPopulation (CConfiguration configuration, IChromosome[] chromosomes)
 Creates a new population from the specified list of chromosomes.
 CPopulation (CConfiguration configuration, IChromosome chromosome)
 Creates a new population formed by the specified chromosome.
 CPopulation (CConfiguration configuration, int size)
 Creates a new empty population.
CConfiguration getConfiguration ()
 Returns the configuration of the genetic algorithm used to evolve this population.
void addChromosome (IChromosome chromosome)
 Adds a chromosome to this Population.
void addChromosomes (CPopulation population)
 Adds 'all' the chromosomes in the specified population, if the population has size maximum set, then some of the chromosomes will be ommited.
void setChromosomes (IEnumerable< IChromosome > chromosomes)
 Replaces all chromosomes in the population with the specified list of chromosomes.
void setChromosome (int index, IChromosome chromosome)
 Replaces the chromosome at the specified index with the specified chromosome.
IChromosome getChromosome (int index)
 Returns the chromosome at the specified position.
void removeChromosome (int index)
 Removes a chromosome at the specified index in the population.
IList< IChromosomegetChromosomes ()
 Returns the unmodifiable list of chromosomes forming this population.
int getSize ()
 Returns the population size.
void clear ()
 Removes all the chromosomes from the population.
IChromosome[] toChromosomes ()
 Returns the population of the chromosomes in an array.
IChromosome getFittestChromosome ()
 Returns the fittest chromosome in the population.
IChromosome getWorstFitChromosome ()
 Returns the worst fit chromosome in the population.
bool isChanged ()
 Returns true if the population has been changed, otherwise it returns false.
bool isSorted ()
 Returns true if the population is sorted, false otherwise.
bool hasMaximumSize ()
 Returns true if the maximum capacity of the population is set; otherwise, it returns false.
void setMaximumSize (int maximumSize)
 Sets the maximum size of the population.
bool contains (IChromosome chromosome)
 Determines whether the specified chromosome is present in this population.
IEnumerator< IChromosomegetFittestChromosomes (int count)
 Sorts the chromosomes in the population according to their fitness value using this.sortByfitness(), and then returns the specified number of best fit chromosomes.
void sortByFitness ()
 Sorts the chromosomes in the population according to their fitness value using the IFitnessComparer set in the configuration.
override bool Equals (Object population)
 Determines whether the specified object is equal to this population.
override int GetHashCode ()
 Returns the hashcode of this population.
object Clone ()
 Creates a deep copy of this population.

Protected Member Functions

void setChanged (bool changed)
 Informs the population that its fittest chromosome may have changed.
void setSorted (bool sorted)
 Marks the population as sorted.

Properties

IChromosome this[int index] [get, set]
 Gets or sets the chromosome at the specified index.

Detailed Description

A population consist of a individual chromosomes that forms potential solutions to a problem.

Author:
Tomas Tunys

Constructor & Destructor Documentation

MCScheduling.GeneticAlgorithm.CPopulation.CPopulation ( CConfiguration  configuration)

Creates a new empty population.

Parameters:
configurationThe configuration of the genetic algorithm used to evolve this population.
MCScheduling.GeneticAlgorithm.CPopulation.CPopulation ( CConfiguration  configuration,
IChromosome[]  chromosomes 
)

Creates a new population from the specified list of chromosomes.

Note: Individual chromosomes are not cloned! This means that the structure of the specified chromosomes may be changed during the evolution!

Parameters:
configurationThe configuration of the genetic algorithm used to evolve this population.
chromosomesThe list of chromosomes forming the new population.
MCScheduling.GeneticAlgorithm.CPopulation.CPopulation ( CConfiguration  configuration,
IChromosome  chromosome 
)

Creates a new population formed by the specified chromosome.

Note: Individual chromosomes are not cloned! This means that the structure of the specified chromosomes may be changed during the evolution!

Parameters:
configurationThe configuration of the genetic algorithm used to evolve this population.
chromosomeThe single chromosome forming the new population.
MCScheduling.GeneticAlgorithm.CPopulation.CPopulation ( CConfiguration  configuration,
int  size 
)

Creates a new empty population.

The size argument is used for optimalization reason (lesser memory reallocation).

Parameters:
configurationThe configuration of the genetic algorithm used to evolve this population.
sizeThe number of preallocated slots for the individuals of the initial population.

Member Function Documentation

void MCScheduling.GeneticAlgorithm.CPopulation.addChromosome ( IChromosome  chromosome)

Adds a chromosome to this Population.

Parameters:
chromosomeThe chromosome to be added.
void MCScheduling.GeneticAlgorithm.CPopulation.addChromosomes ( CPopulation  population)

Adds 'all' the chromosomes in the specified population, if the population has size maximum set, then some of the chromosomes will be ommited.

Parameters:
populationThe population of chromosomes to be added.
object MCScheduling.GeneticAlgorithm.CPopulation.Clone ( )

Creates a deep copy of this population.

Returns:
A new population that is a copy of this one.
bool MCScheduling.GeneticAlgorithm.CPopulation.contains ( IChromosome  chromosome)

Determines whether the specified chromosome is present in this population.

Parameters:
chromosomeThe chromosome to be checked.
Returns:
True if the chromosome is in this population, false otherwise.
override bool MCScheduling.GeneticAlgorithm.CPopulation.Equals ( Object  population)

Determines whether the specified object is equal to this population.

Parameters:
populationThe object to be compared.
Returns:
True if the specified object is equal to this population, otherwise false.
IChromosome MCScheduling.GeneticAlgorithm.CPopulation.getChromosome ( int  index)

Returns the chromosome at the specified position.

Parameters:
indexThe index of the chromosome to be returned.
Returns:
A chromosome at specified index in the population.
IList<IChromosome> MCScheduling.GeneticAlgorithm.CPopulation.getChromosomes ( )

Returns the unmodifiable list of chromosomes forming this population.

Returns:
A readonly list of chromosomes forming this population.
CConfiguration MCScheduling.GeneticAlgorithm.CPopulation.getConfiguration ( )

Returns the configuration of the genetic algorithm used to evolve this population.

Returns:
The configuration of the genetic algorithm used to evolve this population.
IChromosome MCScheduling.GeneticAlgorithm.CPopulation.getFittestChromosome ( )

Returns the fittest chromosome in the population.

The comparison of the fitness is made by the IFitnessComparer set in the configuration.

Returns:
The fittest chromosome of the population.
IEnumerator<IChromosome> MCScheduling.GeneticAlgorithm.CPopulation.getFittestChromosomes ( int  count)

Sorts the chromosomes in the population according to their fitness value using this.sortByfitness(), and then returns the specified number of best fit chromosomes.

Parameters:
countThe number of best fit chromosomes in the population to be returned.
Returns:
An enumerator of the best fit chromosomes of the population. The number of items the enumerator enumerates is equal to the count parameter or to the size of the population in case this.size() < count.
override int MCScheduling.GeneticAlgorithm.CPopulation.GetHashCode ( )

Returns the hashcode of this population.

Returns:
The population's hash code.
int MCScheduling.GeneticAlgorithm.CPopulation.getSize ( )

Returns the population size.

Returns:
The number of chromosomes in the population.
IChromosome MCScheduling.GeneticAlgorithm.CPopulation.getWorstFitChromosome ( )

Returns the worst fit chromosome in the population.

The comparison of the fitness is made by the IFitnessComparer set in the configuration.

Returns:
The worst fit chromosome of the population.
bool MCScheduling.GeneticAlgorithm.CPopulation.isChanged ( )

Returns true if the population has been changed, otherwise it returns false.

Returns:
True if the population has been changed, false otherwise.
void MCScheduling.GeneticAlgorithm.CPopulation.removeChromosome ( int  index)

Removes a chromosome at the specified index in the population.

Parameters:
indexThe index of the chromosome to be removed.
void MCScheduling.GeneticAlgorithm.CPopulation.setChanged ( bool  changed) [protected]

Informs the population that its fittest chromosome may have changed.

Parameters:
changedIf true, the population's fittest chromosome may have changed, if false, the current fittest chromosome is still valid.
void MCScheduling.GeneticAlgorithm.CPopulation.setChromosome ( int  index,
IChromosome  chromosome 
)

Replaces the chromosome at the specified index with the specified chromosome.

If the index is greater or equal to the population size the chromosome is added to the population.

Parameters:
indexThe position of the chromosome to be replaced.
chromosomeThe chromosome to be set.
void MCScheduling.GeneticAlgorithm.CPopulation.setChromosomes ( IEnumerable< IChromosome chromosomes)

Replaces all chromosomes in the population with the specified list of chromosomes.

Parameters:
chromosomesThe chromosomes forming the population.
void MCScheduling.GeneticAlgorithm.CPopulation.setMaximumSize ( int  maximumSize)

Sets the maximum size of the population.

Any chromosome added to the population that would make it larger then this value is ignored.

Parameters:
maximumSizeThe maximum size of the population.
void MCScheduling.GeneticAlgorithm.CPopulation.setSorted ( bool  sorted) [protected]

Marks the population as sorted.

Parameters:
sortedIf true the population is sorted.
void MCScheduling.GeneticAlgorithm.CPopulation.sortByFitness ( )

Sorts the chromosomes in the population according to their fitness value using the IFitnessComparer set in the configuration.

The chromosomes are sorted from the fittest to the worst fit, which results in the fittest chromosome being positioned at index 0.

IChromosome [] MCScheduling.GeneticAlgorithm.CPopulation.toChromosomes ( )

Returns the population of the chromosomes in an array.

Returns:
The population in the form of an array.

Property Documentation

IChromosome MCScheduling.GeneticAlgorithm.CPopulation.this[int index] [get, set]

Gets or sets the chromosome at the specified index.

Parameters:
indexThe zero-based index of the chromosome to get or set.
Returns:
The chromosome at the specified index.
Exceptions:
ArgumentOutOfRangeExceptionIf the index is less then 0 or greater-or-equal to this.size().
 All Classes Namespaces Functions Variables Properties