Package org.moeaframework.util.weights
Class FixedWeights
java.lang.Object
org.moeaframework.util.weights.FixedWeights
- All Implemented Interfaces:
WeightGenerator
Produces a fixed set of weights, typically loaded from a file.
-
Constructor Summary
ConstructorDescriptionFixedWeights
(double[][] weights) Constructs a new weight using a fixed set of weights.FixedWeights
(List<double[]> weights) Constructs a new weight using a fixed set of weights. -
Method Summary
Modifier and TypeMethodDescriptionList<double[]>
generate()
Returns the generated weights.static FixedWeights
Loads the weights from a file.static FixedWeights
Loads the weights from a reader.void
Saves the weights to a file.void
Saves the weights to a writer.int
size()
Returns the number of weights that will be generated.
-
Constructor Details
-
FixedWeights
public FixedWeights(double[][] weights) Constructs a new weight using a fixed set of weights.- Parameters:
weights
- the fixed set of weights- Throws:
IllegalArgumentException
- if the weights are not valid
-
FixedWeights
Constructs a new weight using a fixed set of weights.- Parameters:
weights
- the fixed set of weights- Throws:
IllegalArgumentException
- if the weights are not valid
-
-
Method Details
-
size
public int size()Description copied from interface:WeightGenerator
Returns the number of weights that will be generated.- Specified by:
size
in interfaceWeightGenerator
- Returns:
- the number of weights that will be generated
-
generate
Description copied from interface:WeightGenerator
Returns the generated weights.- Specified by:
generate
in interfaceWeightGenerator
- Returns:
- the generated weights
-
save
Saves the weights to a file.- Parameters:
file
- the file- Throws:
IOException
- if an I/O error occurred
-
save
Saves the weights to a writer.- Parameters:
writer
- the writer
-
load
Loads the weights from a file.- Parameters:
file
- the file- Returns:
- the loaded weights
- Throws:
IllegalArgumentException
- if the weights are not validIOException
- if an I/O error occurred
-
load
Loads the weights from a reader.- Parameters:
reader
- the reader- Returns:
- the loaded weights
- Throws:
IllegalArgumentException
- if the weights are not validIOException
- if an I/O error occurred
-