public static ASSearch setSeed(ASSearch search, int seed) { if (search instanceof AntColonySearch) { ((AntColonySearch) search).setSeed(seed); return search; } if (search instanceof ArtificialBeeColonySearch) { ((ArtificialBeeColonySearch) search).setSeed(seed); return search; } if (search instanceof FireflySearch) { ((FireflySearch) search).setSeed(seed); return search; } if (search instanceof GeneticSearch) { ((GeneticSearch) search).setSeed(seed); return search; } if (search instanceof HarmonySearch) { ((HarmonySearch) search).setSeed(seed); return search; } if (search instanceof MemeticSearch) { ((MemeticSearch) search).setSeed(seed); return search; } if (search instanceof PSOSearch) { ((PSOSearch) search).setSeed(seed); return search; } if (search instanceof SimulatedAnnealingSearch) { ((SimulatedAnnealingSearch) search).setSeed(seed); return search; } if (search instanceof ScatterSearchV1) { ((ScatterSearchV1) search).setSeed(seed); return search; } if (search instanceof RandomSearch) { ((RandomSearch) search).setSeed(seed); return search; } if (search instanceof TabuSearch) { ((TabuSearch) search).setSeed(seed); return search; } if (search instanceof ArtificialImmuneSystemSearch) { ((ArtificialImmuneSystemSearch) search).setSeed(seed); return search; } return search; }
/** * Parses a given list of options. * * <p> * <!-- options-start --> * Valid options are: * * <p> * * <pre> * -P <start set> * Specify a starting set of attributes. * Eg. 1,3,5-7.If supplied, the starting set becomes * one member of the initial random * population. * </pre> * * <pre> * -Z <population size> * Set the size of the population (even number). * (default = 20). * </pre> * * <pre> * -G <number of generations> * Set the number of generations. * (default = 20) * </pre> * * <pre> * -C <probability of crossover> * Set the probability of crossover. * (default = 0.6) * </pre> * * <pre> * -M <probability of mutation> * Set the probability of mutation. * (default = 0.033) * </pre> * * <pre> * -R <report frequency> * Set frequency of generation reports. * e.g, setting the value to 5 will * report every 5th generation * (default = number of generations) * </pre> * * <pre> * -S <seed> * Set the random number seed. * (default = 1) * </pre> * * <!-- options-end --> * * @param options the list of options as an array of strings * @throws Exception if an option is not supported */ @Override public void setOptions(String[] options) throws Exception { String optionString; resetOptions(); optionString = Utils.getOption('P', options); if (optionString.length() != 0) { setStartSet(optionString); } optionString = Utils.getOption('Z', options); if (optionString.length() != 0) { setPopulationSize(Integer.parseInt(optionString)); } optionString = Utils.getOption('G', options); if (optionString.length() != 0) { setMaxGenerations(Integer.parseInt(optionString)); setReportFrequency(Integer.parseInt(optionString)); } optionString = Utils.getOption('C', options); if (optionString.length() != 0) { setCrossoverProb((new Double(optionString)).doubleValue()); } optionString = Utils.getOption('M', options); if (optionString.length() != 0) { setMutationProb((new Double(optionString)).doubleValue()); } optionString = Utils.getOption('R', options); if (optionString.length() != 0) { setReportFrequency(Integer.parseInt(optionString)); } optionString = Utils.getOption('S', options); if (optionString.length() != 0) { setSeed(Integer.parseInt(optionString)); } Utils.checkForRemainingOptions(options); }