summaryrefslogtreecommitdiff
path: root/src/tests/io.cpp
blob: 871a8133c81926737a351361f72f3fb21e99affb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include "genetic/phenotypebinary.h"
#include "genetic/operatorbasic.h"

#include <bu/sio.h>
#include <bu/membuf.h>
#include <bu/random.h>
#include <bu/randomcmwc.h>
#include <bu/randomsystem.h>
#include <time.h>

using namespace Bu;

int main( int argc, char *argv[] )
{
	Bu::Random::setGenerator<Bu::RandomCmwc>();
	Bu::Random::seed( time( NULL ) );

	Genetic::OperatorBasic op( new Genetic::PhenotypeBinary( 45 ), 0.000125 );
	Genetic::Phenotype *pPb1 = op.random();

	Bu::MemBuf mb;
	pPb1->write( mb );
	sio << "Size: " << mb.getSize() << sio.nl;
	mb.setPos( 0 );

	Genetic::PhenotypeBinary b( 1 );
	b.read( mb );

	sio << pPb1->toString() << sio.nl;
	sio << b.toString() << sio.nl;

	delete pPb1;

	return 0;
}