예제 #1
0
  /**
   * Parses a given list of options.
   *
   * <p>
   * <!-- options-start -->
   * Valid options are:
   *
   * <p>
   *
   * <pre>
   * -P &lt;start set&gt;
   *  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 &lt;population size&gt;
   *  Set the size of the population (even number).
   *  (default = 20).
   * </pre>
   *
   * <pre>
   * -G &lt;number of generations&gt;
   *  Set the number of generations.
   *  (default = 20)
   * </pre>
   *
   * <pre>
   * -C &lt;probability of crossover&gt;
   *  Set the probability of crossover.
   *  (default = 0.6)
   * </pre>
   *
   * <pre>
   * -M &lt;probability of mutation&gt;
   *  Set the probability of mutation.
   *  (default = 0.033)
   * </pre>
   *
   * <pre>
   * -R &lt;report frequency&gt;
   *  Set frequency of generation reports.
   *  e.g, setting the value to 5 will
   *  report every 5th generation
   *  (default = number of generations)
   * </pre>
   *
   * <pre>
   * -S &lt;seed&gt;
   *  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);
  }
예제 #2
0
 /** Constructor. Make a new GeneticSearch object */
 public GeneticSearch() {
   resetOptions();
 }