Beispiel #1
0
	double operator()(Individual& ind, RNG& rng, EA& ea) {
        // get the phenotype (markov network):
        typename EA::phenotype_type &N = ealib::phenotype(ind, ea);

        // probably want to reset the RNG for the markov network:
        N.reset(rng.seed());

        // now, set the values of the bits in the input vector:
        double f=0.0;
        for(std::size_t i=0; i<128; ++i) {
            // allocate space for the inputs:
            std::vector<int> inputs;//(net.ninput_states(), 0);
            inputs.push_back(rng.bit());
            inputs.push_back(rng.bit());
            
            // update the network n times:
            N.clear();
            N.update(inputs);
            
            if(*N.begin_output() == (inputs[0] ^ inputs[1])) {
                ++f;
            }
        }

        // and return some measure of fitness:
        return f;
    }