Class ParameterSet
java.lang.Object
org.moeaframework.analysis.parameter.ParameterSet
A collection of parameters along with methods to enumerate or generate samples.
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs a new, empty parameter set.ParameterSet(Collection<? extends Parameter<?>> parameters) Constructs a parameter set with the given parameters.ParameterSet(Parameter<?>... parameters) Constructs a parameter set with the given parameters. -
Method Summary
Modifier and TypeMethodDescriptionEnumerates samples.Parameter<?>get(int index) Returns the parameter at the given index.Parameter<?>Returns the parameter with the given name.intReturns the index of the parameter with the given name.intReturns the index of the given parameter.booleanReturnstrueif this parameter set supports enumeration;falseotherwise.iterator()static ParameterSetLoads the parameter set.static ParameterSetLoads the parameter set.Generates samples according so some sequence.voidSaves the parameter set to a file.voidWrites the parameter set.intsize()Returns the number of parameters.toString()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
ParameterSet
public ParameterSet()Constructs a new, empty parameter set. -
ParameterSet
Constructs a parameter set with the given parameters.- Parameters:
parameters- the parameters
-
ParameterSet
Constructs a parameter set with the given parameters.- Parameters:
parameters- the parameters
-
-
Method Details
-
size
public int size()Returns the number of parameters.- Returns:
- the number of parameters
-
get
Returns the parameter at the given index.- Parameters:
index- the index- Returns:
- the parameter
- Throws:
IndexOutOfBoundsException- if the index is out of bounds
-
get
Returns the parameter with the given name.- Parameters:
name- the parameter name- Returns:
- the parameter
- Throws:
NoSuchParameterException- if no parameter matching the name was found
-
indexOf
Returns the index of the given parameter.- Parameters:
parameter- the parameter- Returns:
- the index of the parameter
-
indexOf
Returns the index of the parameter with the given name.- Parameters:
name- the parameter name- Returns:
- the index of the parameter
-
isEnumerable
public boolean isEnumerable()Returnstrueif this parameter set supports enumeration;falseotherwise. All parameters must beEnumeratedParameterorConstant.- Returns:
trueif this parameter set supports enumeration;falseotherwise.- See Also:
-
enumerate
Enumerates samples. This is effectively a "cross join" of each enumerated parameter, meaning every possible combination of values is generated. Ifkis the number of parameters andNis the number of values per enumeration, the result will containN^ksamples.- Returns:
- the enumerated samples
- Throws:
IllegalArgumentException- if any parameter is not enumerable or a constant
-
sample
Generates samples according so some sequence. The sequence is used to generate numbers between0.0and1.0, which are then converted to the parameter value by callingSampledParameter.sample(Sample, double).- Parameters:
numberOfSamples- the number of samples to generatesequence- the sequence generator- Returns:
- the generated samples
- Throws:
IllegalArgumentException- if any parameter is not sampled or a constant
-
iterator
-
toString
-
load
Loads the parameter set. Seeload(Reader)for details.- Parameters:
file- the file- Returns:
- the parameter set
- Throws:
IOException- if an I/O error occurredInvalidParameterException- if any parameter was invalid
-
load
Loads the parameter set. Parameters can be defined in the following formats:<name> <lb> <ub> # Legacy format <name> <type> <lb> <ub> # Range <name> const <val> # Constant <name> enum <val1> <val2> ... <valN> # Enumeration- Parameters:
reader- the reader- Returns:
- the parameter set
- Throws:
IOException- if an I/O error occurredInvalidParameterException- if any parameter was invalid- See Also:
-
save
Saves the parameter set to a file.- Parameters:
file- the file- Throws:
IOException- if an I/O error occurred
-
save
Writes the parameter set.- Parameters:
writer- the writer- Throws:
IOException- if an I/O error occurred
-