handle erroneous epop max size
This commit is contained in:
parent
89b3e6e983
commit
2650fb5476
|
@ -11,6 +11,7 @@ pub enum ReadError {
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
Read(ReadError),
|
Read(ReadError),
|
||||||
BadPopSize,
|
BadPopSize,
|
||||||
|
BadEpopMax,
|
||||||
BadMut,
|
BadMut,
|
||||||
BadCrossRatio,
|
BadCrossRatio,
|
||||||
BadMove(Pos),
|
BadMove(Pos),
|
||||||
|
@ -87,6 +88,7 @@ impl std::fmt::Display for Error {
|
||||||
match self {
|
match self {
|
||||||
Error::Read(e) => write!(f, "{e}"),
|
Error::Read(e) => write!(f, "{e}"),
|
||||||
Error::BadPopSize => write!(f, "population size cannot be 0"),
|
Error::BadPopSize => write!(f, "population size cannot be 0"),
|
||||||
|
Error::BadEpopMax => write!(f, "elite population size must be less than pop size"),
|
||||||
Error::BadMut => write!(f, "mutation length too large"),
|
Error::BadMut => write!(f, "mutation length too large"),
|
||||||
Error::BadCrossRatio => write!(f, "crossover ratio cannot be 0"),
|
Error::BadCrossRatio => write!(f, "crossover ratio cannot be 0"),
|
||||||
Error::BadMove(pos) => write!(f, "invalid move ({pos})"),
|
Error::BadMove(pos) => write!(f, "invalid move ({pos})"),
|
||||||
|
@ -552,6 +554,10 @@ pub fn run(config: Config, rle: Option<String>) -> Result<()> {
|
||||||
return Err(Error::BadPopSize);
|
return Err(Error::BadPopSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if config.epop_max >= config.pop_size {
|
||||||
|
return Err(Error::BadEpopMax);
|
||||||
|
}
|
||||||
|
|
||||||
if config.mut_max > config.dna_size {
|
if config.mut_max > config.dna_size {
|
||||||
return Err(Error::BadMut);
|
return Err(Error::BadMut);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue