X-Git-Url: https://git.dlugolecki.net.pl/?a=blobdiff_plain;f=src%2Ffitness%2Fwsti.h;fp=src%2Ffitness%2Fwsti.h;h=3743a9ca00077143a90fb126aba02e718d3a2c46;hb=af69896de7f61e773e62dfdcfa75f7788dd0dd37;hp=d99dd18b8e6d58673a5f750d6e7ca8634fe7d55b;hpb=b81d71a34fc7b18764f2ab75e6e29949a811a532;p=genetic.git diff --git a/src/fitness/wsti.h b/src/fitness/wsti.h index d99dd18..3743a9c 100644 --- a/src/fitness/wsti.h +++ b/src/fitness/wsti.h @@ -57,7 +57,16 @@ namespace genetic { } public: /** - * Class constructor. Initializes class with requied values. + * Class constructor. Initializes class with required values. + * + * @param _chromosome Chromosome, for which value will be calculated + */ + WSTI(_Chromosome& _chromosome) + : Fitness<_Chromosome>(_chromosome) { + } + + /** + * Class constructor. Initializes class with required values. * * @param start begining of the Fitness function domain * @param end end of the Fitness function domain @@ -67,7 +76,7 @@ namespace genetic { } /** - * Class constructor. Initializes class with requied values. + * Class constructor. Initializes class with required values. * * @param _chromosome Chromosome, for which value will be calculated * @param start begining of the Fitness function domain @@ -76,6 +85,43 @@ namespace genetic { WSTI(_Chromosome& _chromosome, float start, float end) : Fitness<_Chromosome>(_chromosome), span_start(start), span_end(end) { } + + /** + * Method used to pass additional arguments needed by the function to + * run correctly. + * Required map keys are: + * - _span_start_ - with value equal to begining of the Fitness function domain + * - _span_end_ - with value equal to end of the Fitness function domain + * Their values should be floats. + * + * @param args map containing span_start and span_end as a keys and + * their values (_double_) passed as strings + */ + virtual void parseArguments(std::map args) { + std::map::iterator it; + for (it = args.begin(); it != args.end(); it++) { + if (it->first == "span_start") { + this->span_start = std::stod(it->second); + } + else if (it->first == "span_end") { + this->span_end = std::stod(it->second); + } + } + } + + /** + * Method used to get additional arguments needed by the function to + * run correctly. + * + * @return map containing span_start and span_end as a map keys, with + * their values passed as string + */ + std::map getArguments() { + std::map fit_args; + fit_args.insert(std::pair("span_start", std::to_string(span_start))); + fit_args.insert(std::pair("span_end", std::to_string(span_end))); + return fit_args; + } }; }