-
Notifications
You must be signed in to change notification settings - Fork 0
/
trait.h
65 lines (48 loc) · 1.94 KB
/
trait.h
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#ifndef _TRAIT_H_
#define _TRAIT_H_
#include <fstream>
#include "neat.h"
#include <vector>
#include "boost/serialization/nvp.hpp"
#include <boost/serialization/binary_object.hpp>
namespace NEAT {
using namespace std;
// ------------------------------------------------------------------
// TRAIT: A Trait is a group of parameters that can be expressed
// as a group more than one time. Traits save a genetic
// algorithm from having to search vast parameter landscapes
// on every node. Instead, each node can simply point to a trait
// and those traits can evolve on their own
class Trait {
// ************ LEARNING PARAMETERS ***********
// The following parameters are for use in
// neurons that learn through habituation,
// sensitization, or Hebbian-type processes
public:
int trait_id; // Used in file saving and loading
std::vector<double> params;//[NEAT::num_trait_params]; // Keep traits in an array
Trait ();
Trait(int id,double p1,double p2,double p3,double p4,double p5,double p6,double p7,double p8,double p9);
// Copy Constructor
Trait(const Trait& t);
// Create a trait exactly like another trait
Trait(Trait *t);
// Special constructor off a file assume word "trait" has been read in
Trait(const char *argline);
// Special Constructor creates a new Trait which is the average of 2 existing traits passed in
Trait(Trait *t1,Trait *t2);
// Dump trait to a stream
void print_to_file(std::ostream &outFile);
void print_to_file(std::ofstream &outFile);
// Perturb the trait parameters slightly
void mutate();
template<class Archive>
void serialize(Archive & ar, const unsigned int version)
{
//ar & BOOST_SERIALIZATION_NVP(trait_id);
//ar & boost::serialization::make_binary_object(params, 8);
ar & BOOST_SERIALIZATION_NVP(params);
}
};
} // namespace NEAT
#endif