Package no.priv.garshol.duke.genetic

Source Code of no.priv.garshol.duke.genetic.LowProbabilityAspect

package no.priv.garshol.duke.genetic;

import no.priv.garshol.duke.Property;
import no.priv.garshol.duke.Configuration;

/**
* Sets the low probability.
*/
public class LowProbabilityAspect extends FloatAspect {
  private Property prop;

  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);
  }

  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());
  }
 
}
TOP

Related Classes of no.priv.garshol.duke.genetic.LowProbabilityAspect

TOP
Copyright © 2018 www.massapi.com. 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.