// nastavenie metody krizenia public override void Crossover(IChromosome pair) { TSPChromosome p = (TSPChromosome)pair; // kontrola spravnosti paru if ((p != null) && (p.length == length)) { ushort[] child1 = new ushort[length]; ushort[] child2 = new ushort[length]; // vytvorenie dvoch potomkov CreateChildUsingCrossover(this.val, p.val, child1); CreateChildUsingCrossover(p.val, this.val, child2); // nahradenie rodicov potomkami this.val = child1; p.val = child2; } }
//Оператор схрещування public override void Crossover(IChromosome pair) { TSPChromosome p = (TSPChromosome)pair; // перевірка правильності пари if ((p != null) && (p.length == length)) { ushort[] child1 = new ushort[length]; ushort[] child2 = new ushort[length]; // створення двох дітей CreateChildUsingCrossover(this.val, p.val, child1); CreateChildUsingCrossover(p.val, this.val, child2); // заміна батьків дітьми this.val = child1; p.val = child2; } }
/// <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; } }
/// <summary> /// Copy Constructor /// </summary> protected TSPChromosome(TSPChromosome source) : base(source) { this.map = source.map; }
/// <summary> /// Copy Constructor /// </summary> protected TSPChromosome( TSPChromosome source ) : base( source ) { this.map = source.map; }