Fixed some signed/unsigned conversion bugs
This commit is contained in:
parent
68e970e455
commit
250d31f904
2 changed files with 12 additions and 9 deletions
|
|
@ -45,10 +45,10 @@
|
||||||
|
|
||||||
struct phenotype
|
struct phenotype
|
||||||
{
|
{
|
||||||
unsigned trn_ok, val_ok, tst_ok;
|
int trn_ok, val_ok, tst_ok;
|
||||||
double mse_error;
|
double mse_error;
|
||||||
|
|
||||||
static unsigned trn_max, val_max, tst_max;
|
static int trn_max, val_max, tst_max;
|
||||||
|
|
||||||
friend bool operator<(const phenotype& a, const phenotype& b)
|
friend bool operator<(const phenotype& a, const phenotype& b)
|
||||||
{
|
{
|
||||||
|
|
@ -87,13 +87,16 @@ struct phenotype
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
unsigned phenotype::trn_max = 0, phenotype::val_max = 0, phenotype::tst_max = 0;
|
int phenotype::trn_max = 0, phenotype::val_max = 0, phenotype::tst_max = 0;
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// genotype
|
// genotype
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
#ifndef GPROP_GENOTYPE
|
||||||
|
#define GPROP_GENOTYPE mlp::net
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef mlp::net genotype;
|
typedef GPROP_GENOTYPE genotype;
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Chrom
|
// Chrom
|
||||||
|
|
@ -195,13 +198,13 @@ public:
|
||||||
// eoChromEvaluator
|
// eoChromEvaluator
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
unsigned correct(const mlp::net& net, const mlp::set& set)
|
int correct(const mlp::net& net, const mlp::set& set)
|
||||||
{
|
{
|
||||||
unsigned sum = 0;
|
int sum = 0;
|
||||||
|
|
||||||
for (mlp::set::const_iterator s = set.begin(); s != set.end(); ++s)
|
for (mlp::set::const_iterator s = set.begin(); s != set.end(); ++s)
|
||||||
{
|
{
|
||||||
unsigned partial = 0;
|
int partial = 0;
|
||||||
|
|
||||||
for (unsigned i = 0; i < s->output.size(); ++i)
|
for (unsigned i = 0; i < s->output.size(); ++i)
|
||||||
if (s->output[i] < 0.5 && net(s->input)[i] < 0.5 ||
|
if (s->output[i] < 0.5 && net(s->input)[i] < 0.5 ||
|
||||||
|
|
|
||||||
|
|
@ -274,7 +274,7 @@ namespace mlp {
|
||||||
return (max_element(tmp.begin(), tmp.end()) - tmp.begin());
|
return (max_element(tmp.begin(), tmp.end()) - tmp.begin());
|
||||||
}
|
}
|
||||||
|
|
||||||
void save(ostream &os) {
|
void save(ostream &os) const {
|
||||||
// Save the number of inputs, number of outputs, and number of hidden layers
|
// Save the number of inputs, number of outputs, and number of hidden layers
|
||||||
os << num_inputs() << "\n" << num_outputs() << "\n" << num_hidden_layers() << "\n";
|
os << num_inputs() << "\n" << num_outputs() << "\n" << num_hidden_layers() << "\n";
|
||||||
for(const_iterator l = begin(); l != end(); ++l)
|
for(const_iterator l = begin(); l != end(); ++l)
|
||||||
|
|
@ -362,7 +362,7 @@ namespace mlp {
|
||||||
while (is >> samp) { push_back(samp); }
|
while (is >> samp) { push_back(samp); }
|
||||||
}
|
}
|
||||||
|
|
||||||
void save(ostream &os) {
|
void save(ostream &os) const {
|
||||||
os << front().input.size() << " " << front().output.size() << endl;
|
os << front().input.size() << " " << front().output.size() << endl;
|
||||||
copy(begin(), end(), ostream_iterator<sample>(os,"\n"));
|
copy(begin(), end(), ostream_iterator<sample>(os,"\n"));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue