/* Selah Lynch solution.cc July 2004 Class Solution Definitions, see .h file for class description */ #include #include #include "solution.h" /*delete this:*/ #include Solution::Solution(int numpntsarg){ numpoints=numpntsarg; order = new int [numpoints]; SetAsRand(); } Solution::Solution(Solution& s){ numpoints=s.numpoints; order = new int [numpoints]; for(int i=0; ipt2){ temp2=pt1; pt1=pt2; pt2=temp2; } //copy appropriate values to child from mom for(ch_indx=pt1; ch_indx<=pt2; ch_indx++) { order[ch_indx]=mom.order[ch_indx]; picked[order[ch_indx]]=true; } //copy appropriate values to child from dad ch_indx=0; for(int n=0; n //combine the order of those into the child //THEORY: any set of numbers with a favorable connection //is a useful piece of information for the solution } void Solution::SetAsString(int* intstr){ check (intstr!=NULL,"intstr must be set for SetasIntstr()"); for(int i=0; ipt2){ temp2=pt1; pt1=pt2; pt2=temp2; } for(int i=0; i<((pt2-pt1+1)/2); i++){ temp3 = order[pt1+i]; order[pt1+i] = order[pt2-i]; order[pt2-i] = temp3; } } void Solution::MutateRot(){ int incr, *temparr; incr=rand()%(numpoints-1)+1; temparr=new int [incr]; for(int i=0; i