The chromosome is to solve TSP task (Travailing Salesman Problem).
Inheritance: Accord.Genetic.PermutationChromosome
Exemplo n.º 1
0
        /// <summary>
        /// Crossover operator
        /// </summary>
        public override void Crossover(IChromosome pair)
        {
            TSPChromosome p = (TSPChromosome)pair;

            // check for correct pair
            if ((p != null) && (p.length == length))
            {
                ushort[] child1 = new ushort[length];
                ushort[] child2 = new ushort[length];

                // create two children
                CreateChildUsingCrossover(this.val, p.val, child1);
                CreateChildUsingCrossover(p.val, this.val, child2);

                // replace parents with children
                this.val = child1;
                p.val    = child2;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Crossover operator
        /// </summary>
        public override void Crossover(IChromosome pair)
        {
            TSPChromosome p = (TSPChromosome)pair;

            // check for correct pair
            if ((p != null) && (p.length == length))
            {
                ushort[] child1 = new ushort[length];
                ushort[] child2 = new ushort[length];

                // create two children
                RILogManager.Default.SendTrace("Crossover creating children");
                CreateChildUsingCrossover(val, p.val, child1);
                CreateChildUsingCrossover(p.val, val, child2);

                // replace parents with children
                RILogManager.Default.SendTrace("Crossover replacing parents with children");
                val   = child1;
                p.val = child2;
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// Copy Constructor
 /// </summary>
 protected TSPChromosome(TSPChromosome source)
     : base(source)
 {
     map = source.map;
 }
Exemplo n.º 4
0
 /// <summary>
 /// Copy Constructor
 /// </summary>
 protected TSPChromosome(TSPChromosome source)
     : base(source)
 {
     this.map = source.map;
 }