Genetic Prorgaming
-
this is a try at GP in C++ whit strings GP what : from array or grafic to formula GP how : 1 : write random formula's 2 : sort formula's on error 3 : best fumula's mix to kid's 4 : some kid's are mutated 5 : if genration < max and error > whised goto 2 version 0.1.1 building function run get "list" outof formula
bluatigro 9 okt 2017
// genetic programing whit strings
// version 0.1#include #include #include #include #include using namespace std ;
typedef VSTR vector ;
VSTR split( string in , char cut = ' ' )
{
VSTR uit ;
size_type i = 0 ;
size_type j = in.find( cut ) ;
while ( j != string::npos )
{
uit.push_back( in.substr( i , j - i ) ) ;
i = ++j ;
j = in.find( cut , j ) ;
if ( j == string::npos )
in.push_back( in.substr( i , in.lenght() ) ) ;
}
return uit ;
}string dbl2str( double x )
{
stringsream ss ;
ss << x ;
return ss.str() ;
}double str2dbl( string x )
{
// how ?
}class GeneProg
{
private :
int numberMode ;
VSTR genes ;
double in[ 10 ] ;
int inmax ;
public :
GeneProg()
{
numberMode = 0 ;
inmax = 0 ;
}
string run( string prog )
{
int einde = prog.find( ']' ) ;
int begin = einde ;
while ( prog[ begin ] != '[' ) ;
begin-- ;
return prog.substr( begin , einde - begin ) ;
}
} ;int main()
{
GeneProg GP ;
string a = "[ + 7 [ - 2 3 ] ]" ;
string b = "[ * 9 [ / 8 6 ] ]" ;
cout << "[ test run ]" << endl ;
cout << "prog a = " << a << endl ;
//gp.run shoot give "[ - 2 3 ]"
cout << "run a = " << GP.run( a ) << endl ;
cout << "check a = " << 7 + ( 2 - 3 ) << endl ;
cout << "prog b = " << b << endl ;
//gp.run shoot give "[ / 8 6 ]"
cout << "run b = " << GP.run( b ) << endl ;
cout << "check b = " << 9 * ( 8 / 6 ) << endl ;
cout << "[ game over ]" << endl ;
cin.get() ;
} -
this is a try at GP in C++ whit strings GP what : from array or grafic to formula GP how : 1 : write random formula's 2 : sort formula's on error 3 : best fumula's mix to kid's 4 : some kid's are mutated 5 : if genration < max and error > whised goto 2 version 0.1.1 building function run get "list" outof formula
bluatigro 9 okt 2017
// genetic programing whit strings
// version 0.1#include #include #include #include #include using namespace std ;
typedef VSTR vector ;
VSTR split( string in , char cut = ' ' )
{
VSTR uit ;
size_type i = 0 ;
size_type j = in.find( cut ) ;
while ( j != string::npos )
{
uit.push_back( in.substr( i , j - i ) ) ;
i = ++j ;
j = in.find( cut , j ) ;
if ( j == string::npos )
in.push_back( in.substr( i , in.lenght() ) ) ;
}
return uit ;
}string dbl2str( double x )
{
stringsream ss ;
ss << x ;
return ss.str() ;
}double str2dbl( string x )
{
// how ?
}class GeneProg
{
private :
int numberMode ;
VSTR genes ;
double in[ 10 ] ;
int inmax ;
public :
GeneProg()
{
numberMode = 0 ;
inmax = 0 ;
}
string run( string prog )
{
int einde = prog.find( ']' ) ;
int begin = einde ;
while ( prog[ begin ] != '[' ) ;
begin-- ;
return prog.substr( begin , einde - begin ) ;
}
} ;int main()
{
GeneProg GP ;
string a = "[ + 7 [ - 2 3 ] ]" ;
string b = "[ * 9 [ / 8 6 ] ]" ;
cout << "[ test run ]" << endl ;
cout << "prog a = " << a << endl ;
//gp.run shoot give "[ - 2 3 ]"
cout << "run a = " << GP.run( a ) << endl ;
cout << "check a = " << 7 + ( 2 - 3 ) << endl ;
cout << "prog b = " << b << endl ;
//gp.run shoot give "[ / 8 6 ]"
cout << "run b = " << GP.run( b ) << endl ;
cout << "check b = " << 9 * ( 8 / 6 ) << endl ;
cout << "[ game over ]" << endl ;
cin.get() ;
}See here for the answers to all of your questions. Yes, I know you did not actually ask any questions, but if you did, the link would still be considered valuable.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles