📄 realvalgene.cpp
字号:
/******************************************************************************* RealValGene.cpp last change: 01/04/1999 version: 0.0.0 design: Eckart Zitzler Paul E. Sevinc implementation: Paul E. Sevinc (c) 1998-1999: Computer Engineering and Networks Laboratory Swiss Federal Institute of Technology Zurich description: See RealValGene.h*******************************************************************************/#include "RealValGene.h"#include "Gene.h"#include "RandomNr.h"#include "TIKEAFExceptions.h"RealValGene::RealValGene( RandomNr& rn, double pm, double minAllele, double maxAllele ) throw ( ProbabilityException, LimitsException ) : Gene( rn, pm ), min( minAllele ), max( maxAllele ){#ifndef NOTIKEAFEXCEPTIONS if ( min >= max ) { throw LimitsException( "from RealValGene::RealValGene" ); }#endif}voidRealValGene::initRandom(){ allele = min + randomNr.uniform01() * ( max - min );}voidRealValGene::mutate(){ initRandom();}Gene*RealValGene::clone(){ RealValGene* rvg = new RealValGene( randomNr, pMutation, min, max ); rvg->allele = allele; return rvg;}voidRealValGene::setAllele( double a ) throw ( LimitsException ){#ifndef NOTIKEAEXCEPTIONS if ( a < min || a > max ) { throw LimitsException( "from RealValGene::setAllele" ); }#endif allele = a;}doubleRealValGene::getAllele(){ return allele;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -