org.apache.ignite.ml.util.genetic

## Class Chromosome

- java.lang.Object
- - org.apache.ignite.ml.util.genetic.Chromosome

- All Implemented Interfaces:
    Comparable

      public class Chromosome
      extends Object
      implements Comparable

  Represents the set of genes, known as chromosome in genetic programming. Note: this class has a natural ordering that is inconsistent with equals.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `Chromosome(Double[] doubles)`
    `Chromosome(int size)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `int` | `compareTo(@NotNull Object o)`
    `Chromosome` | `copy()` Creates chromosome copy.
    `Double` | `getFitness()` Returns the fitness value.
    `double` | `getGene(int idx)` Returns the gene value by index.
    `void` | `setFitness(Double fitness)` Sets the fitness value.
    `void` | `setGene(int idx, double geneValue)` Sets gene value by index.
    `int` | `size()` Returns the amount of genes in chromosome.
    `Double[]` | `toDoubleArray()` Returns the double array chromosome representation.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### Chromosome

          public Chromosome(int size)

      Parameters:
        `size` - Size.

    - #### Chromosome

          public Chromosome(Double[] doubles)

      Parameters:
        `doubles` - Doubles.

  - ### Method Detail

    - #### toDoubleArray

          public Double[] toDoubleArray()

      Returns the double array chromosome representation.

    - #### getFitness

          public Double getFitness()

      Returns the fitness value.

    - #### setFitness

          public void setFitness(Double fitness)

      Sets the fitness value.
      Parameters:
        `fitness` - Fitness.

    - #### size

          public int size()

      Returns the amount of genes in chromosome.

    - #### getGene

          public double getGene(int idx)

      Returns the gene value by index.
      Parameters:
        `idx` - Index.

    - #### setGene

          public void setGene(int idx,
                              double geneValue)

      Sets gene value by index.
      Parameters:
        `idx` - Index.
        `geneValue` - Gene value.

    - #### copy

          public Chromosome copy()

      Creates chromosome copy.

    - #### compareTo

          public int compareTo(@NotNull
                               @NotNull Object o)

      Specified by:
        `compareTo` in interface `Comparable`

2021 Copyright © Apache Software Foundation
| Follow @ApacheIgnite
Ignite Database and Caching Platform | : ver. 2.11.0
Release Date | : September 11 2021