Commit fcc3bc1a authored by Joseph Pallamidessi's avatar Joseph Pallamidessi

Change variable name because of redefinition on Windows, closes #14

parent 60287618
...@@ -10,7 +10,7 @@ Operating System: Windows XP ...@@ -10,7 +10,7 @@ Operating System: Windows XP
_________________________________________________________*/ _________________________________________________________*/
\User declarations: \User declarations:
int SIZE=10; int _SIZE_=10;
double pMutPerGene=0.4; double pMutPerGene=0.4;
#include<cstring> #include<cstring>
inline void swap(int& a,int& b) {int c=a; a=b; b=c;} inline void swap(int& a,int& b) {int c=a; a=b; b=c;}
...@@ -20,7 +20,7 @@ _________________________________________________________*/ ...@@ -20,7 +20,7 @@ _________________________________________________________*/
void cross(GenomeClass *pChild, GenomeClass *pParent, int locus){ void cross(GenomeClass *pChild, GenomeClass *pParent, int locus){
Element *p, *pChildList, *pParentList; Element *p, *pChildList, *pParentList;
pChildList=pChild->pList; pParentList=pParent->pList; pChildList=pChild->pList; pParentList=pParent->pList;
for (int i=0;i<SIZE;i++){ for (int i=0;i<_SIZE_;i++){
if (i>=locus){ if (i>=locus){
for(p=pChild->pList;pParentList->Value!=p->Value;p=p->pNext); for(p=pChild->pList;pParentList->Value!=p->Value;p=p->pNext);
swap(p->Value, pChildList->Value); swap(p->Value, pChildList->Value);
...@@ -32,7 +32,7 @@ void cross(GenomeClass *pChild, GenomeClass *pParent, int locus){ ...@@ -32,7 +32,7 @@ void cross(GenomeClass *pChild, GenomeClass *pParent, int locus){
\end \end
\Before everything else function: \Before everything else function:
if ((argc>1)&&(!strcmp(argv[1],"size"))) SIZE=atoi(argv[2]); if ((argc>1)&&(!strcmp(argv[1],"size"))) _SIZE_=atoi(argv[2]);
\end \end
\User classes: \User classes:
...@@ -50,9 +50,9 @@ void cross(GenomeClass *pChild, GenomeClass *pParent, int locus){ ...@@ -50,9 +50,9 @@ void cross(GenomeClass *pChild, GenomeClass *pParent, int locus){
Element *pElt; Element *pElt;
Genome.Size=0; Genome.Size=0;
Genome.pList=NULL; Genome.pList=NULL;
for (int i=0;i<SIZE;i++){ // creation of a linked list of SIZE elements for (int i=0;i<_SIZE_;i++){ // creation of a linked list of _SIZE_ elements
pElt=new Element; // with the decreasing values: pElt=new Element; // with the decreasing values:
pElt->Value=i+1; // (SIZE, SIZE-1, ... , 3, 2, 1) pElt->Value=i+1; // (_SIZE_, _SIZE_-1, ... , 3, 2, 1)
pElt->pNext=Genome.pList; pElt->pNext=Genome.pList;
Genome.pList=pElt; Genome.pList=pElt;
Genome.Size++; Genome.Size++;
...@@ -60,7 +60,7 @@ void cross(GenomeClass *pChild, GenomeClass *pParent, int locus){ ...@@ -60,7 +60,7 @@ void cross(GenomeClass *pChild, GenomeClass *pParent, int locus){
\end \end
\GenomeClass::crossover: \GenomeClass::crossover:
int locus=random(0,SIZE-1); int locus=random(0,_SIZE_-1);
cross(&child, &parent2, locus); cross(&child, &parent2, locus);
\end \end
...@@ -86,7 +86,7 @@ void cross(GenomeClass *pChild, GenomeClass *pParent, int locus){ ...@@ -86,7 +86,7 @@ void cross(GenomeClass *pChild, GenomeClass *pParent, int locus){
else eval-=2; else eval-=2;
p=p->pNext; p=p->pNext;
} }
if (p->Value==SIZE) eval+=10; if (p->Value==_SIZE_) eval+=10;
return (eval<0 ? 0 : eval); return (eval<0 ? 0 : eval);
\end \end
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment