diff --git a/src/lib.rs b/src/lib.rs index db3e89a..b12e235 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -11,6 +11,7 @@ pub enum ReadError { pub enum Error { Read(ReadError), BadPopSize, + BadEpopMax, BadMut, BadCrossRatio, BadMove(Pos), @@ -87,6 +88,7 @@ impl std::fmt::Display for Error { match self { Error::Read(e) => write!(f, "{e}"), 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::BadCrossRatio => write!(f, "crossover ratio cannot be 0"), Error::BadMove(pos) => write!(f, "invalid move ({pos})"), @@ -552,6 +554,10 @@ pub fn run(config: Config, rle: Option) -> Result<()> { return Err(Error::BadPopSize); } + if config.epop_max >= config.pop_size { + return Err(Error::BadEpopMax); + } + if config.mut_max > config.dna_size { return Err(Error::BadMut); }