Interface VecFactory<T>

Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface VecFactory<T>
This interface allows creating a vector object from a given array type T. It is useful if you need some additional parametrization of the created vectors.

As the following example shows, only one VecFactory instance should be used for creating the vectors for a given multi-objective problem.

private static final VecFactory<double[]> FACTORY = VecFactory.ofDoubleVec( Optimize.MAXIMUM, Optimize.MINIMUM, Optimize.MINIMUM, Optimize.MAXIMUM ); // The fitness function. static Vec<double[]> fitness(final double[] x) { final double[] result = new double[4]; // ... return FACTORY.newVec(result); }
In the example above, the first dimension of the created vector is maximized, the following two are minimized, and the last vector component is again maximized.
Since:
5.2
Version:
6.0
See Also:
  • Method Details

    • newVec

      Vec<T> newVec(T array)
      Create a new Vec object from the given array.
      Parameters:
      array - the array used in the created vector
      Returns:
      a new Vec object from the given array
      Throws:
      NullPointerException - if the given array is null
      IllegalArgumentException - if the array length is zero or doesn't match the required length of the actual factory
    • ofIntVec

      static VecFactory<int[]> ofIntVec(List<Optimize> optimizes)
      Create a new factory for int[] vectors. Additionally, you can specify the optimization direction (maximization or minimization) for each dimension. The dimensionality of the created vectors must be exactly the same as the given length of the given optimizes. If the lengths don't match, an IllegalArgumentException is thrown.
      Parameters:
      optimizes - the optimization direction for each dimension
      Returns:
      a new factory for int[] vectors
      Throws:
      NullPointerException - if the given optimizes is null
      IllegalArgumentException - if the optimizes length is zero
      See Also:
      API Note:
      Only one factory instance should be used for a given multi-objective problem.
    • ofIntVec

      static VecFactory<int[]> ofIntVec(Optimize... optimizes)
      Create a new factory for int[] vectors. Additionally, you can specify the optimization direction (maximization or minimization) for each dimension. The dimensionality of the created vectors must be exactly the same as the given length of the given optimizes. If the lengths don't match, an IllegalArgumentException is thrown.
      Parameters:
      optimizes - the optimization direction for each dimension
      Returns:
      a new factory for int[] vectors
      Throws:
      NullPointerException - if the given optimizes is null
      IllegalArgumentException - if the optimizes length is zero
      See Also:
      API Note:
      Only one factory instance should be used for a given multi-objective problem.
    • ofIntVec

      static VecFactory<int[]> ofIntVec()
      Create a new factory for int[] vectors, where all dimensions are maximized.
      Returns:
      a new factory for int[] vectors, where all dimensions are maximized
      See Also:
    • ofLongVec

      static VecFactory<long[]> ofLongVec(List<Optimize> optimizes)
      Create a new factory for long[] vectors. Additionally, you can specify the optimization direction (maximization or minimization) for each dimension. The dimensionality of the created vectors must be exactly the same as the given length of the given optimizes. If the lengths don't match, an IllegalArgumentException is thrown.
      Parameters:
      optimizes - the optimization direction for each dimension
      Returns:
      a new factory for long[] vectors
      Throws:
      NullPointerException - if the given optimizes is null
      IllegalArgumentException - if the optimizes length is zero
      See Also:
      API Note:
      Only one factory instance should be used for a given multi-objective problem.
    • ofLongVec

      static VecFactory<long[]> ofLongVec(Optimize... optimizes)
      Create a new factory for long[] vectors. Additionally, you can specify the optimization direction (maximization or minimization) for each dimension. The dimensionality of the created vectors must be exactly the same as the given length of the given optimizes. If the lengths don't match, an IllegalArgumentException is thrown.
      Parameters:
      optimizes - the optimization direction for each dimension
      Returns:
      a new factory for long[] vectors
      Throws:
      NullPointerException - if the given optimizes is null
      IllegalArgumentException - if the optimizes length is zero
      See Also:
      API Note:
      Only one factory instance should be used for a given multi-objective problem.
    • ofLongVec

      static VecFactory<long[]> ofLongVec()
      Create a new factory for long[] vectors, where all dimensions are maximized.
      Returns:
      a new factory for long[] vectors, where all dimensions are maximized
      See Also:
    • ofDoubleVec

      static VecFactory<double[]> ofDoubleVec(List<Optimize> optimizes)
      Create a new factory for double[] vectors. Additionally, you can specify the optimization direction (maximization or minimization) for each dimension. The dimensionality of the created vectors must be exactly the same as the given length of the given optimizes. If the lengths don't match, an IllegalArgumentException is thrown.
      Parameters:
      optimizes - the optimization direction for each dimension
      Returns:
      a new factory for double[] vectors
      Throws:
      NullPointerException - if the given optimizes is null
      IllegalArgumentException - if the optimizes length is zero
      See Also:
      API Note:
      Only one factory instance should be used for a given multi-objective problem.
    • ofDoubleVec

      static VecFactory<double[]> ofDoubleVec(Optimize... optimizes)
      Create a new factory for double[] vectors. Additionally, you can specify the optimization direction (maximization or minimization) for each dimension. The dimensionality of the created vectors must be exactly the same as the given length of the given optimizes. If the lengths don't match, an IllegalArgumentException is thrown.
      Parameters:
      optimizes - the optimization direction for each dimension
      Returns:
      a new factory for double[] vectors
      Throws:
      NullPointerException - if the given optimizes is null
      IllegalArgumentException - if the optimizes length is zero
      See Also:
      API Note:
      Only one factory instance should be used for a given multi-objective problem.
    • ofDoubleVec

      static VecFactory<double[]> ofDoubleVec()
      Create a new factory for double[] vectors, where all dimensions are maximized.
      Returns:
      a new factory for double[] vectors, where all dimensions are maximized
      See Also:
    • ofObjectVec

      static <T> VecFactory<T[]> ofObjectVec(Comparator<? super T> comparator, ElementDistance<T[]> distance, List<Optimize> optimizes)
      Create a new factory for T[] vectors. Additionally, you can specify the optimization direction (maximization or minimization) for each dimension. The dimensionality of the created vectors must be exactly the same as the given length of the given optimizes. If the lengths don't match, an IllegalArgumentException is thrown.
      Type Parameters:
      T - the array element type
      Parameters:
      comparator - the array element comparator
      distance - the element distance function
      optimizes - the optimization direction for each dimension
      Returns:
      a new factory for T[] vectors
      Throws:
      NullPointerException - if one of the arguments is null
      IllegalArgumentException - if the optimizes length is zero
      See Also:
    • ofObjectVec

      static <T> VecFactory<T[]> ofObjectVec(Comparator<? super T> comparator, ElementDistance<T[]> distance, Optimize... optimizes)
      Create a new factory for T[] vectors. Additionally, you can specify the optimization direction (maximization or minimization) for each dimension. The dimensionality of the created vectors must be exactly the same as the given length of the given optimizes. If the lengths don't match, an IllegalArgumentException is thrown.
      Type Parameters:
      T - the array element type
      Parameters:
      comparator - the array element comparator
      distance - the element distance function
      optimizes - the optimization direction for each dimension
      Returns:
      a new factory for T[] vectors
      Throws:
      NullPointerException - if one of the arguments is null
      IllegalArgumentException - if the optimizes length is zero
      See Also:
    • ofObjectVec

      static <T extends Comparable<? super T>> VecFactory<T[]> ofObjectVec(ElementDistance<T[]> distance, List<Optimize> optimizes)
      Create a new factory for T[] vectors with comparable element types. Additionally, you can specify the optimization direction (maximization or minimization) for each dimension. The dimensionality of the created vectors must be exactly the same as the given length of the given optimizes. If the lengths don't match, an IllegalArgumentException is thrown.
      Type Parameters:
      T - the array element type
      Parameters:
      distance - the element distance function
      optimizes - the optimization direction for each dimension
      Returns:
      a new factory for T[] vectors
      Throws:
      NullPointerException - if one of the arguments is null
      IllegalArgumentException - if the optimizes length is zero
      Since:
      6.0
      See Also:
    • ofObjectVec

      static <T extends Comparable<? super T>> VecFactory<T[]> ofObjectVec(ElementDistance<T[]> distance, Optimize... optimizes)
      Create a new factory for T[] vectors with comparable element types. Additionally, you can specify the optimization direction (maximization or minimization) for each dimension. The dimensionality of the created vectors must be exactly the same as the given length of the given optimizes. If the lengths don't match, an IllegalArgumentException is thrown.
      Type Parameters:
      T - the array element type
      Parameters:
      distance - the element distance function
      optimizes - the optimization direction for each dimension
      Returns:
      a new factory for T[] vectors
      Throws:
      NullPointerException - if one of the arguments is null
      IllegalArgumentException - if the optimizes length is zero
      Since:
      6.0
      See Also:
    • ofObjectVec

      static <T extends Comparable<? super T>> VecFactory<T[]> ofObjectVec(List<Optimize> optimizes)
      Create a new factory for T[] vectors with comparable element types. Additionally, you can specify the optimization direction (maximization or minimization) for each dimension. The dimensionality of the created vectors must be exactly the same as the given length of the given optimizes. If the lengths don't match, an IllegalArgumentException is thrown.
      Type Parameters:
      T - the array element type
      Parameters:
      optimizes - the optimization direction for each dimension
      Returns:
      a new factory for T[] vectors
      Throws:
      NullPointerException - if one of the arguments is null
      IllegalArgumentException - if the optimizes length is zero
      Since:
      6.0
      See Also:
    • ofObjectVec

      static <T extends Comparable<? super T>> VecFactory<T[]> ofObjectVec(Optimize... optimizes)
      Create a new factory for T[] vectors with comparable element types. Additionally, you can specify the optimization direction (maximization or minimization) for each dimension. The dimensionality of the created vectors must be exactly the same as the given length of the given optimizes. If the lengths don't match, an IllegalArgumentException is thrown.
      Type Parameters:
      T - the array element type
      Parameters:
      optimizes - the optimization direction for each dimension
      Returns:
      a new factory for T[] vectors
      Throws:
      NullPointerException - if one of the arguments is null
      IllegalArgumentException - if the optimizes length is zero
      Since:
      6.0
      See Also:
    • ofObjectVec

      static <T extends Comparable<? super T>> VecFactory<T[]> ofObjectVec()
      Create a new factory for T[] vectors with comparable element types. Additionally, you can specify the optimization direction (maximization or minimization) for each dimension. The dimensionality of the created vectors must be exactly the same as the given length of the given optimizes. If the lengths don't match, an IllegalArgumentException is thrown.
      Type Parameters:
      T - the array element type
      Returns:
      a new factory for T[] vectors
      Throws:
      NullPointerException - if one of the arguments is null
      IllegalArgumentException - if the optimizes length is zero
      Since:
      6.0
      See Also: