saealib.Problem

class saealib.Problem(func, dim, n_obj, weight, lb, ub, eps=1e-06, comparator=None, constraints=None)[source]

Bases: object

Definition of optimization problem.

Parameters:
  • func (callable)

  • dim (int)

  • n_obj (int)

  • weight (np.ndarray)

  • lb (list[float])

  • ub (list[float])

  • eps (float)

  • comparator (Comparator | None)

  • constraints (list[Constraint] | None)

dim

Dimension of the design variables.

Type:

int

n_obj

Number of objectives.

Type:

int

weight

Weights for objectives. shape = (n_obj, )

Type:

np.ndarray

lb

Lower bounds for design variables. shape = (dim, )

Type:

np.ndarray

ub

Upper bounds for design variables. shape = (dim, )

Type:

np.ndarray

comparator

Comparator instance to compare solutions.

Type:

Comparator

eps

Epsilon value for comparison (Comparator use).

Type:

float

func

Objective function to evaluate solutions.

Type:

callable -> float

constraints

List of inequality constraint definitions.

Type:

list[Constraint]

Methods

__init__

Initialize Problem instance.

evaluate

Evaluate the objective function at given solution x.

evaluate_constraints

Evaluate all constraint functions at x.

Method Details

Problem.__init__(func, dim, n_obj, weight, lb, ub, eps=1e-06, comparator=None, constraints=None)[source]

Initialize Problem instance.

Parameters:
  • func (callable -> float) – Objective function to evaluate solutions.

  • dim (int) – Dimension of the design variables.

  • n_obj (int) – Number of objectives.

  • weight (np.ndarray) – Weights for objectives. shape = (n_obj, ) Used by SingleObjectiveComparator and WeightedSumComparator. Not used by NSGA2Comparator.

  • lb (list[float]) – Lower bounds for design variables. length = dim

  • ub (list[float]) – Upper bounds for design variables. length = dim

  • eps (float, optional) – Epsilon value for comparison (Comparator use), by default 1e-6

  • comparator (Comparator, optional) – Comparator instance to use. If None, auto-selected based on n_obj: n_obj == 1 -> SingleObjectiveComparator, n_obj > 1 -> NSGA2Comparator.

  • constraints (list[Constraint], optional) – List of inequality constraint definitions. Default: empty list.

Problem.evaluate(x)[source]

Evaluate the objective function at given solution x.

Parameters:

x (np.ndarray) – The solution to evaluate.

Returns:

The objective value(s) at solution x. shape = (n_obj, )

Return type:

np.ndarray

Problem.evaluate_constraints(x)[source]

Evaluate all constraint functions at x.

Parameters:

x (np.ndarray) – The solution to evaluate. shape = (dim, )

Returns:

  • g (np.ndarray) – Raw constraint values. shape = (n_constraints, ) Empty array when no constraints are defined.

  • cv (float) – Aggregate constraint violation = sum(max(0, g_i - threshold_i)). 0.0 when no constraints are defined.

Return type:

tuple[ndarray, float]