Class SampledDouble

java.lang.Object
org.moeaframework.analysis.parameter.AbstractParameter<Double>
org.moeaframework.analysis.parameter.SampledDouble
All Implemented Interfaces:
NumericParameter<Double>, Parameter<Double>, SampledParameter<Double>, Named

public class SampledDouble extends AbstractParameter<Double> implements SampledParameter<Double>, NumericParameter<Double>
Parameter representing a Double value.
  • Constructor Details

    • SampledDouble

      public SampledDouble(String name, double lowerBound, double upperBound)
      Constructs a new decimal parameter with the given sampling bounds.
      Parameters:
      name - the parameter name
      lowerBound - the lower bound
      upperBound - the upper bound
  • Method Details

    • getLowerBound

      public Double getLowerBound()
      Description copied from interface: NumericParameter
      The lower bound of this parameter.
      Specified by:
      getLowerBound in interface NumericParameter<Double>
      Returns:
      the lower bound
    • getUpperBound

      public Double getUpperBound()
      Description copied from interface: NumericParameter
      The upper bound of this parameter.
      Specified by:
      getUpperBound in interface NumericParameter<Double>
      Returns:
      the upper bound
    • parse

      public Double parse(String str)
      Description copied from interface: Parameter
      Parses this parameter value from the given string.
      Specified by:
      parse in interface Parameter<Double>
      Parameters:
      str - the string
      Returns:
      the parameter value
    • sample

      public void sample(Sample sample, double scale)
      Description copied from interface: SampledParameter
      Samples this parameter and assigns the value to the sample. The scale is a value between 0.0 and 1.0, typically supplied by a Sequence, used to generate the sampled value.

      When converting the scale to the parameter value, implementations are expected to provide equal weighting to each possible value, so that a value does not appear more or less often than any other value.

      Specified by:
      sample in interface SampledParameter<Double>
      Parameters:
      sample - the sample
      scale - value between 0.0 and 1.0 used to generate the sample
    • encode

      public String encode(Tokenizer tokenizer)
      Description copied from interface: Parameter
      Encodes this parameter definition in a format suitable for storing in a file.
      Specified by:
      encode in interface Parameter<Double>
      Parameters:
      tokenizer - the tokenizer
      Returns:
      the string representation
    • decode

      public static SampledDouble decode(Tokenizer tokenizer, String line)
      Decodes the string representation of this parameter.
      Parameters:
      tokenizer - the tokenizer
      line - the string representation
      Returns:
      the decoded parameter
      Throws:
      InvalidParameterException - if the string representation is not a valid parameter
    • applyPrecision

      public static String applyPrecision(double value)
      Rounds the decimal value using the same precision as Settings.EPS. This prevents small errors in the floating-point representation / arithmetic from manifesting as different parameter values.
      Parameters:
      value - the original decimal value
      Returns:
      the rounded decimal value stored as a string