Package no.priv.garshol.duke

Examples of no.priv.garshol.duke.Configuration


  @Test
  public void testMakeRandomCopy() {
    GeneticConfiguration conf = new GeneticConfiguration(config1);
    GeneticConfiguration confrand = conf.makeRandomCopy();
    Configuration rand = confrand.getConfiguration();

    assertTrue("shouldn't have a parent", conf.getParent() == null);
    assertTrue("wrong parent", confrand.getParent() == conf);
    assertEquals("wrong number of properties",
                 rand.getProperties().size(), 3);
   
    // same properties, but most aspects should now be different.
    // don't really want to a computation of how many aspects are different,
    // because with some degree of statistical likelihood, any limit is going
    // to be wrong some of the time. let's try this one and see how it works
View Full Code Here


  @Test
  public void testMutate() {
    GeneticConfiguration conf = new GeneticConfiguration(config1.copy());
    conf.mutate();
    Configuration rand = conf.getConfiguration();

    int diffs = countDifferences(config1, rand);
    if (diffs == 0) {
      // this happens every now and then by accident. when it does, we
      // give it a second try.
View Full Code Here

    List<Property> props = new ArrayList();
    props.add(new PropertyImpl("ID"));
    props.add(new PropertyImpl("NAME", lev, 0.2, 0.9));
    props.add(new PropertyImpl("EMAIL", lev, 0.2, 0.9));
   
    Configuration other = new ConfigurationImpl();
    ((ConfigurationImpl) other).setProperties(props);
    ((ConfigurationImpl) other).setThreshold(0.75);
    GeneticConfiguration g_other = new GeneticConfiguration(other);

    // proceed to mate
    GeneticConfiguration conf = new GeneticConfiguration(config1.copy());
    conf.mateWith(g_other);
    Configuration rand = conf.getConfiguration();

    // compute differences
    // there are seven aspects, which should always be equal to just one
    // of the original configurations. comparing against both should therefore
    // always yield exactly 7 differences.
View Full Code Here

    this.prop = prop;
    this.comparators = comparators;
  }

  public void setRandomly(GeneticConfiguration cfg) {
    Configuration config = cfg.getConfiguration();
    Property p = config.getPropertyByName(prop.getName());
    p.setComparator(comparators.get((int) (comparators.size() * Math.random())));
  }
View Full Code Here

    p.setComparator(comparators.get((int) (comparators.size() * Math.random())));
  }

  public void setFromOther(GeneticConfiguration cfg1,
                           GeneticConfiguration cfg2) {
    Configuration config = cfg1.getConfiguration();
    Configuration other = cfg2.getConfiguration();

    Property p1 = config.getPropertyByName(prop.getName());
    Property p2 = other.getPropertyByName(prop.getName());
    p1.setComparator(p2.getComparator());
  }
View Full Code Here

  public LowProbabilityAspect(Property prop) {
    this.prop = prop;
  }

  public void setRandomly(GeneticConfiguration cfg) {
    Configuration config = cfg.getConfiguration();
    Property p = config.getPropertyByName(prop.getName());
    double new_value = drift(config.getThreshold(), 0.5, 0.0);
    p.setLowProbability(new_value);
  }
View Full Code Here

    p.setLowProbability(new_value);
  }

  public void setFromOther(GeneticConfiguration cfg1,
                           GeneticConfiguration cfg2) {
    Configuration config = cfg1.getConfiguration();
    Configuration other = cfg2.getConfiguration();

    Property p1 = config.getPropertyByName(prop.getName());
    Property p2 = other.getPropertyByName(prop.getName());
    p1.setLowProbability(p2.getLowProbability());
  }
View Full Code Here

* Sets the threshold.
*/
public class ThresholdAspect extends FloatAspect {

  public void setRandomly(GeneticConfiguration cfg) {
    Configuration config = cfg.getConfiguration();
    double new_value = drift(config.getThreshold(), 1.0, 0.0);
    config.setThreshold(new_value);
  }
View Full Code Here

    config.setThreshold(new_value);
  }

  public void setFromOther(GeneticConfiguration cfg1,
                           GeneticConfiguration cfg2) {
    Configuration config = cfg1.getConfiguration();
    Configuration other = cfg2.getConfiguration();

    config.setThreshold(other.getThreshold());
  }
View Full Code Here

  public HighProbabilityAspect(Property prop) {
    this.prop = prop;
  }

  public void setRandomly(GeneticConfiguration cfg) {
    Configuration config = cfg.getConfiguration();
    Property p = config.getPropertyByName(prop.getName());
    double new_value = drift(config.getThreshold(), 1.0, 0.5);
    p.setHighProbability(new_value);
  }
View Full Code Here

TOP

Related Classes of no.priv.garshol.duke.Configuration

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.