Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
easea
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Operations
Operations
Incidents
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Arnaud Kress
easea
Commits
3991236c
Commit
3991236c
authored
Oct 23, 2012
by
Cancino Waldo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add GP+Network+CUDA example (Alberto Tonda)
parent
8f44bf4a
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
206 additions
and
0 deletions
+206
-0
examples/regression-network/ip.txt
examples/regression-network/ip.txt
+2
-0
examples/regression-network/regression.ez
examples/regression-network/regression.ez
+200
-0
examples/regression-network/run.sh
examples/regression-network/run.sh
+2
-0
examples/regression-network/run_cuda.sh
examples/regression-network/run_cuda.sh
+2
-0
No files found.
examples/regression-network/ip.txt
0 → 100644
View file @
3991236c
127.0.0.1:2929
127.0.0.1:2930
examples/regression-network/regression.ez
0 → 100755
View file @
3991236c
/*_________________________________________________________
This is a standard GP implementation on EASEA,
aimed for regression.
use : easea -cuda_gp regression.ez
make
in order to generate and compile this code.
__________________________________________________________*/
\User declarations :
// these 3 defines are mandatory here. Adjust as you like.
#define NO_FITNESS_CASES 1024
#define VAR_LEN 1
#define GROW_FULL_RATIO 0.5
// this is the number of learning cases computed in parallel.
// note that on 1024 is the maximum size on fermi architectures 512 on older cards.
#define NUMTHREAD 1024
#define MAX_STACK 15
#define PI (3.141592653589793)
\end
\User functions:
#define POLY(x) x*x*x-3*x*x+x
/**
This function generates data NO_FITNESS_CASES fitness cases,
from the polynome POLY(X) with X randomly picked between (-1,1)
@inputs address of the inputs array. (array will be allocated here)
@outputs adddress of the outputs array. (array will be allocated here)
@ret number of loaded fitness cases (should be equal to NO_FITNESS_CASES).
*/
int generateData(float*** inputs, float** outputs){
int i=0;
(*inputs) = new float*[NO_FITNESS_CASES];
(*outputs) = new float[NO_FITNESS_CASES];
for( i=0 ; i<NO_FITNESS_CASES ; i++ ){
(*inputs)[i]=new float[VAR_LEN];
float x = random(-10.,+10.);
(*inputs)[i][0] = x;
(*outputs)[i] = POLY(x);
}
return NO_FITNESS_CASES;
}
void free_data(){
for( int i=0 ; i<NO_FITNESS_CASES ;i++ ) delete[] inputs[i] ;
delete[] outputs;
delete[] inputs;
}
\end
\Before everything else function:
{
generateData(&inputs,&outputs);
}
\end
\After everything else function:
{
std::cout << toString(((IndividualImpl*)EA->population->Best)->root) << std::endl;
free_data();
}
\end
\At the beginning of each generation function:
{
//cout << "At the beginning of each generation function called" << endl;
}
\end
\At the end of each generation function:
{
//cout << "At the end of each generation function called" << endl;
}
\end
\At each generation before reduce function:
//cout << "At each generation before replacement function called" << endl;
\end
\User classes :
GenomeClass {
GPNode* root;
}
\end
\GenomeClass::display:
\end
\GenomeClass::initialiser :
{
Genome.root = ramped_hh();
}
\end
\GenomeClass::crossover :
{
simpleCrossOver(parent1,parent2,child);
child.valid = false;
}
\end
\GenomeClass::mutator : // Must return the number of mutations
{
simple_mutator(&Genome);
return 1;
}
\end
\begin operator description :
OP_X, "x", 0, {RESULT=INPUT[0];};
OP_ERC, "ERC", 0, {RESULT=ERC;};
OP_ADD, "+", 2, {RESULT=OP1+OP2;};
OP_SUB, "-", 2, {RESULT=OP1-OP2;};
OP_MUL, "*", 2, {RESULT=OP1*OP2;};
OP_DIV, "/", 2, {
if( !OP2 ) RESULT = 1;
else RESULT = OP1/OP2;
};
\end
\GenomeClass::evaluator header:
\end
\GenomeClass::evaluator for each fc :
float expected_value = OUTPUT;
ERROR = (expected_value-EVOLVED_VALUE)*(expected_value-EVOLVED_VALUE);
\end
\GenomeClass::evaluator accumulator :
return sqrtf(ERROR);
\end
\User Makefile options:
CXXFLAGS+=-I/usr/local/cuda/common/inc/ -I/usr/local/cuda/include/
LDFLAGS+=
\end
\Default run parameters : // Please let the parameters appear in this order
Number of generations : 50 // NB_GEN
Time limit: 0 // In seconds, 0 to deactivate
Population size : 5000 //POP_SIZE
Offspring size : 5000 // 40%
Mutation probability : 0.1 // MUT_PROB
Crossover probability : 0.9 // XOVER_PROB
Evaluator goal : minimise // Maximise
Selection operator: Tournament 7
Surviving parents: 100%//percentage or absolute
Surviving offspring: 100%
Reduce parents operator: Tournament 2
Reduce offspring operator: Tournament 2
Final reduce operator: Tournament 7
Elitism: Strong //Weak or Strong
Elite: 1
Print stats: true //Default: 1
Generate csv stats file:false
Generate gnuplot script:false
Generate R script:false
Plot stats:false //Default: 0
Remote island model: true
IP file: ip.txt //File containing all the remote island's IP
Server port : 2929
Migration probability: 1
Save population: false
Start from file:false
max init tree depth : 4
min init tree depth : 2
max tree depth : 8
size of prog buffer : 200000000
\end
examples/regression-network/run.sh
0 → 100755
View file @
3991236c
rm
Makefile
*
cpp
*
hpp
*
o
*
prm
*
dat
*
mak
*
cu
easea
-v
-gp
regression.ez
examples/regression-network/run_cuda.sh
0 → 100755
View file @
3991236c
rm
Makefile
*
cpp
*
hpp
*
o
*
prm
*
dat
*
mak
*
cu
easea
-v
-cuda_gp
regression.ez
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment