/** * @throws Exception * @author Klaus Meffert */ public void testVerifyStateIsValid_0() throws Exception { Configuration conf = new Configuration(); assertEquals(false, conf.isLocked()); conf.setFitnessFunction(new StaticFitnessFunction(2)); try { conf.verifyStateIsValid(); fail(); } catch (InvalidConfigurationException invex) {; // this is OK } }
/** * Configuration with sample chromosome that has a gene with allele value null. * * @throws Exception * @author Klaus Meffert * @since 2.6 */ public void testVerifyStateIsValid_9() throws Exception { Configuration conf = new DefaultConfiguration(); conf.setFitnessFunction(new TestFitnessFunction()); BooleanGene gene = new BooleanGene(conf); gene.setAllele(null); Chromosome sample = new Chromosome(conf, gene, 55); conf.setSampleChromosome(sample); conf.setPopulationSize(5); conf.verifyStateIsValid(); }
/** * @throws Exception * @author Klaus Meffert */ public void testVerifyStateIsValid_1() throws Exception { Configuration conf = new Configuration(); assertEquals(false, conf.isLocked()); conf.setFitnessFunction(new StaticFitnessFunction(2)); Gene gene = new BooleanGene(conf); conf.setSampleChromosome(new Chromosome(conf, gene, 5)); try { conf.verifyStateIsValid(); fail(); } catch (InvalidConfigurationException invex) {; // this is OK } }
/** * Configuration with sample chromosome that contains no genes. * * @throws Exception * @author Klaus Meffert * @since 2.6 */ public void testVerifyStateIsValid_8() throws Exception { Configuration conf = new DefaultConfiguration(); conf.setFitnessFunction(new TestFitnessFunction()); Chromosome sample = new Chromosome(conf); conf.setSampleChromosome(sample); conf.setPopulationSize(5); try { conf.verifyStateIsValid(); fail(); } catch (InvalidConfigurationException illex) {; // this is OK } }
/** * @throws Exception * @author Klaus Meffert */ public void testVerifyStateIsValid_6() throws Exception { Configuration conf = new Configuration(); assertEquals(false, conf.isLocked()); conf.setFitnessFunction(new StaticFitnessFunction(2)); Gene gene = new BooleanGene(conf); conf.setSampleChromosome(new Chromosome(conf, gene, 5)); conf.addNaturalSelector(new WeightedRouletteSelector(conf), true); conf.setRandomGenerator(new StockRandomGenerator()); conf.setEventManager(new EventManager()); conf.setFitnessEvaluator(new DefaultFitnessEvaluator()); conf.addGeneticOperator(new MutationOperator(conf)); conf.setPopulationSize(1); conf.verifyStateIsValid(); }
/** * @throws Exception * @author Klaus Meffert */ public void testVerifyStateIsValid_3() throws Exception { Configuration conf = new Configuration(); assertEquals(false, conf.isLocked()); conf.setFitnessFunction(new StaticFitnessFunction(2)); Gene gene = new BooleanGene(conf); conf.setSampleChromosome(new Chromosome(conf, gene, 5)); conf.addNaturalSelector(new WeightedRouletteSelector(conf), true); conf.setRandomGenerator(new StockRandomGenerator()); try { conf.verifyStateIsValid(); fail(); } catch (InvalidConfigurationException invex) {; // this is OK } }
/** * @throws Exception * @author Klaus Meffert */ public void testVerifyStateIsValid_7() throws Exception { Configuration conf = new Configuration(); assertEquals(false, conf.isLocked()); conf.setFitnessFunction(new StaticFitnessFunction(2)); Gene gene = new BooleanGene(conf); conf.setSampleChromosome(new Chromosome(conf, gene, 5)); conf.addNaturalSelector(new WeightedRouletteSelector(conf), true); conf.setRandomGenerator(new StockRandomGenerator()); conf.setEventManager(new EventManager()); conf.addGeneticOperator(new MutationOperator(conf)); conf.setPopulationSize(1); try { conf.verifyStateIsValid(); fail(); } catch (IllegalArgumentException illex) {; // this is OK } }