wrap_problem#

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

Function to wrap a callable as an ioh function

Parameters:
  • function (fn(x: list) -> float) – The callable to wrap

  • 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.

  • 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: list) -> list = None) – A function to transform the elements of x, prior to calling the function.

  • 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