Class ParameterSet
java.lang.Object
org.moeaframework.analysis.parameter.ParameterSet
A collection of parameters along with methods to enumerate or generate samples.
-
Constructor Summary
ConstructorDescriptionConstructs 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.int
Returns the index of the parameter with the given name.int
Returns the index of the given parameter.boolean
Returnstrue
if this parameter set supports enumeration;false
otherwise.iterator()
static ParameterSet
Loads the parameter set.static ParameterSet
Loads the parameter set.Generates samples according so some sequence.void
Saves the parameter set to a file.void
Writes the parameter set.int
size()
Returns the number of parameters.toString()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods 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()Returnstrue
if this parameter set supports enumeration;false
otherwise. All parameters must beEnumeratedParameter
orConstant
.- Returns:
true
if this parameter set supports enumeration;false
otherwise.- See Also:
-
enumerate
Enumerates samples. This is effectively a "cross join" of each enumerated parameter, meaning every possible combination of values is generated. Ifk
is the number of parameters andN
is the number of values per enumeration, the result will containN^k
samples.- 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.0
and1.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
-