ENOPPY Library

enoppy.engineer

class enoppy.engineer.Engineer[source]

Bases: abc.ABC

Defines an abstract class for engineering design problems.

All subclasses should implement the evaluate method for a particular problem.

bounds

The lower/upper bounds of the problem. This a 2D-matrix of [lower, upper] array that contain the lower and upper bounds. By default, each problem has its own bounds. But user can try to put different bounds to test the problem.

Type

list

n_dims

The dimensionality of the problem. It is calculated from bounds

Type

int

lb

The lower bounds for the problem

Type

np.ndarray

ub

The upper bounds for the problem

Type

np.ndarray

f_global

The global optimum of the evaluated function.

Type

float

x_global

A list of vectors that provide the locations of the global minimum. Note that some problems have multiple global minima, not all of which may be listed.

Type

np.ndarray

n_fe

The number of function evaluations that the object has been asked to calculate.

Type

int

amend_position(x, lb=None, ub=None)[source]

Amend position to fit the format of the problem

Parameters

x (np.ndarray) – The current position (solution)

property bounds

The lower/upper bounds to be used for optimization problem. This a 2D-matrix of [lower, upper] array that contain the lower and upper bounds for the problem. The problem should not be asked for evaluation outside these bounds. len(bounds) == n_dims.

check_penalty_func(func=None)[source]
check_solution(x)[source]

Raise the error if the problem size is not equal to the solution length

Parameters

x (np.ndarray) – The solution

convex = True
create_solution()[source]

Create a random solution for the current problem

Returns

solution – The random solution

Return type

np.ndarray

default_penalty(list_objs=None, list_cons=None)[source]
differentiable = True
evaluate(x)[source]

Evaluation of the benchmark function.

Parameters

x (np.ndarray, list, tuple) – The candidate vector for evaluating the benchmark problem. Must have len(x) == self.n_dims.

Returns

val – the evaluated benchmark function

Return type

float

get_cons(x)[source]

Compute the values of the constraint functions for a given set of input values.

get_eq_cons(x)[source]

Compute the values of the equality constraint functions for a given set of input values.

get_ineq_cons(x)[source]

Compute the values of the inequality constraint functions for a given set of input values.

get_objs(x)[source]

Compute the values of the objective functions for a given set of input values.

get_paras()[source]

Return the parameters of the problem. Depended on function

property lb

The lower bounds for the problem

Returns

lb – The lower bounds for the problem

Return type

1D-vector

linear = False
property n_cons

The number of constraint functions of the problem.

property n_dims

The dimensionality of the problem.

property n_eq_cons

The number of equality constraint functions of the problem.

property n_ineq_cons

The number of inequality constraint functions of the problem.

property n_objs

The number of objective functions of the problem.

name = 'Benchmark name'
parametric = True
property ub

The upper bounds for the problem

Returns

ub – The upper bounds for the problem

Return type

1D-vector