Class Enumeration<T>
java.lang.Object
org.moeaframework.analysis.parameter.AbstractParameter<T>
org.moeaframework.analysis.parameter.Enumeration<T>
- Type Parameters:
T
- the type of each value
- All Implemented Interfaces:
EnumeratedParameter<T>
,Parameter<T>
,SampledParameter<T>
,Named
public class Enumeration<T>
extends AbstractParameter<T>
implements EnumeratedParameter<T>, SampledParameter<T>
An enumeration of a fixed set of possible values. This parameter can either be used to enumerate all possible
values or sample according to a sequence.
-
Constructor Summary
ConstructorsConstructorDescriptionEnumeration
(String name, List<T> values) Constructs an enumeration with a fixed set of possible values.Enumeration
(String name, T... values) Constructs an enumeration with a fixed set of possible values. -
Method Summary
Modifier and TypeMethodDescriptionstatic Enumeration<String>
Decodes the string representation of this parameter.Encodes this parameter definition in a format suitable for storing in a file.Enumerates the parameters by creating a "cross join" with the existing samples.Parses this parameter value from the given string.void
Samples this parameter and assigns the value to the sample.int
size()
Returns the number of values defined by this enumeration.values()
Returns all possible values produced by this enumeration.Methods inherited from class org.moeaframework.analysis.parameter.AbstractParameter
getName, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.moeaframework.analysis.parameter.Parameter
assignValue, readValue
-
Constructor Details
-
Enumeration
Constructs an enumeration with a fixed set of possible values.- Parameters:
name
- the parameter namevalues
- the values
-
Enumeration
Constructs an enumeration with a fixed set of possible values.- Parameters:
name
- the parameter namevalues
- the values
-
-
Method Details
-
size
public int size()Returns the number of values defined by this enumeration.- Returns:
- the number of values
-
values
Description copied from interface:EnumeratedParameter
Returns all possible values produced by this enumeration.- Specified by:
values
in interfaceEnumeratedParameter<T>
- Returns:
- the values
-
parse
Description copied from interface:Parameter
Parses this parameter value from the given string. -
enumerate
Description copied from interface:EnumeratedParameter
Enumerates the parameters by creating a "cross join" with the existing samples. If givenN
samples as input, the result will containN * values().size()
samples.- Specified by:
enumerate
in interfaceEnumeratedParameter<T>
- Parameters:
samples
- the input samples- Returns:
- the enumerated samples including this parameter
-
sample
Description copied from interface:SampledParameter
Samples this parameter and assigns the value to the sample. The scale is a value between0.0
and1.0
, typically supplied by aSequence
, 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 interfaceSampledParameter<T>
- Parameters:
sample
- the samplescale
- value between0.0
and1.0
used to generate the sample
-
encode
Description copied from interface:Parameter
Encodes this parameter definition in a format suitable for storing in a file. -
decode
Decodes the string representation of this parameter.- Parameters:
tokenizer
- the tokenizerline
- the string representation- Returns:
- the decoded parameter
- Throws:
InvalidParameterException
- if the string representation is not a valid parameter
-