14 namespace utf = boost::unit_test;
22 static int getHighest(
double *o,
int n){
25 for(
int i=0;i<n;i++,o++){
51 void setExample(
int i,
double h,
double in0,
double in1,
double out){
69 void add0(
double o00,
double o01,
double o10,
double o11){
70 setExample(0,0, 0,0, o00);
71 setExample(2,0, 0,1, o01);
72 setExample(4,0, 1,0, o10);
73 setExample(6,0, 1,1, o11);
74 setExample(8,0, 0,0, o00);
75 setExample(10,0, 0,1, o01);
76 setExample(12,0, 1,0, o10);
77 setExample(14,0, 1,1, o11);
86 void add1(
double o00,
double o01,
double o10,
double o11){
87 setExample(1,1, 0,0, o00);
88 setExample(3,1, 0,1, o01);
89 setExample(5,1, 1,0, o10);
90 setExample(7,1, 1,1, o11);
91 setExample(9,1, 0,0, o00);
92 setExample(11,1, 0,1, o01);
93 setExample(13,1, 1,0, o10);
94 setExample(15,1, 1,1, o11);
102 static double booleanTest(
Net *net,
double h,
int a,
int b,
double v){
107 double out = *net->
run(in);
108 BOOST_TEST_MESSAGE(
" At " << h <<
", " << a <<
" " << b <<
109 " gives " << out <<
", should be " << v);
110 return (v-out)*(v-out);
void setH(int example, double h)
Set the h (modulator) for a given example.
boolean example set: 16 examples, 2 inputs, 1 output, 2 mod levels. There are 4 examples for each fun...
virtual void setH(double h)=0
Set the modulator level for subsequent runs and training of this network.
double * getOutputs(int example)
Get a pointer to the outputs for a given example, for reading or writing.
void add1(double o00, double o01, double o10, double o11)
set the 4 examples at modulator=1
void add0(double o00, double o01, double o10, double o11)
set the 4 examples at modulator=0
double * run(double *in)
Run the network on some data.
I'm not a fan of factories, but here's one - this makes a network of the appropriate type which confo...
The abstract network type upon which all others are based. It's not pure virtual, in that it encapsul...
double ins[][2]
possible inputs to boolean functions
double * getInputs(int example)
Get a pointer to the inputs for a given example, for reading or writing.
A set of example data. Each datum consists of hormone (i.e. modulator value), inputs and outputs...