adding new parameters

This commit is contained in:
gustavoromero 2000-11-24 09:51:31 +00:00
commit 5ac5a72db2
2 changed files with 13 additions and 2 deletions

View file

@ -18,7 +18,7 @@
// global variables // global variables
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
unsigned in, out, hidden;
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// parameters // parameters
@ -29,6 +29,7 @@ eoValueParam<unsigned> generations(10, "generations", "default generation number
eoValueParam<double> mut_rate(0.1, "mut_rate", "default mutation rate", 'm'); eoValueParam<double> mut_rate(0.1, "mut_rate", "default mutation rate", 'm');
eoValueParam<double> xover_rate(0.1, "xover_rate", "default crossover rate", 'x'); eoValueParam<double> xover_rate(0.1, "xover_rate", "default crossover rate", 'x');
eoValueParam<string> file("", "file", "common part of patterns filenames *.trn *.val and *.tst", 'f'); eoValueParam<string> file("", "file", "common part of patterns filenames *.trn *.val and *.tst", 'f');
eoValueParam<unsigned> hiddenp(8, "hidden", "default number of neurons in hidden layer", 'h');
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// auxiliar functions // auxiliar functions
@ -71,6 +72,7 @@ void arg(int argc, char** argv)
parser.processParam(mut_rate, "genetic operators"); parser.processParam(mut_rate, "genetic operators");
parser.processParam(xover_rate, "genetic operators"); parser.processParam(xover_rate, "genetic operators");
parser.processParam(file, "files"); parser.processParam(file, "files");
parser.processParam(hiddenp, "genetic operators");
if (parser.userNeedsHelp()) if (parser.userNeedsHelp())
{ {
@ -85,6 +87,10 @@ void arg(int argc, char** argv)
phenotype::trn_max = trn_set.size(); phenotype::trn_max = trn_set.size();
phenotype::val_max = val_set.size(); phenotype::val_max = val_set.size();
phenotype::tst_max = tst_set.size(); phenotype::tst_max = tst_set.size();
in = trn_set.front().input.size();
out = trn_set.front().output.size();
hidden = hiddenp.value();
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------

View file

@ -64,10 +64,15 @@ typedef mlp::net genotype;
// Chrom // Chrom
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
extern unsigned in, out, hidden;
class Chrom: public EO<phenotype>, public genotype class Chrom: public EO<phenotype>, public genotype
{ {
public: public:
Chrom(): genotype(25, 2) {} Chrom(): genotype(in, out, vector<unsigned>(1, hidden))
{
cout << "in = " << in << " out = " << out << " hidden = " << hidden << endl;
}
string className() const { return "Chrom"; } string className() const { return "Chrom"; }