OMADS package
Submodules
OMADS.POLL module
This is a python implementation of the orothognal mesh adaptive direct search method (OMADS)
- class OMADS.POLL.DType(_prec: str = 'medium', _dtype: numpy.dtype = <class 'numpy.float64'>, _itype: numpy.dtype = <class 'numpy.int64'>, _zero: float = 1e-15, _warned: bool = False)[source]
Bases:
object
A numpy data type delegator for decimal precision control
- Parameters
prec (str, optional) – Default precision option can be set to “high”, “medium” or “low” precision resolution, defaults to “medium”
dtype (np.dtype, optional) – Numpy double data type precision, defaults to np.float64
itype (np.dtype, optional) – Numpy integer data type precision, defaults to np.int
zero (float, optional) – Zero value resolution, defaults to np.finfo(np.float64).resolution
- property zero: float
This is the mantissa value of the machine zero
- Returns
machine precision zero resolution
- Return type
float
- property precision
Set/get precision resolution level
- Returns
float precision value
- Return type
numpy float
- Note
MS Windows does not support precision with the {1e-18} high resolution of the python numerical library (numpy) so high precision will be changed to medium precision which supports {1e-15} resolution check: https://numpy.org/doc/stable/user/basics.types.html
- property dtype
Set/get the double formate type
- Returns
float precision value
- Return type
numpy float
- property itype
Set/Get for the integer formate type
- Returns
integer precision value
- Return type
numpy float
- __init__(_prec: str = 'medium', _dtype: numpy.dtype = <class 'numpy.float64'>, _itype: numpy.dtype = <class 'numpy.int64'>, _zero: float = 1e-15, _warned: bool = False) None
- class OMADS.POLL.Options(seed: int = 0, budget: int = 1000, tol: float = 1e-09, psize_init: float = 1.0, display: bool = False, opportunistic: bool = False, check_cache: bool = False, store_cache: bool = False, collect_y: bool = False, rich_direction: bool = False, precision: str = 'high', save_results: bool = False, save_coordinates: bool = False, save_all_best: bool = False, parallel_mode: bool = False, np: int = 1)[source]
Bases:
object
The running study and algorithmic options of OMADS
- Parameters
seed – Random generator seed
budget – The evaluation budget
tol – The threshold of the minimum poll size at which the run will be terminated
psize_init – Initial poll size
dispaly – Print the study progress during the run
opportunistic – Loop on the points populated in the poll set until a better minimum found, then stop the evaluation loop
check_cache – Check the hash table before points evaluation to avoid duplicates
store_cache – Enable storing evaluated points into the hash table
collect_y – Collect dependent design variables (required for DMDO)
rich_direction – Go with the rich direction (Impact the mesh size update)
precision – Define the precision level
save_results – A boolean flag that indicates saving results in a csv file
save_coordinates – A boolean flag that indicates saving coordinates of the poll set in a JSON file (required to generate animations of the spinner)
save_all_best – A boolean used to check whether saving best points only in the MADS.out file
parallel_mode – A boolean to check whether evaluating the poll set in parallel multiprocessing
np – The number of CPUs
- seed: int = 0
- budget: int = 1000
- tol: float = 1e-09
- psize_init: float = 1.0
- display: bool = False
- opportunistic: bool = False
- check_cache: bool = False
- store_cache: bool = False
- collect_y: bool = False
- rich_direction: bool = False
- precision: str = 'high'
- save_results: bool = False
- save_coordinates: bool = False
- save_all_best: bool = False
- parallel_mode: bool = False
- np: int = 1
- __init__(seed: int = 0, budget: int = 1000, tol: float = 1e-09, psize_init: float = 1.0, display: bool = False, opportunistic: bool = False, check_cache: bool = False, store_cache: bool = False, collect_y: bool = False, rich_direction: bool = False, precision: str = 'high', save_results: bool = False, save_coordinates: bool = False, save_all_best: bool = False, parallel_mode: bool = False, np: int = 1) None
- class OMADS.POLL.VAR_TYPE(value)[source]
Bases:
enum.Enum
An enumeration.
- CONTINUOUS = 1
- INTEGER = 2
- DISCRETE = 3
- BINARY = 4
- CATEGORICAL = 5
- ORDINAL = 6
- class OMADS.POLL.Parameters(baseline: typing.List[float] = <factory>, lb: typing.List[float] = <factory>, ub: typing.List[float] = <factory>, var_names: typing.List[str] = <factory>, scaling: float = 10.0, post_dir: str = '/Users/ahmedb/apps/code/Bay_dev/OMADS/docs-dev/.\\', var_type: typing.Optional[typing.List[str]] = None, var_sets: typing.Optional[typing.Dict] = None, constants: typing.Optional[typing.List] = None, constants_name: typing.Optional[typing.List] = None)[source]
Bases:
object
Variables and algorithmic parameters
- Parameters
baseline – Baseline design point (initial point
x0
)lb – The variables lower bound
ub – The variables upper bound
var_names – The variables name
scaling – Scaling factor (can be defined as a list (assigning a factor for each variable) or a scalar value that will be applied on all variables)
post_dir – The location and name of the post directory where the output results file will live in (if any)
- baseline: List[float]
- lb: List[float]
- ub: List[float]
- var_names: List[str]
- scaling: float = 10.0
- post_dir: str = '/Users/ahmedb/apps/code/Bay_dev/OMADS/docs-dev/.\\'
- var_type: List[str] = None
- var_sets: Dict = None
- constants: List = None
- constants_name: List = None
- __init__(baseline: typing.List[float] = <factory>, lb: typing.List[float] = <factory>, ub: typing.List[float] = <factory>, var_names: typing.List[str] = <factory>, scaling: float = 10.0, post_dir: str = '/Users/ahmedb/apps/code/Bay_dev/OMADS/docs-dev/.\\', var_type: typing.Optional[typing.List[str]] = None, var_sets: typing.Optional[typing.Dict] = None, constants: typing.Optional[typing.List] = None, constants_name: typing.Optional[typing.List] = None) None
- class OMADS.POLL.Evaluator(blackbox: typing.Any = 'rosenbrock', commandOptions: typing.Optional[typing.Any] = None, internal: typing.Optional[str] = None, path: str = '..\\tests\\Rosen', input: str = 'input.inp', output: str = 'output.out', constants: typing.Optional[typing.List] = None, bb_eval: int = 0, _dtype: OMADS.POLL.DType = DType(_prec='medium', _dtype=<class 'numpy.float64'>, _itype=<class 'numpy.int64'>, _zero=1e-15, _warned=False), timeout: float = 1000000.0)[source]
Bases:
object
Define the evaluator attributes and settings
- Parameters
blackbox – The blackbox name (it can be a callable function or an executable file)
commandOptions – Define options that will be added to the execution command of the executable file. Command options should be defined as a string in one line
internal – If the blackbox callable function is part of the internal benchmarking library
path – The path of the executable file (if any)
input – The input file name – should include the file extension
output – The output file name – should include the file extension
constants – Define constant parameters list, see the documentation in Tutorials->Blackbox evaluation->User parameters
_dtype – The precision delegator of the numpy library
timeout – The time out of the evaluation process
- blackbox: Any = 'rosenbrock'
- commandOptions: Any = None
- internal: Optional[str] = None
- path: str = '..\\tests\\Rosen'
- input: str = 'input.inp'
- output: str = 'output.out'
- constants: List = None
- bb_eval: int = 0
- timeout: float = 1000000.0
- property dtype
- eval(values: List[float])[source]
Evaluate the poll point
- Parameters
values (List[float]) – Poll point coordinates (design vector)
- Raises
IOError – Incorrect number of input arguments introduced to the callable function
IOError – Incorrect number of input arguments introduced to the callable function
IOError – The blackbox file is not an executable file (if not a callable function)
IOError – Incorrect benchmarking keyword category
- Returns
Evaluated optimization functions
- Return type
List[float, List[float]]
- write_input(values: List[float])[source]
_summary_
- Parameters
values (List[float]) – Write the variables in the input file
- read_output() List[float] [source]
_summary_
- Returns
Read the output values from the output file
- Return type
List[float]
- __init__(blackbox: typing.Any = 'rosenbrock', commandOptions: typing.Optional[typing.Any] = None, internal: typing.Optional[str] = None, path: str = '..\\tests\\Rosen', input: str = 'input.inp', output: str = 'output.out', constants: typing.Optional[typing.List] = None, bb_eval: int = 0, _dtype: OMADS.POLL.DType = DType(_prec='medium', _dtype=<class 'numpy.float64'>, _itype=<class 'numpy.int64'>, _zero=1e-15, _warned=False), timeout: float = 1000000.0) None
- class OMADS.POLL.Point(_n: int = 0, _coords: typing.List[float] = <factory>, _defined: typing.List[bool] = <factory>, _evaluated: bool = False, _f: float = inf, _freal: float = inf, _c_ineq: typing.List[float] = <factory>, _c_eq: typing.List[float] = <factory>, _h: float = inf, _signature: int = 0, _dtype: OMADS.POLL.DType = DType(_prec='medium', _dtype=<class 'numpy.float64'>, _itype=<class 'numpy.int64'>, _zero=1e-15, _warned=False), _var_type: typing.Optional[typing.List[int]] = None, _sets: typing.Optional[typing.Dict] = None, _var_link: typing.Optional[typing.List[str]] = None)[source]
Bases:
object
A class for the poll point
- Parameters
_n – # Dimension of the point
_coords – Coordinates of the point
_defined – Coordinates definition boolean
_evaluated – Evaluation boolean
_f – Objective function
_freal – Realistic target value of the objective function
_c_ineq – Inequality constraints
_c_eq – Equality constraints
_h – Aggregated constraints; active set
_signature – hash signature; facilitate looking for duplicates and storing coordinates, hash signature, in the cache memory
_dtype – numpy double data type precision
- property var_link
- property var_type: List[int]
- property sets
- property dtype
- property evaluated
- property signature
- property n_dimensions
- property coordinates
Get the coordinates of the point.
- property defined: List[bool]
- property f
- property freal
- property c_ineq
- property c_eq
- property h
- __init__(_n: int = 0, _coords: typing.List[float] = <factory>, _defined: typing.List[bool] = <factory>, _evaluated: bool = False, _f: float = inf, _freal: float = inf, _c_ineq: typing.List[float] = <factory>, _c_eq: typing.List[float] = <factory>, _h: float = inf, _signature: int = 0, _dtype: OMADS.POLL.DType = DType(_prec='medium', _dtype=<class 'numpy.float64'>, _itype=<class 'numpy.int64'>, _zero=1e-15, _warned=False), _var_type: typing.Optional[typing.List[int]] = None, _sets: typing.Optional[typing.Dict] = None, _var_link: typing.Optional[typing.List[str]] = None) None
- class OMADS.POLL.OrthoMesh(_delta: float = -1.0, _Delta: float = -1.0, _rho: float = -1.0, _exp: int = 0, _mantissa: int = 1, psize_max: float = 0.0, psize_success: float = 0.0, _dtype: OMADS.POLL.DType = DType(_prec='medium', _dtype=<class 'numpy.float64'>, _itype=<class 'numpy.int64'>, _zero=1e-15, _warned=False))[source]
Bases:
object
Mesh coarsness update class
- Parameters
_delta – mesh size
_Delta – poll size
_rho – poll size to mesh size ratio
_exp – manage the poll size granularity for discrete variables. See Audet et. al, The mesh adaptive direct search algorithm for granular and discrete variable
_mantissa – Same as
_exp
psize_max – Maximum poll size
psize_success – Poll size at successful evaluation
_dtype – numpy double data type precision
- psize_max: float = 0.0
- psize_success: float = 0.0
- property dtype
- property msize
- property psize
- property rho
- __init__(_delta: float = -1.0, _Delta: float = -1.0, _rho: float = -1.0, _exp: int = 0, _mantissa: int = 1, psize_max: float = 0.0, psize_success: float = 0.0, _dtype: OMADS.POLL.DType = DType(_prec='medium', _dtype=<class 'numpy.float64'>, _itype=<class 'numpy.int64'>, _zero=1e-15, _warned=False)) None
- class OMADS.POLL.Cache(_hash_ID: typing.List[int] = <factory>, _cache_dict: typing.Dict[typing.Any, typing.Any] = <factory>)[source]
Bases:
object
In computing, a hash table (hash map) is a data structure that implements an associative array abstract data type, a structure that can map keys to values. A hash table uses a hash function to compute an index, also called a hash code, into an array of buckets or slots, from which the desired value can be found. During lookup, the key is hashed and the resulting hash indicates where the corresponding value is stored.
- property cache_dict: Dict
A getter of the cache memory dictionary
- Return type
Dict
- property hash_id: List[int]
A getter to return the list of hash IDs
- Return type
List[int]
- property size: int
A getter of the size of the hash ID list
- Return type
int
- is_duplicate(x: OMADS.POLL.Point) bool [source]
Check if the point is in the cache memory
- Parameters
x (Point) – Design point
- Returns
A boolean flag indicate whether the point exist in the cache memory
- Return type
bool
- get_index(x: OMADS.POLL.Point) int [source]
Get the index of hash value, associated with the point x, if that point was saved in the cach memory
- Parameters
x (Point) – Input point
- Returns
The index of the point in the hash ID list
- Return type
int
- add_to_cache(x: OMADS.POLL.Point)[source]
Save the point x to the cache memory
- Parameters
x (Point) – Evaluated point to be saved in the cache memory
- __init__(_hash_ID: typing.List[int] = <factory>, _cache_dict: typing.Dict[typing.Any, typing.Any] = <factory>) None
- class OMADS.POLL.Dirs2n(_poll_dirs: typing.List[OMADS.POLL.Point] = <factory>, _point_index: typing.List[int] = <factory>, _n: int = 0, _defined: typing.List[bool] = <factory>, scaling: typing.List[typing.List[float]] = <factory>, _xmin: OMADS.POLL.Point = Point(_n=0, _coords=[], _defined=[False], _evaluated=False, _f=inf, _freal=inf, _c_ineq=[], _c_eq=[], _h=inf, _signature=0, _dtype=DType(_prec='medium', _dtype=<class 'numpy.float64'>, _itype=<class 'numpy.int64'>, _zero=1e-15, _warned=False), _var_type=None, _sets=None, _var_link=None), _nb_success: int = 0, _bb_eval: int = <factory>, _psize: float = <factory>, _iter: int = <factory>, hashtable: OMADS.POLL.Cache = <factory>, _check_cache: bool = True, _display: bool = True, _store_cache: bool = True, mesh: OMADS.POLL.OrthoMesh = <factory>, _opportunistic: bool = False, _eval_budget: int = 100, _dtype: OMADS.POLL.DType = DType(_prec='medium', _dtype=<class 'numpy.float64'>, _itype=<class 'numpy.int64'>, _zero=1e-15, _warned=False), bb_handle: OMADS.POLL.Evaluator = <factory>, _success: bool = False, _seed: int = 0, _terminate: bool = False, _bb_output: typing.List[float] = <factory>)[source]
Bases:
object
This is the orthognal 2n-directions class used for the poll step
- Parameters
_poll_dirs – Poll set (list of points)
_point_index – List of point indices
_n – Number of directions
_defined – A boolean that indicate if the poll points are defined
- scaling: List[List[float]]
- hashtable: OMADS.POLL.Cache
- mesh: OMADS.POLL.OrthoMesh
- bb_handle: OMADS.POLL.Evaluator
- property bb_output: List[float]
- property dtype
- property point_index
- property terminate
- property seed
- property success
- property eval_budget
- property opportunistic
- property save_results
- property store_cache
- property check_cache
- property display
- __init__(_poll_dirs: typing.List[OMADS.POLL.Point] = <factory>, _point_index: typing.List[int] = <factory>, _n: int = 0, _defined: typing.List[bool] = <factory>, scaling: typing.List[typing.List[float]] = <factory>, _xmin: OMADS.POLL.Point = Point(_n=0, _coords=[], _defined=[False], _evaluated=False, _f=inf, _freal=inf, _c_ineq=[], _c_eq=[], _h=inf, _signature=0, _dtype=DType(_prec='medium', _dtype=<class 'numpy.float64'>, _itype=<class 'numpy.int64'>, _zero=1e-15, _warned=False), _var_type=None, _sets=None, _var_link=None), _nb_success: int = 0, _bb_eval: int = <factory>, _psize: float = <factory>, _iter: int = <factory>, hashtable: OMADS.POLL.Cache = <factory>, _check_cache: bool = True, _display: bool = True, _store_cache: bool = True, mesh: OMADS.POLL.OrthoMesh = <factory>, _opportunistic: bool = False, _eval_budget: int = 100, _dtype: OMADS.POLL.DType = DType(_prec='medium', _dtype=<class 'numpy.float64'>, _itype=<class 'numpy.int64'>, _zero=1e-15, _warned=False), bb_handle: OMADS.POLL.Evaluator = <factory>, _success: bool = False, _seed: int = 0, _terminate: bool = False, _bb_output: typing.List[float] = <factory>) None
- property bb_eval
- property psize
- property iter
- property poll_dirs
- property dim
- property defined
- property xmin
- property nb_success
- create_housholder(is_rich: bool, domain: Optional[List[int]] = None) numpy.ndarray [source]
Create householder matrix
- Parameters
is_rich (bool) – A flag that indicates if the rich direction option is enabled
- Returns
The householder matrix
- Return type
np.ndarray
- create_poll_set(hhm: numpy.ndarray, ub: List[float], lb: List[float], it: int, var_type: List, var_sets: Dict, var_link: List[str])[source]
Create the poll directions
- Parameters
hhm (np.ndarray) – Householder matrix
ub (List[float]) – Variables upper bound
lb (List[float]) – Variables lower bound
it (int) – iteration
- master_updates(x: List[OMADS.POLL.Point], peval)[source]
- class OMADS.POLL.PreMADS(data: Dict[Any, Any])[source]
Bases:
object
Preprocessor for setting up optimization settings and parameters
- __init__(data: Dict[Any, Any]) None
- data: Dict[Any, Any]
- class OMADS.POLL.Output(file_path: str, vnames: typing.List[str], field_names: typing.List[str] = <factory>)[source]
Bases:
object
Results output file decorator
- __init__(file_path: str, vnames: typing.List[str], field_names: typing.List[str] = <factory>) None
- file_path: str
- vnames: List[str]
- file_writer: Any
- field_names: List[str]
- class OMADS.POLL.PostMADS(x_incumbent: typing.List[OMADS.POLL.Point], xmin: OMADS.POLL.Point, coords: typing.List[typing.List[OMADS.POLL.Point]] = <factory>, poll_dirs: typing.List[OMADS.POLL.Point] = <factory>, iter: typing.List[int] = <factory>, bb_eval: typing.List[int] = <factory>, psize: typing.List[float] = <factory>)[source]
Bases:
object
Results postprocessor
- __init__(x_incumbent: typing.List[OMADS.POLL.Point], xmin: OMADS.POLL.Point, coords: typing.List[typing.List[OMADS.POLL.Point]] = <factory>, poll_dirs: typing.List[OMADS.POLL.Point] = <factory>, iter: typing.List[int] = <factory>, bb_eval: typing.List[int] = <factory>, psize: typing.List[float] = <factory>) None
- x_incumbent: List[OMADS.POLL.Point]
- xmin: OMADS.POLL.Point
- coords: List[List[OMADS.POLL.Point]]
- poll_dirs: List[OMADS.POLL.Point]
- iter: List[int]
- bb_eval: List[int]
- psize: List[float]
- output_results(out: OMADS.POLL.Output)[source]
Create a results file from the saved cache
- output_coordinates(out: OMADS.POLL.Output)[source]
Save spinners in a json file
OMADS.SEARCH module
OMADS.MADS module
Module contents
- class OMADS.DType(_prec: str = 'medium', _dtype: numpy.dtype = <class 'numpy.float64'>, _itype: numpy.dtype = <class 'numpy.int64'>, _zero: float = 1e-15, _warned: bool = False)[source]
Bases:
object
A numpy data type delegator for decimal precision control
- Parameters
prec (str, optional) – Default precision option can be set to “high”, “medium” or “low” precision resolution, defaults to “medium”
dtype (np.dtype, optional) – Numpy double data type precision, defaults to np.float64
itype (np.dtype, optional) – Numpy integer data type precision, defaults to np.int
zero (float, optional) – Zero value resolution, defaults to np.finfo(np.float64).resolution
- property zero: float
This is the mantissa value of the machine zero
- Returns
machine precision zero resolution
- Return type
float
- property precision
Set/get precision resolution level
- Returns
float precision value
- Return type
numpy float
- Note
MS Windows does not support precision with the {1e-18} high resolution of the python numerical library (numpy) so high precision will be changed to medium precision which supports {1e-15} resolution check: https://numpy.org/doc/stable/user/basics.types.html
- property dtype
Set/get the double formate type
- Returns
float precision value
- Return type
numpy float
- property itype
Set/Get for the integer formate type
- Returns
integer precision value
- Return type
numpy float
- __init__(_prec: str = 'medium', _dtype: numpy.dtype = <class 'numpy.float64'>, _itype: numpy.dtype = <class 'numpy.int64'>, _zero: float = 1e-15, _warned: bool = False) None
- class OMADS.Options(seed: int = 0, budget: int = 1000, tol: float = 1e-09, psize_init: float = 1.0, display: bool = False, opportunistic: bool = False, check_cache: bool = False, store_cache: bool = False, collect_y: bool = False, rich_direction: bool = False, precision: str = 'high', save_results: bool = False, save_coordinates: bool = False, save_all_best: bool = False, parallel_mode: bool = False, np: int = 1)[source]
Bases:
object
The running study and algorithmic options of OMADS
- Parameters
seed – Random generator seed
budget – The evaluation budget
tol – The threshold of the minimum poll size at which the run will be terminated
psize_init – Initial poll size
dispaly – Print the study progress during the run
opportunistic – Loop on the points populated in the poll set until a better minimum found, then stop the evaluation loop
check_cache – Check the hash table before points evaluation to avoid duplicates
store_cache – Enable storing evaluated points into the hash table
collect_y – Collect dependent design variables (required for DMDO)
rich_direction – Go with the rich direction (Impact the mesh size update)
precision – Define the precision level
save_results – A boolean flag that indicates saving results in a csv file
save_coordinates – A boolean flag that indicates saving coordinates of the poll set in a JSON file (required to generate animations of the spinner)
save_all_best – A boolean used to check whether saving best points only in the MADS.out file
parallel_mode – A boolean to check whether evaluating the poll set in parallel multiprocessing
np – The number of CPUs
- seed: int = 0
- budget: int = 1000
- tol: float = 1e-09
- psize_init: float = 1.0
- display: bool = False
- opportunistic: bool = False
- check_cache: bool = False
- store_cache: bool = False
- collect_y: bool = False
- rich_direction: bool = False
- precision: str = 'high'
- save_results: bool = False
- save_coordinates: bool = False
- save_all_best: bool = False
- parallel_mode: bool = False
- np: int = 1
- __init__(seed: int = 0, budget: int = 1000, tol: float = 1e-09, psize_init: float = 1.0, display: bool = False, opportunistic: bool = False, check_cache: bool = False, store_cache: bool = False, collect_y: bool = False, rich_direction: bool = False, precision: str = 'high', save_results: bool = False, save_coordinates: bool = False, save_all_best: bool = False, parallel_mode: bool = False, np: int = 1) None
- class OMADS.Parameters(baseline: typing.List[float] = <factory>, lb: typing.List[float] = <factory>, ub: typing.List[float] = <factory>, var_names: typing.List[str] = <factory>, scaling: float = 10.0, post_dir: str = '/Users/ahmedb/apps/code/Bay_dev/OMADS/docs-dev/.\\', var_type: typing.Optional[typing.List[str]] = None, var_sets: typing.Optional[typing.Dict] = None, constants: typing.Optional[typing.List] = None, constants_name: typing.Optional[typing.List] = None)[source]
Bases:
object
Variables and algorithmic parameters
- Parameters
baseline – Baseline design point (initial point
x0
)lb – The variables lower bound
ub – The variables upper bound
var_names – The variables name
scaling – Scaling factor (can be defined as a list (assigning a factor for each variable) or a scalar value that will be applied on all variables)
post_dir – The location and name of the post directory where the output results file will live in (if any)
- baseline: List[float]
- lb: List[float]
- ub: List[float]
- var_names: List[str]
- scaling: float = 10.0
- post_dir: str = '/Users/ahmedb/apps/code/Bay_dev/OMADS/docs-dev/.\\'
- var_type: List[str] = None
- var_sets: Dict = None
- constants: List = None
- constants_name: List = None
- __init__(baseline: typing.List[float] = <factory>, lb: typing.List[float] = <factory>, ub: typing.List[float] = <factory>, var_names: typing.List[str] = <factory>, scaling: float = 10.0, post_dir: str = '/Users/ahmedb/apps/code/Bay_dev/OMADS/docs-dev/.\\', var_type: typing.Optional[typing.List[str]] = None, var_sets: typing.Optional[typing.Dict] = None, constants: typing.Optional[typing.List] = None, constants_name: typing.Optional[typing.List] = None) None
- class OMADS.Evaluator(blackbox: typing.Any = 'rosenbrock', commandOptions: typing.Optional[typing.Any] = None, internal: typing.Optional[str] = None, path: str = '..\\tests\\Rosen', input: str = 'input.inp', output: str = 'output.out', constants: typing.Optional[typing.List] = None, bb_eval: int = 0, _dtype: OMADS.POLL.DType = DType(_prec='medium', _dtype=<class 'numpy.float64'>, _itype=<class 'numpy.int64'>, _zero=1e-15, _warned=False), timeout: float = 1000000.0)[source]
Bases:
object
Define the evaluator attributes and settings
- Parameters
blackbox – The blackbox name (it can be a callable function or an executable file)
commandOptions – Define options that will be added to the execution command of the executable file. Command options should be defined as a string in one line
internal – If the blackbox callable function is part of the internal benchmarking library
path – The path of the executable file (if any)
input – The input file name – should include the file extension
output – The output file name – should include the file extension
constants – Define constant parameters list, see the documentation in Tutorials->Blackbox evaluation->User parameters
_dtype – The precision delegator of the numpy library
timeout – The time out of the evaluation process
- blackbox: Any = 'rosenbrock'
- commandOptions: Any = None
- internal: Optional[str] = None
- path: str = '..\\tests\\Rosen'
- input: str = 'input.inp'
- output: str = 'output.out'
- constants: List = None
- bb_eval: int = 0
- timeout: float = 1000000.0
- property dtype
- eval(values: List[float])[source]
Evaluate the poll point
- Parameters
values (List[float]) – Poll point coordinates (design vector)
- Raises
IOError – Incorrect number of input arguments introduced to the callable function
IOError – Incorrect number of input arguments introduced to the callable function
IOError – The blackbox file is not an executable file (if not a callable function)
IOError – Incorrect benchmarking keyword category
- Returns
Evaluated optimization functions
- Return type
List[float, List[float]]
- write_input(values: List[float])[source]
_summary_
- Parameters
values (List[float]) – Write the variables in the input file
- read_output() List[float] [source]
_summary_
- Returns
Read the output values from the output file
- Return type
List[float]
- __init__(blackbox: typing.Any = 'rosenbrock', commandOptions: typing.Optional[typing.Any] = None, internal: typing.Optional[str] = None, path: str = '..\\tests\\Rosen', input: str = 'input.inp', output: str = 'output.out', constants: typing.Optional[typing.List] = None, bb_eval: int = 0, _dtype: OMADS.POLL.DType = DType(_prec='medium', _dtype=<class 'numpy.float64'>, _itype=<class 'numpy.int64'>, _zero=1e-15, _warned=False), timeout: float = 1000000.0) None
- class OMADS.Point(_n: int = 0, _coords: typing.List[float] = <factory>, _defined: typing.List[bool] = <factory>, _evaluated: bool = False, _f: float = inf, _freal: float = inf, _c_ineq: typing.List[float] = <factory>, _c_eq: typing.List[float] = <factory>, _h: float = inf, _signature: int = 0, _dtype: OMADS.POLL.DType = DType(_prec='medium', _dtype=<class 'numpy.float64'>, _itype=<class 'numpy.int64'>, _zero=1e-15, _warned=False), _var_type: typing.Optional[typing.List[int]] = None, _sets: typing.Optional[typing.Dict] = None, _var_link: typing.Optional[typing.List[str]] = None)[source]
Bases:
object
A class for the poll point
- Parameters
_n – # Dimension of the point
_coords – Coordinates of the point
_defined – Coordinates definition boolean
_evaluated – Evaluation boolean
_f – Objective function
_freal – Realistic target value of the objective function
_c_ineq – Inequality constraints
_c_eq – Equality constraints
_h – Aggregated constraints; active set
_signature – hash signature; facilitate looking for duplicates and storing coordinates, hash signature, in the cache memory
_dtype – numpy double data type precision
- property var_link
- property var_type: List[int]
- property sets
- property dtype
- property evaluated
- property signature
- property n_dimensions
- property coordinates
Get the coordinates of the point.
- property defined: List[bool]
- property f
- property freal
- property c_ineq
- property c_eq
- property h
- __init__(_n: int = 0, _coords: typing.List[float] = <factory>, _defined: typing.List[bool] = <factory>, _evaluated: bool = False, _f: float = inf, _freal: float = inf, _c_ineq: typing.List[float] = <factory>, _c_eq: typing.List[float] = <factory>, _h: float = inf, _signature: int = 0, _dtype: OMADS.POLL.DType = DType(_prec='medium', _dtype=<class 'numpy.float64'>, _itype=<class 'numpy.int64'>, _zero=1e-15, _warned=False), _var_type: typing.Optional[typing.List[int]] = None, _sets: typing.Optional[typing.Dict] = None, _var_link: typing.Optional[typing.List[str]] = None) None
- class OMADS.OrthoMesh(_delta: float = -1.0, _Delta: float = -1.0, _rho: float = -1.0, _exp: int = 0, _mantissa: int = 1, psize_max: float = 0.0, psize_success: float = 0.0, _dtype: OMADS.POLL.DType = DType(_prec='medium', _dtype=<class 'numpy.float64'>, _itype=<class 'numpy.int64'>, _zero=1e-15, _warned=False))[source]
Bases:
object
Mesh coarsness update class
- Parameters
_delta – mesh size
_Delta – poll size
_rho – poll size to mesh size ratio
_exp – manage the poll size granularity for discrete variables. See Audet et. al, The mesh adaptive direct search algorithm for granular and discrete variable
_mantissa – Same as
_exp
psize_max – Maximum poll size
psize_success – Poll size at successful evaluation
_dtype – numpy double data type precision
- psize_max: float = 0.0
- psize_success: float = 0.0
- property dtype
- property msize
- property psize
- property rho
- __init__(_delta: float = -1.0, _Delta: float = -1.0, _rho: float = -1.0, _exp: int = 0, _mantissa: int = 1, psize_max: float = 0.0, psize_success: float = 0.0, _dtype: OMADS.POLL.DType = DType(_prec='medium', _dtype=<class 'numpy.float64'>, _itype=<class 'numpy.int64'>, _zero=1e-15, _warned=False)) None
- class OMADS.Cache(_hash_ID: typing.List[int] = <factory>, _cache_dict: typing.Dict[typing.Any, typing.Any] = <factory>)[source]
Bases:
object
In computing, a hash table (hash map) is a data structure that implements an associative array abstract data type, a structure that can map keys to values. A hash table uses a hash function to compute an index, also called a hash code, into an array of buckets or slots, from which the desired value can be found. During lookup, the key is hashed and the resulting hash indicates where the corresponding value is stored.
- property cache_dict: Dict
A getter of the cache memory dictionary
- Return type
Dict
- property hash_id: List[int]
A getter to return the list of hash IDs
- Return type
List[int]
- property size: int
A getter of the size of the hash ID list
- Return type
int
- is_duplicate(x: OMADS.POLL.Point) bool [source]
Check if the point is in the cache memory
- Parameters
x (Point) – Design point
- Returns
A boolean flag indicate whether the point exist in the cache memory
- Return type
bool
- get_index(x: OMADS.POLL.Point) int [source]
Get the index of hash value, associated with the point x, if that point was saved in the cach memory
- Parameters
x (Point) – Input point
- Returns
The index of the point in the hash ID list
- Return type
int
- add_to_cache(x: OMADS.POLL.Point)[source]
Save the point x to the cache memory
- Parameters
x (Point) – Evaluated point to be saved in the cache memory
- __init__(_hash_ID: typing.List[int] = <factory>, _cache_dict: typing.Dict[typing.Any, typing.Any] = <factory>) None
- class OMADS.Dirs2n(_poll_dirs: typing.List[OMADS.POLL.Point] = <factory>, _point_index: typing.List[int] = <factory>, _n: int = 0, _defined: typing.List[bool] = <factory>, scaling: typing.List[typing.List[float]] = <factory>, _xmin: OMADS.POLL.Point = Point(_n=0, _coords=[], _defined=[False], _evaluated=False, _f=inf, _freal=inf, _c_ineq=[], _c_eq=[], _h=inf, _signature=0, _dtype=DType(_prec='medium', _dtype=<class 'numpy.float64'>, _itype=<class 'numpy.int64'>, _zero=1e-15, _warned=False), _var_type=None, _sets=None, _var_link=None), _nb_success: int = 0, _bb_eval: int = <factory>, _psize: float = <factory>, _iter: int = <factory>, hashtable: OMADS.POLL.Cache = <factory>, _check_cache: bool = True, _display: bool = True, _store_cache: bool = True, mesh: OMADS.POLL.OrthoMesh = <factory>, _opportunistic: bool = False, _eval_budget: int = 100, _dtype: OMADS.POLL.DType = DType(_prec='medium', _dtype=<class 'numpy.float64'>, _itype=<class 'numpy.int64'>, _zero=1e-15, _warned=False), bb_handle: OMADS.POLL.Evaluator = <factory>, _success: bool = False, _seed: int = 0, _terminate: bool = False, _bb_output: typing.List[float] = <factory>)[source]
Bases:
object
This is the orthognal 2n-directions class used for the poll step
- Parameters
_poll_dirs – Poll set (list of points)
_point_index – List of point indices
_n – Number of directions
_defined – A boolean that indicate if the poll points are defined
- scaling: List[List[float]]
- hashtable: OMADS.POLL.Cache
- mesh: OMADS.POLL.OrthoMesh
- bb_handle: OMADS.POLL.Evaluator
- property bb_output: List[float]
- property dtype
- property point_index
- property terminate
- property seed
- property success
- property eval_budget
- property opportunistic
- property save_results
- property store_cache
- property check_cache
- property display
- __init__(_poll_dirs: typing.List[OMADS.POLL.Point] = <factory>, _point_index: typing.List[int] = <factory>, _n: int = 0, _defined: typing.List[bool] = <factory>, scaling: typing.List[typing.List[float]] = <factory>, _xmin: OMADS.POLL.Point = Point(_n=0, _coords=[], _defined=[False], _evaluated=False, _f=inf, _freal=inf, _c_ineq=[], _c_eq=[], _h=inf, _signature=0, _dtype=DType(_prec='medium', _dtype=<class 'numpy.float64'>, _itype=<class 'numpy.int64'>, _zero=1e-15, _warned=False), _var_type=None, _sets=None, _var_link=None), _nb_success: int = 0, _bb_eval: int = <factory>, _psize: float = <factory>, _iter: int = <factory>, hashtable: OMADS.POLL.Cache = <factory>, _check_cache: bool = True, _display: bool = True, _store_cache: bool = True, mesh: OMADS.POLL.OrthoMesh = <factory>, _opportunistic: bool = False, _eval_budget: int = 100, _dtype: OMADS.POLL.DType = DType(_prec='medium', _dtype=<class 'numpy.float64'>, _itype=<class 'numpy.int64'>, _zero=1e-15, _warned=False), bb_handle: OMADS.POLL.Evaluator = <factory>, _success: bool = False, _seed: int = 0, _terminate: bool = False, _bb_output: typing.List[float] = <factory>) None
- property bb_eval
- property psize
- property iter
- property poll_dirs
- property dim
- property defined
- property xmin
- property nb_success
- create_housholder(is_rich: bool, domain: Optional[List[int]] = None) numpy.ndarray [source]
Create householder matrix
- Parameters
is_rich (bool) – A flag that indicates if the rich direction option is enabled
- Returns
The householder matrix
- Return type
np.ndarray
- create_poll_set(hhm: numpy.ndarray, ub: List[float], lb: List[float], it: int, var_type: List, var_sets: Dict, var_link: List[str])[source]
Create the poll directions
- Parameters
hhm (np.ndarray) – Householder matrix
ub (List[float]) – Variables upper bound
lb (List[float]) – Variables lower bound
it (int) – iteration
- master_updates(x: List[OMADS.POLL.Point], peval)[source]
- class OMADS.PreMADS(data: Dict[Any, Any])[source]
Bases:
object
Preprocessor for setting up optimization settings and parameters
- __init__(data: Dict[Any, Any]) None
- data: Dict[Any, Any]
- class OMADS.Output(file_path: str, vnames: typing.List[str], field_names: typing.List[str] = <factory>)[source]
Bases:
object
Results output file decorator
- __init__(file_path: str, vnames: typing.List[str], field_names: typing.List[str] = <factory>) None
- file_path: str
- vnames: List[str]
- file_writer: Any
- field_names: List[str]
- class OMADS.PostMADS(x_incumbent: typing.List[OMADS.POLL.Point], xmin: OMADS.POLL.Point, coords: typing.List[typing.List[OMADS.POLL.Point]] = <factory>, poll_dirs: typing.List[OMADS.POLL.Point] = <factory>, iter: typing.List[int] = <factory>, bb_eval: typing.List[int] = <factory>, psize: typing.List[float] = <factory>)[source]
Bases:
object
Results postprocessor
- __init__(x_incumbent: typing.List[OMADS.POLL.Point], xmin: OMADS.POLL.Point, coords: typing.List[typing.List[OMADS.POLL.Point]] = <factory>, poll_dirs: typing.List[OMADS.POLL.Point] = <factory>, iter: typing.List[int] = <factory>, bb_eval: typing.List[int] = <factory>, psize: typing.List[float] = <factory>) None
- x_incumbent: List[OMADS.POLL.Point]
- xmin: OMADS.POLL.Point
- coords: List[List[OMADS.POLL.Point]]
- poll_dirs: List[OMADS.POLL.Point]
- iter: List[int]
- bb_eval: List[int]
- psize: List[float]
- output_results(out: OMADS.POLL.Output)[source]
Create a results file from the saved cache
- output_coordinates(out: OMADS.POLL.Output)[source]
Save spinners in a json file