Class FixedWeights

java.lang.Object
org.moeaframework.util.weights.FixedWeights
All Implemented Interfaces:
WeightGenerator

public class FixedWeights extends Object implements WeightGenerator
Produces a fixed set of weights, typically loaded from a file.
  • 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

      public FixedWeights(List<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
  • Method Details

    • size

      public int size()
      Description copied from interface: WeightGenerator
      Returns the number of weights that will be generated.
      Specified by:
      size in interface WeightGenerator
      Returns:
      the number of weights that will be generated
    • generate

      public List<double[]> generate()
      Description copied from interface: WeightGenerator
      Returns the generated weights.
      Specified by:
      generate in interface WeightGenerator
      Returns:
      the generated weights
    • save

      public void save(File file) throws IOException
      Saves the weights to a file.
      Parameters:
      file - the file
      Throws:
      IOException - if an I/O error occurred
    • save

      public void save(Writer writer)
      Saves the weights to a writer.
      Parameters:
      writer - the writer
    • load

      public static FixedWeights load(File file) throws IOException
      Loads the weights from a file.
      Parameters:
      file - the file
      Returns:
      the loaded weights
      Throws:
      IllegalArgumentException - if the weights are not valid
      IOException - if an I/O error occurred
    • load

      public static FixedWeights load(Reader reader) throws IOException
      Loads the weights from a reader.
      Parameters:
      reader - the reader
      Returns:
      the loaded weights
      Throws:
      IllegalArgumentException - if the weights are not valid
      IOException - if an I/O error occurred