Commit 80aa1535 authored by Ogier Maitre's avatar Ogier Maitre

Merge de la branche GP et syntaxerror

parent b90e4e08
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -5,7 +5,7 @@ Lexical analyser for the EASEA language (EAsy Specification for Evolutionary Alg ...@@ -5,7 +5,7 @@ Lexical analyser for the EASEA language (EAsy Specification for Evolutionary Alg
Pierre COLLET (Pierre.Collet@polytechnique.fr) Pierre COLLET (Pierre.Collet@polytechnique.fr)
Ecole Polytechnique Ecole Polytechnique
Centre de Mathmatiques Appliques Centre de Mathmatiques Appliques
91128 Palaiseau cedex 91128 Palaiseau cedex
****************************************************************************/ ****************************************************************************/
#ifdef WIN32 #ifdef WIN32
...@@ -327,6 +327,8 @@ exponent ([Ee][+-]?[0-9]+) ...@@ -327,6 +327,8 @@ exponent ([Ee][+-]?[0-9]+)
opDesc[iNoOp]->opcode = new string(yytext); opDesc[iNoOp]->opcode = new string(yytext);
} }
<GP_RULE_ANALYSIS>"//".*"\n" {}
<GP_RULE_ANALYSIS>"\""([a-zA-Z0-9]|\*|\+|\-|\/|\%)*"\"" { <GP_RULE_ANALYSIS>"\""([a-zA-Z0-9]|\*|\+|\-|\/|\%)*"\"" {
if( iGP_OPCODE_FIELD != 1 ){ if( iGP_OPCODE_FIELD != 1 ){
fprintf(stderr,"Error, op code real name must be given at the second place\n"); fprintf(stderr,"Error, op code real name must be given at the second place\n");
...@@ -369,7 +371,7 @@ exponent ([Ee][+-]?[0-9]+) ...@@ -369,7 +371,7 @@ exponent ([Ee][+-]?[0-9]+)
if( bVERBOSE ) printf("begining of the code part\n"); if( bVERBOSE ) printf("begining of the code part\n");
accolade_counter=1; accolade_counter=1;
printf("arity : %d\n",opDesc[iNoOp]->arity); // printf("arity : %d\n",opDesc[iNoOp]->arity);
if( opDesc[iNoOp]->arity>=2 ) if( opDesc[iNoOp]->arity>=2 )
opDesc[iNoOp]->gpuCodeStream << "OP2 = stack[--sp];\n "; opDesc[iNoOp]->gpuCodeStream << "OP2 = stack[--sp];\n ";
if( opDesc[iNoOp]->arity>=1 ) if( opDesc[iNoOp]->arity>=1 )
...@@ -404,7 +406,7 @@ exponent ([Ee][+-]?[0-9]+) ...@@ -404,7 +406,7 @@ exponent ([Ee][+-]?[0-9]+)
<GP_COPY_OPCODE_CODE>"INPUT["[0-9]*"]" { <GP_COPY_OPCODE_CODE>"INPUT["[0-9]*"]" {
char* endptr; char* endptr;
unsigned no_input = strtol(yytext+strlen("INPUT["),&endptr,10); unsigned no_input = strtol(yytext+strlen("INPUT["),&endptr,10);
printf("input no : %d\n",no_input); // printf("input no : %d\n",no_input);
opDesc[iNoOp]->cpuCodeStream << "input["<< no_input <<"]" ; opDesc[iNoOp]->cpuCodeStream << "input["<< no_input <<"]" ;
opDesc[iNoOp]->gpuCodeStream << "input["<< no_input << "]"; opDesc[iNoOp]->gpuCodeStream << "input["<< no_input << "]";
} }
...@@ -413,7 +415,7 @@ exponent ([Ee][+-]?[0-9]+) ...@@ -413,7 +415,7 @@ exponent ([Ee][+-]?[0-9]+)
opDesc[iNoOp]->isERC = true; opDesc[iNoOp]->isERC = true;
opDesc[iNoOp]->cpuCodeStream << "root->erc_value" ; opDesc[iNoOp]->cpuCodeStream << "root->erc_value" ;
opDesc[iNoOp]->gpuCodeStream << "k_progs[start_prog++];" ; opDesc[iNoOp]->gpuCodeStream << "k_progs[start_prog++];" ;
printf("ERC matched\n"); // printf("ERC matched\n");
} }
<GP_COPY_OPCODE_CODE>\n { <GP_COPY_OPCODE_CODE>\n {
...@@ -446,9 +448,26 @@ exponent ([Ee][+-]?[0-9]+) ...@@ -446,9 +448,26 @@ exponent ([Ee][+-]?[0-9]+)
iCOPY_GP_EVAL_STATUS = EVAL_BDY; iCOPY_GP_EVAL_STATUS = EVAL_BDY;
if( bVERBOSE ) printf("Insert GP eval body\n"); if( bVERBOSE ) printf("Insert GP eval body\n");
fprintf(fpOutputFile," "); fprintf(fpOutputFile," ");
bCOPY_GP_EVAL_GPU = false;
BEGIN COPY_GP_EVAL; BEGIN COPY_GP_EVAL;
} }
<TEMPLATE_ANALYSIS>"\\INSERT_GENOME_EVAL_BDY_GPU" {
yyreset();
rewind(fpGenomeFile);
yyin = fpGenomeFile;
bIsCopyingGPEval = false;
iCOPY_GP_EVAL_STATUS = EVAL_BDY;
if( bVERBOSE ) printf("Insert GP eval body\n");
fprintf(fpOutputFile," ");
bCOPY_GP_EVAL_GPU = true;
BEGIN COPY_GP_EVAL;
}
<TEMPLATE_ANALYSIS>"\\INSERT_GENOME_EVAL_FTR" { <TEMPLATE_ANALYSIS>"\\INSERT_GENOME_EVAL_FTR" {
yyreset(); yyreset();
rewind(fpGenomeFile); rewind(fpGenomeFile);
...@@ -523,7 +542,11 @@ exponent ([Ee][+-]?[0-9]+) ...@@ -523,7 +542,11 @@ exponent ([Ee][+-]?[0-9]+)
} }
<COPY_GP_EVAL>"OUTPUT" { <COPY_GP_EVAL>"OUTPUT" {
if( bIsCopyingGPEval) fprintf(fpOutputFile, "outputs[i]" ); if( bIsCopyingGPEval)
if( bCOPY_GP_EVAL_GPU )
fprintf(fpOutputFile, "outputs[i*NUMTHREAD2+tid]" );
else fprintf(fpOutputFile, "outputs[i]" );
} }
<COPY_GP_EVAL>"return " { <COPY_GP_EVAL>"return " {
...@@ -1308,7 +1331,7 @@ if(OPERATING_SYSTEM=WINDOWS) ...@@ -1308,7 +1331,7 @@ if(OPERATING_SYSTEM=WINDOWS)
bFunction=1; bInitFunction=1; bFunction=1; bInitFunction=1;
if( bLINE_NUM_EZ_FILE ) if( bLINE_NUM_EZ_FILE )
fprintf(fpOutputFile,"#line %d \"%s.ez\"\n",lineCounter, sRAW_PROJECT_NAME); fprintf(fpOutputFile,"#line %d \"%s.ez\"\n",lineCounter, sRAW_PROJECT_NAME);
BEGIN COPY; BEGIN COPY;
} }
<COPY_INITIALISATION_FUNCTION><<EOF>> {bInitFunction=0; // No before everything else function was found in the .ez file <COPY_INITIALISATION_FUNCTION><<EOF>> {bInitFunction=0; // No before everything else function was found in the .ez file
...@@ -1649,7 +1672,7 @@ if(OPERATING_SYSTEM=WINDOWS) ...@@ -1649,7 +1672,7 @@ if(OPERATING_SYSTEM=WINDOWS)
<GENOME_ANALYSIS>"GPNode" { <GENOME_ANALYSIS>"GPNode" {
yylval.pSymbol = new CSymbol("GPNode"); yylval.pSymbol = new CSymbol("GPNode");
//yylval.pSymbol->ObjectType = oPointer; //yylval.pSymbol->ObjectType = oPointer;
printf("match gpnode\n"); // printf("match gpnode\n");
return GPNODE; return GPNODE;
} }
...@@ -2120,7 +2143,7 @@ if(OPERATING_SYSTEM=WINDOWS) ...@@ -2120,7 +2143,7 @@ if(OPERATING_SYSTEM=WINDOWS)
<GET_PARAMETERS>"Evaluator"[ \t\n]+"goal"[ \t\n]*":"[ \t\n]* {if (bVERBOSE) printf ("\tMinMax...\n");return MINIMAXI;} <GET_PARAMETERS>"Evaluator"[ \t\n]+"goal"[ \t\n]*":"[ \t\n]* {if (bVERBOSE) printf ("\tMinMax...\n");return MINIMAXI;}
<GET_PARAMETERS>"Number"[ \t\n]+"of"[ \t\n]+"optimisation"[ \t\n]+"iterations"[ \t\n]*":"[ \t\n]* {if (bVERBOSE) printf ("\tNb of Optimisation It...\n");return NB_OPT_IT;} <GET_PARAMETERS>"Number"[ \t\n]+"of"[ \t\n]+"optimisation"[ \t\n]+"iterations"[ \t\n]*":"[ \t\n]* {if (bVERBOSE) printf ("\tNb of Optimisation It...\n");return NB_OPT_IT;}
<GET_PARAMETERS>"Baldwinism"[ \t\n]*":"[ \t\n]* {if (bVERBOSE) printf ("\tBaldwinism...\n");return BALDWINISM;} <GET_PARAMETERS>"Baldwinism"[ \t\n]*":"[ \t\n]* {if (bVERBOSE) printf ("\tBaldwinism...\n");return BALDWINISM;}
<GET_PARAMETERS>"Remote"[ \t\n]+"island"[ \t\n]+"model"[ \t\n]*":"[ \t\n]* {if(bVERBOSE) printf ("\tRemote Island Model...\n"); return REMOTE_ISLAND_MODEL;} <GET_PARAMETERS>"Remote"[ \t\n]+"island"[ \t\n]+"model"[ \t\n]*":"[ \t\n]* {if(bVERBOSE) printf ("\tRemote Island Model...\n"); return REMOTE_ISLAND_MODEL;}
<GET_PARAMETERS>"IP"[ \t\n]+"file"[ \t\n]*":"[ \t\n]* {if(bVERBOSE) printf("\tIP File...\n"); return IP_FILE;} <GET_PARAMETERS>"IP"[ \t\n]+"file"[ \t\n]*":"[ \t\n]* {if(bVERBOSE) printf("\tIP File...\n"); return IP_FILE;}
......
...@@ -123,7 +123,9 @@ public: ...@@ -123,7 +123,9 @@ public:
double divide(double dDividend, double dDivisor); double divide(double dDividend, double dDivisor);
CSymbol* insert() const; CSymbol* insert() const;
#line 127 "EaseaParse.h" virtual void yysyntaxerror();
#line 129 "EaseaParse.h"
}; };
#ifndef YYPARSENAME #ifndef YYPARSENAME
......
...@@ -5,7 +5,7 @@ Parser for the EASEA language (EAsy Specification for Evolutionary Algorithms) ...@@ -5,7 +5,7 @@ Parser for the EASEA language (EAsy Specification for Evolutionary Algorithms)
Pierre COLLET (Pierre.Collet@polytechnique.fr) Pierre COLLET (Pierre.Collet@polytechnique.fr)
Ecole Polytechnique Ecole Polytechnique
Centre de Mathmatiques Appliques Centre de Math�matiques Appliqu�es
91128 Palaiseau cedex 91128 Palaiseau cedex
****************************************************************************/ ****************************************************************************/
...@@ -160,7 +160,7 @@ class CSymbol; ...@@ -160,7 +160,7 @@ class CSymbol;
} }
// parser name and class definition // parser name and class definition
%name CEASEAParser %name CEASEAParser
{ {
protected: protected:
CEASEALexer EASEALexer; // the lexical analyser CEASEALexer EASEALexer; // the lexical analyser
...@@ -173,6 +173,8 @@ public: ...@@ -173,6 +173,8 @@ public:
double assign(CSymbol* pIdentifier, double dValue); double assign(CSymbol* pIdentifier, double dValue);
double divide(double dDividend, double dDivisor); double divide(double dDividend, double dDivisor);
CSymbol* insert() const; CSymbol* insert() const;
virtual void yysyntaxerror();
} }
// constructor // constructor
...@@ -317,8 +319,8 @@ Objects ...@@ -317,8 +319,8 @@ Objects
| Objects ',' Object | Objects ',' Object
; ;
// Attention : il reste grer correctement les tableaux de pointeurs // Attention : il reste � g�rer correctement les tableaux de pointeurs
// les indirections multiples et les tableaux plusieurs dimensions. // les indirections multiples et les tableaux � plusieurs dimensions.
// Je sais, il faudrait aussi utiliser un peu de polymorphisme pour les symboles // Je sais, il faudrait aussi utiliser un peu de polymorphisme pour les symboles
Object Object
...@@ -835,3 +837,10 @@ double CEASEAParser::divide(double a, double b) ...@@ -835,3 +837,10 @@ double CEASEAParser::divide(double a, double b)
return a / b; return a / b;
} }
} }
void CEASEAParser::yysyntaxerror(){
printf("Syntax Error at line : %d\n",EASEALexer.yylineno);
}
...@@ -11,7 +11,7 @@ $(EXEC):EaseaSym.o EaseaParse.o EaseaLex.o alexyacc/libalex.a EaseaYTools.o boos ...@@ -11,7 +11,7 @@ $(EXEC):EaseaSym.o EaseaParse.o EaseaLex.o alexyacc/libalex.a EaseaYTools.o boos
#else #else
#$(EXEC):EaseaSym.o EaseaParse.o EaseaLex.o alexyacc/libalex.a EaseaYTools.o libeasea/libeasea.a #$(EXEC):EaseaSym.o EaseaParse.o EaseaLex.o alexyacc/libalex.a EaseaYTools.o libeasea/libeasea.a
#endif #endif
$(CPPC) $(CPPFLAGS) $(LDFLAGS) $^ -o $@ $(CPPC) $(CPPFLAGS) $(LDFLAGS) $^ -o $@
# #
# Congratulations ! It looks like you compiled EASEA successfully. # Congratulations ! It looks like you compiled EASEA successfully.
# #
...@@ -81,7 +81,7 @@ endif ...@@ -81,7 +81,7 @@ endif
EaseaParse.o: EaseaParse.cpp EaseaLex.cpp EaseaParse.o: EaseaParse.cpp EaseaLex.cpp
$(CPPC) $(CPPFLAGS) $< -o $@ -c $(CPPC) $(CPPFLAGS) $< -o $@ -c 2>/dev/null
%.o:%.cpp %.o:%.cpp
$(CPPC) $(CPPFLAGS) -c -o $@ $< $(CPPC) $(CPPFLAGS) -c -o $@ $<
......
...@@ -8,6 +8,110 @@ __________________________________________________________*/ ...@@ -8,6 +8,110 @@ __________________________________________________________*/
\User functions: \User functions:
float evaluation_fonction(int k, IndividualImpl* Genome,struct base** k_tables,unsigned* packets_size){
struct base* k_tmp_tables[k];
unsigned error = 0;
unsigned tree_size = 0;
// generate tmp tables from genome, for every packets
float fitness_value = 0;
for( unsigned i=0 ; i<k ; i++ ){
k_tmp_tables[i] = table_from_genome(Genome->x,k_tables[i],t2,GENOME_SIZE,GENE_SIZE);
}
// cross validation
for( unsigned i=0 ; i<k ; i++ ){
struct base* tmp_learning_table= (struct base*)malloc(sizeof(*tmp_learning_table));
struct base* tmp_test_table = (struct base*)malloc(sizeof(*tmp_test_table));
tmp_learning_table->instances =
(float**)malloc(sizeof(*tmp_learning_table->instances)*t1->no_instances-k_tables[i]->no_instances);
tmp_learning_table->hdr = ba_partial_copy_hdr(k_tmp_tables[i]->hdr);
tmp_test_table->hdr = ba_partial_copy_hdr(k_tmp_tables[i]->hdr);
// create a learning set with k-1 packets
unsigned copied_instances = 0;
for( unsigned j=0 ; j<k ; j++ ){
if(j==i)continue;
memcpy( (tmp_learning_table->instances)+copied_instances,
k_tmp_tables[j]->instances,
sizeof(*tmp_learning_table->instances)*(k_tmp_tables[j]->no_instances));
copied_instances += k_tmp_tables[j]->no_instances;
}
tmp_learning_table->no_instances = copied_instances;
// create the test set with 1 packet
tmp_test_table->instances = (float**)malloc(sizeof(*tmp_test_table->instances)*k_tmp_tables[i]->no_instances);
memcpy(tmp_test_table->instances,k_tmp_tables[i]->instances,
sizeof(*tmp_test_table->instances)*k_tmp_tables[i]->no_instances);
tmp_test_table->no_instances = k_tmp_tables[i]->no_instances;
// set threshold, from t1 for standard attribute
for( unsigned j=0 ; j<t1->hdr->no_attributes ; j++ ){
tmp_test_table->hdr->attributes[j]->threshold = t1->hdr->attributes[j]->threshold;
tmp_test_table->hdr->attributes[j]->no_threshold = t1->hdr->attributes[j]->no_threshold;
}
// compute threshold for attribute generated by genome
ba_compute_threshold_from(tmp_test_table,t1->hdr->no_attributes);
// set threshold, from t1 for standard attribute
for( unsigned j=0 ; j<t1->hdr->no_attributes ; j++ ){
tmp_learning_table->hdr->attributes[j]->threshold = t1->hdr->attributes[j]->threshold;
tmp_learning_table->hdr->attributes[j]->no_threshold = t1->hdr->attributes[j]->no_threshold;
}
// compute threshold for attribute generated by genome
ba_compute_threshold_from(tmp_learning_table,t1->hdr->no_attributes);
cTreeNode* t = genereate_decision_tree(tmp_learning_table);
//show_tree(k_tmp_tables[0],t,0);
//DBG_print_instances(tmp_test_table->instances,tmp_test_table->no_instances,tmp_test_table->hdr->no_attributes);
for( unsigned j=0 ; j<tmp_test_table->no_instances ; j++ ){
unsigned predicted_class = t->classify_instance(tmp_test_table->instances[j]);
unsigned real_class = (unsigned)tmp_test_table->instances[j][t1->hdr->whichis_class];
//printf("%3.0f : %d, %d\n",tmp_test_table->instances[j][1],predicted_class,real_class);
// here compute classification error, or any quality measurment
if( predicted_class!=real_class ){
error++;
}
}
//printf("err : %f %d\n",fitness_value,t->tree_depth());
tree_size += t->tree_depth();
delete t;
// free current sets
// first un-assignate instances
for( unsigned i=0 ; i<tmp_learning_table->no_instances ; i++ ){tmp_learning_table->instances[i] = NULL;}
for( unsigned i=0 ; i<tmp_test_table->no_instances ; i++ ){tmp_test_table->instances[i] = NULL;}
tmp_learning_table->no_instances = 0;
tmp_test_table->no_instances = 0;
// then delete tmp tables
ba_partial_copy_delete(tmp_learning_table);
ba_partial_copy_delete(tmp_test_table);
printf("f at this packet %d\n",error);
}
fitness_value = (((float)error) / t1->no_instances)*100;// + (((float)tree_size)/k)
for( unsigned i=0 ; i<k ; i++ ){
ba_delete(k_tmp_tables[i]);
}
return fitness_value;
}
\end \end
\At the beginning of each generation function: \At the beginning of each generation function:
...@@ -47,6 +151,7 @@ struct base* t1 = NULL; ...@@ -47,6 +151,7 @@ struct base* t1 = NULL;
struct base* t2 = NULL; struct base* t2 = NULL;
float* uniq_instances[2]; float* uniq_instances[2];
float* mutation_step;
unsigned uniq_cnt[2]; unsigned uniq_cnt[2];
struct base* k_tables[K]; struct base* k_tables[K];
...@@ -69,12 +174,11 @@ GenomeClass { ...@@ -69,12 +174,11 @@ GenomeClass {
cout << "Seed : " << globalRandomGenerator->get_seed() << endl; cout << "Seed : " << globalRandomGenerator->get_seed() << endl;
srand(globalRandomGenerator->get_seed()); srand(globalRandomGenerator->get_seed());
t1 = ba_postgres_load_ilot(1); t1 = ba_postgres_load_ilot(4);
t2 = ba_postgres_load_batiment(1); t2 = ba_postgres_load_batiment(4);
ba_sort_instances(t1,0,0); ba_sort_instances(t1,0,0);
ba_set_links(t1,t2); ba_set_links(t1,t2);
//ba_print_links(t1);
//printf("+ %d - %d\n",t1->class_repartition[1],t1->class_repartition[0]);
for( unsigned i=0 ; i<t1->hdr->attributes[t1->hdr->whichis_class]->no_values; i++ ) for( unsigned i=0 ; i<t1->hdr->attributes[t1->hdr->whichis_class]->no_values; i++ )
printf("%s : %d\n",t1->hdr->attributes[t1->hdr->whichis_class]->values[i],t1->class_repartition[i]); printf("%s : %d\n",t1->hdr->attributes[t1->hdr->whichis_class]->values[i],t1->class_repartition[i]);
...@@ -107,6 +211,34 @@ GenomeClass { ...@@ -107,6 +211,34 @@ GenomeClass {
#endif #endif
//exit(-1); //exit(-1);
// here we can compute the extremum of the annex table
float* mins = new float[t2->hdr->no_attributes-2];
float* maxs = new float[t2->hdr->no_attributes-2];
unsigned no_usefull_attributs = t2->hdr->no_attributes-2;
mutation_step = new float[no_usefull_attributs];
for( unsigned i=1 ; i<t2->hdr->no_attributes-1 ; i++ ){
mins[i-1] = INFINITY;
maxs[i-1] = -INFINITY;
for( unsigned j=0 ; j<t2->no_instances ; j++ ){
if( t2->instances[j][i] < mins[i-1] )
mins[i-1] = t2->instances[j][i];
if( t2->instances[j][i] > maxs[i-1] )
maxs[i-1] = t2->instances[j][i];
}
}
for( unsigned i=0 ; i< no_usefull_attributs ; i++ ){
mutation_step[i] = (maxs[i]-mins[i])/50;
printf("%d : M : %f m : %f ms %f\n",i,maxs[i],mins[i],mutation_step[i]);
}
delete mins;
delete maxs;
} }
\end \end
...@@ -146,6 +278,16 @@ GenomeClass { ...@@ -146,6 +278,16 @@ GenomeClass {
printf(" error on the whole set : %d\n",error); printf(" error on the whole set : %d\n",error);
#endif #endif
struct base* k_tables_f[10];
unsigned packets_size_f[10];
generate_k_fold(10,packets_size_f,t1,k_tables_f,t2);
//evaluation_fonction(10,
printf("validation on 10 folds %f\n",evaluation_fonction(10, best,k_tables_f,packets_size_f));
delete root; delete root;
ba_delete( tmp_table ); ba_delete( tmp_table );
} }
...@@ -213,24 +355,10 @@ GenomeClass { ...@@ -213,24 +355,10 @@ GenomeClass {
else{ else{
float value; float value;
if( __isinf(Genome.x[i+j]) ) Genome.x[i+j] = random(0,1000); if( __isinf(Genome.x[i+j]) ) Genome.x[i+j] = random(0,1000);
switch(j){ value = random_gauss(Genome.x[i+j],mutation_step[i]);
case 0: Genome.x[i+j] = roundf(value);
value = random_gauss(Genome.x[i+j],100); Genome.x[i+j] = ba_nearest_table_value(t2,j+1,value);
Genome.x[i+j] = roundf(value);
Genome.x[i+j] = ba_nearest_table_value(t2,j+1,value);
break;
case 1:
value = random_gauss(Genome.x[i+j],20);
Genome.x[i+j] = roundf(value);
Genome.x[i+j] = ba_nearest_table_value(t2,j+1,value);
break;
case 2:
value = random_gauss(Genome.x[i+j],10);
Genome.x[i+j] = roundf(value);
Genome.x[i+j] = ba_nearest_table_value(t2,j+1,value);
break;
}
//}
NbMut++; NbMut++;
} }
} }
...@@ -359,14 +487,15 @@ GenomeClass { ...@@ -359,14 +487,15 @@ GenomeClass {
\end \end
\User Makefile options: \User Makefile options:
LIBANTLR_DIR = ~/lib/libantlr3c-3.3-SNAPSHOT/
CXXFLAGS+=-I/home/maitre/sources/c4.5/include/ -fopenmp CXXFLAGS+=-I/home/maitre/sources/c4.5/include/ -fopenmp
LDFLAGS+= -lpq -lm -fopenmp ../c4.5_common/libc45.a LDFLAGS+= -lpq -lm -fopenmp ../c4.5_common/libc45.a $(LIBANTLR_DIR)/.libs/libantlr3c.a
\end \end
\Default run parameters : // Please let the parameters appear in this order \Default run parameters : // Please let the parameters appear in this order
Number of generations : 200 // NB_GEN Number of generations : 200 // NB_GEN
Time limit: 0 // In seconds, 0 to deactivate Time limit: 0 // In seconds, 0 to deactivate
Population size : 100 //POP_SIZE Population size : 200 //POP_SIZE
Offspring size : 100 // 40% Offspring size : 100 // 40%
Mutation probability : 1 // MUT_PROB Mutation probability : 1 // MUT_PROB
Crossover probability : 1 // XOVER_PROB Crossover probability : 1 // XOVER_PROB
......
...@@ -88,9 +88,9 @@ GenomeClass { ...@@ -88,9 +88,9 @@ GenomeClass {
#if 1 #if 1
// try the perfect solution // try the perfect solution
IndividualImpl* i = new IndividualImpl(); IndividualImpl* i = new IndividualImpl();
i->x[0] = 30; i->x[0] = 60;
i->x[1] = 39; i->x[1] = 60;
i->x[GENE_SIZE-1] = 0; i->x[GENE_SIZE-1] = 3;
for( unsigned j=3 ; j<GENE_SIZE-1 ; j++ ) for( unsigned j=3 ; j<GENE_SIZE-1 ; j++ )
i->x[j] = INFINITY; i->x[j] = INFINITY;
...@@ -142,7 +142,7 @@ GenomeClass { ...@@ -142,7 +142,7 @@ GenomeClass {
printf(" error on the whole set : %d\n",error); printf(" error on the whole set : %d\n",error);
#endif #endif
ba_to_arff(tmp_table,"output_table.arff");
delete root; delete root;
ba_delete( tmp_table ); ba_delete( tmp_table );
} }
...@@ -152,7 +152,7 @@ GenomeClass { ...@@ -152,7 +152,7 @@ GenomeClass {
{ {
for( unsigned i=0; i<GENOME_SIZE ; i+=GENE_SIZE ) { for( unsigned i=0; i<GENOME_SIZE ; i+=GENE_SIZE ) {
for( unsigned j=0 ; j<GENE_SIZE-1 ; j++ ){ for( unsigned j=0 ; j<GENE_SIZE-1 ; j++ ){
Genome.x[i+j] = random(0,100); Genome.x[i+j] = t2->instances[random(0,t2->no_instances)][j+1]; //random(0,100);
} }
Genome.x[i+GENE_SIZE-1] = random(0,5); Genome.x[i+GENE_SIZE-1] = random(0,5);
} }
...@@ -162,7 +162,7 @@ GenomeClass { ...@@ -162,7 +162,7 @@ GenomeClass {
\GenomeClass::crossover : \GenomeClass::crossover :
{ {
#if 0 #if 1
for (int i=0; i<GENOME_SIZE; i+=GENE_SIZE){ for (int i=0; i<GENOME_SIZE; i+=GENE_SIZE){
if( tossCoin(0.5) ) if( tossCoin(0.5) )
for( unsigned j=0 ; j<GENE_SIZE ; j++ ) for( unsigned j=0 ; j<GENE_SIZE ; j++ )
...@@ -339,8 +339,9 @@ GenomeClass { ...@@ -339,8 +339,9 @@ GenomeClass {
\end \end
\User Makefile options: \User Makefile options:
LIBANTLR_DIR = ~/lib/libantlr3c-3.3-SNAPSHOT/
CXXFLAGS+=-I/home/maitre/sources/c4.5/include/ -fopenmp CXXFLAGS+=-I/home/maitre/sources/c4.5/include/ -fopenmp
LDFLAGS+= -lpq -lm -fopenmp ../c4.5_common/libc45.a LDFLAGS+= -lpq -lm -fopenmp ../c4.5_common/libc45.a $(LIBANTLR_DIR)/.libs/libantlr3c.a
\end \end
\Default run parameters : // Please let the parameters appear in this order \Default run parameters : // Please let the parameters appear in this order
......
for(( i=0 ; i<1 ; i++ )) for(( i=0 ; i<20 ; i++ ))
do do
suf=`date +%s` suf=`date +%s`
echo $suf echo $suf
......
\TEMPLATE_START \TEMPLATE_START
#ifdef WIN32 #ifdef WIN32
#define _CRT_SECURE_NO_WARNINGS #define _CRT_SECURE_NO_WARNINGS
#pragma comment(lib, "libEasea.lib") #pragma comment(lib, "libEasea.lib")
#endif #endif
/** /**
This is program entry for TreeGP template for EASEA This is program entry for TreeGP template for EASEA
...@@ -84,7 +84,10 @@ int main(int argc, char** argv){ ...@@ -84,7 +84,10 @@ int main(int argc, char** argv){
#include "CIndividual.h" #include "CIndividual.h"
#include "CCuda.h" #include "CCuda.h"
#include "CGPNode.h" #include "CGPNode.h"
#include <iostream>
#include <sstream>
unsigned aborded_crossover;
float* input_k; float* input_k;
float* output_k; float* output_k;
int* indexes_k; int* indexes_k;
...@@ -95,7 +98,7 @@ int* hits_k; ...@@ -95,7 +98,7 @@ int* hits_k;
using namespace std; using namespace std;
#include "EASEAIndividual.hpp" #include "EASEAIndividual.hpp"
bool INSTEAD_EVAL_STEP = false; bool INSTEAD_EVAL_STEP = true;
int fitnessCasesSetLength; int fitnessCasesSetLength;