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
ConstructorsConstructorDescriptionFixedWeights(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 FixedWeightsLoads the weights from a file.static FixedWeightsLoads the weights from a reader.voidSaves the weights to a file.voidSaves the weights to a writer.intsize()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:WeightGeneratorReturns the number of weights that will be generated.- Specified by:
sizein interfaceWeightGenerator- Returns:
- the number of weights that will be generated
-
generate
Description copied from interface:WeightGeneratorReturns the generated weights.- Specified by:
generatein 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
-