GenrChromosome Class

Inheritance Hierarchy
  • Laga.GeneticAlgorithm
    • public class GenrChromosome
      • NumberChromosome()
      • NumberChromosomeBinary()
      • NumberChromosomeSwap()
      • CharChromosomeBinary()
      • CharChromosome()


Class Constructor:
Syntax Parameters
GenrChromosome(int Size) Size: the length of the chromosome


Methods

NumberChromosome(min, max)

  • Description: This method generates a chromosome composed by random numbers
  • Parameters:
    • min[double or float or int]: The min value in the chromosome
    • max[double or float or int]: The max value in the chromosome(exclusive)
  • Return: double[], float[], int[]

Example

    GenrChromosome chromosome = new GenrChromosome(5);
    double[] Chrom = chromosome.NumberChromosome(0.0, 1.0);
    //result
    0.207198212485387, 0.253313632334263, 0.566322204920613, 0.735812343068334, 0.479827285036364,
    
    float[] Chrom = chromosome.NumberChromosome(0.0f, 1.0f);
    //result
    9.211745E+08, 1.134843E+09, 1.554793E+09, 1.223132E+09, 1.600176E+09,

    int[] Chrom = chromosome.NumberChromosome(0, 10);
    //result
    8, 3, 7, 2, 1,

NumberChromosomeBinary()

  • Description: he method generates a binary chromosome composed by 1s and 0s
  • Parameters:
    • The length is specified in the class constructor
  • Return: int[]

Example

    GenrChromosome chromosome = new GenrChromosome(5);
    int[] Chrom = chromosome.NumberChromosomeBinary();
    //result
    1, 1, 0, 1, 1,

NumberChromosomeSwap(min, max)

  • Description: the method generate a number chromosome composed by non repeated numbers between start and start + size(not inclusive). It’s only for integer numbers, and was designed for combinatorial optimization
  • Parameters:
    • min[int]: The min value in the chromosome
    • max[int]: The max value in the chromosome(inclusive)
  • Return: int[]

Example

    GenrChromosome chromosome = new GenrChromosome(5);
    char[] Chrom = chromosome.NumberChromosomeSwap(0, 4);
    //results
    4, 1, 0, 2, 3,
    3, 1, 2, 0, 4,

CharChromosomeBinary()

  • Description: Generates a binary chromosome of chars, ‘1’ and ‘0’
  • Parameters:
    • The length is specified in the class constructor
  • Return: char[]

Example

    GenrChromosome chromosome = new GenrChromosome(5);
    char[] Chrom = chromosome.CharChromosomeBinary();
    //result
    0, 1, 0, 1, 0,

CharChromosome(start, end)

  • Description: Generates an random char chromosome composed by characters and based on ASCII Table
  • Parameters:
    • start[int]: the start number in the table, inclusive
    • end[int]: the end number in the table, inclusive
  • Return: char[]

Example

    GenrChromosome chromosome = new GenrChromosome(25);
    char[] Chrom = chromosome.CharChromosome(65, 90);
    //result
    E, B, C, N, F, C, O, P, C, H, O, U, Q, U, G, L, K, Z, E, K, X, A, L, B, Q,

    char[] Chrom = chromosome.CharChromosome(33, 47);
    //result
    ,, -, !, /, -, ', %, !, %, %, !, /, ,, +, ), *, &, /, &, /, &, +, (, !, +,

    char[] Chrom = chromosome.CharChromosome(97, 122);
    //result
    q, a, h, k, j, d, u, o, d, l, w, b, d, i, l, l, h, c, n, c, s, d, k, r, h,



Revised documentation: 18/08/2018