delo.DescribedFunction¶
- class delo.DescribedFunction(function, dimension, domain_lower_limit=None, domain_upper_limit=None, name=None)¶
Function with attributes
Wrapper for function objects, that contains info about function’s domain.
- dimension¶
Dimension of function’s domain.
- Type
int
- domain_lower_limit¶
The lower limits of function domain.
- Type
np.array of dimension size
- domain_upper_limit¶
The upper limit of function domain.
- Type
np.array of dimension size
- call()¶
Call the passed in constructor.
Examples
>>> import delo >>> import numpy as np >>> >>> described_arcsin = delo.DescribedFunction(np.argsin, dimension=1, ... domain_lower_limit=-1, ... domain_upper_limit=1) DescribedFunction was created to be used in DE algorithms. Specifying domain limits is required >>> described_square_root = delo.DescribedFunction(np.sqrt, dimension=1, ... domain_lower_limit=0, ... domain_upper_limit=5) For multidimentional functions, appropriate wrapping is required: the np.array of arguments had to be converted into np.array of values >>> def my_single_argument_function(x): ... return np.sum(x ** 2) >>> >>> def my_multi_argument_wrapping(x): ... return np.array([my_single_argument_function(xi) for xi in x]) >>> >>> described_my_function = delo.DescribedFunction(my_multi_argument_wrapping, ... dimension=10, ... domain_lower_limit=-5, ... domain_upper_limit=5)
- __init__(function, dimension, domain_lower_limit=None, domain_upper_limit=None, name=None)¶
Constructor
- Parameters
function (callable) – function with 2D
np.ndarrayinput and scalar output.dimension (int) – Dimension of function’s domain.
domain_lower_limit (np.array, float, optional) – the lower limit of function domain. If None, it will be set to be repeated -10.
domain_upper_limit (np.array, float, optional) – is the upper limit of function domain. If None, it will be set to be repeated 10.
Methods
__init__(function, dimension[, ...])Constructor