wrap_problem

ioh.wrap_problem(function: Callable[[numpy.typing.NDArray], float], name: str = None, problem_class: ProblemClass = ProblemClass.REAL, dimension: int = 5, instance: int = 1, optimization_type: OptimizationType = OptimizationType.MIN, lb: int | float = 0, ub: int | float = 1, transform_variables: Callable[[numpy.typing.NDArray, int], numpy.typing.NDArray | Sequence[int | float]] = None, transform_objectives: Callable[[float, int], float] = None, calculate_objective: Callable[[int, int], IntegerSolution | RealSolution] = None, constraints: List[IntegerConstraint | RealConstraint] = None) → RealSingleObjective | IntegerSingleObjective

Function to wrap a callable as an ioh function

Parameters:
  • function (fn(x: numpy.ndarray) -> float) – The callable to wrap. It gets x as a new numpy array (float64 for real, int32 for integer problems).

  • name (str = None) – The name of the function. This can be used to create new instances of this function. Note, when not using unique names, this will override the previously wrapped functions. The name of a built-in problem raises a ValueError. The problem gets the first free id of its problem class.

  • problem_class (ProblemClass = ProblemClass.REAL) – The type of the problem.

  • dimension (int = 5) – The dimension (number of variables) of the problem

  • instance (int = 1) – The instance ID of the problem

  • optimization_type (OptimizationType = OptimizationType.MIN) – The type of optimization to do, maximization or minimization

  • lb ([int, float] = 0) – The lower bound of the constraint, should be the same type as problem_class. Defaults to 0

  • ub ([int, float] = 1) – The upper bound of the constraint, should be the same type as problem_class. Defaults to 1

  • transform_variables (fn(x: numpy.ndarray, instance: int) -> numpy.ndarray | list = None) – A function to transform the elements of x, prior to calling the function. It gets x as a new numpy array, and returns the transformed x (an array, a list or another sequence of the same length).

  • transform_objectives (fn(y: float) -> float = None) – A function to tranform the float value of y, after callling the function.

  • calculate_objective (fn(instance, dimension) -> Solution | (x, y) = None) – A function to calculate the global optimum of the function. This function gets a dimension and instance id, and should return either a Solution objective(IntegerSolution or RealSolution) or a tuple giving the x and y values for the global optimum. Where x is the search space representation and y the target value.

  • constraints (list[IntegerConstraint | RealConstraint] = None) – The constraints applied to the problem