pymoto.OC
- class pymoto.OC(variables: Signal | Iterable[Signal], response: Signal, function: Network, slice_network=False, move=0.1, xmin=0.0, xmax=1.0, verbosity: int = 2, l1init: float = 0.0, l2init: float = 100000.0, l1l2tol: float = 0.0001, maxvol: float = None)
- __init__(variables: Signal | Iterable[Signal], response: Signal, function: Network, slice_network=False, move=0.1, xmin=0.0, xmax=1.0, verbosity: int = 2, l1init: float = 0.0, l2init: float = 100000.0, l1l2tol: float = 0.0001, maxvol: float = None)
Optimality criteria optimization algorithm
- Parameters:
variables – One or more variable Signals defining the design variables
response – Response signal to be minimized (objective)
function – The Network defining the optimization problem
- Keyword Arguments:
slice_network (bool) – If True, only the modules connecting variable and response signals are evaluated. Defaults to False.
move – Move limit on relative variable change per iteration (can be passed as scalar: same value for all variables, vector: each variable has a unique value, list of scalars/vectors: for each variable signal). Defaults to 0.1.
xmin – Minimum design variable (can be passed as scalar: same value for all variables, vector: each variable has a unique value, list of scalars/vectors: for each variable signal). Defaults to 0.0.
xmax – Maximum design variable (can be passed as scalar: same value for all variables, vector: each variable has a unique value, list of scalars/vectors: for each variable signal). Defaults to 1.0.
verbosity (int) – Level of information to print. Defaults to 2. 0 - No prints 1 - Only convergence message 2 - Convergence and iteration info (default) 3 - Additional info on variables and GCMMA inner iteration info (when applicable) 4 - Additional info on sensitivity information
l1init (int) – Internal OC parameter. Defaults to 0.
l2init (int) – Internal OC parameter. Defaults to 100000.
l1l2tol (float) – Internal OC parameter. Defaults to 1e-4.
maxvol (float) – Volume fraction. Defaults to None.
Methods
__init__(variables, response, function[, ...])Optimality criteria optimization algorithm
Calculate Jacobian dg/dx
Calculate function response g(x)
optimize([maxiter, tolx, tolf, evaluate_last])Perform a gradient-based optimization
print_iteration_info(g[, ...])Print iteration information
print_variable_info([dg])Print information on variables (and sensitivities)
step(x, g, dg)Performs a single optimization step
Attributes
Set current design variable vector
- step(x: ndarray = None, g: ndarray = None, dg: ndarray = None) -> (<class 'numpy.ndarray'>, <class 'numpy.ndarray'>, <class 'numpy.ndarray'>)
Performs a single optimization step
- Parameters:
x (np.ndarray, optional) – The design vector to evaluate. When not provided, use information set in state
g (np.ndarray, optional) – The function values to use. When not provided, will be calculated on demand
dg (np.ndarray, optional) – The sensitivity values to use. When not provided, will be calculated on demand
- Returns:
New design vector g: (Evaluated) response values dg: (Evaluated) design sensitivities
- Return type:
xnew
- calculate_dg()
Calculate Jacobian dg/dx
- calculate_g()
Calculate function response g(x)
- optimize(maxiter: int = 100, tolx: float = 0.0001, tolf: float = 0.0001, evaluate_last: bool = False)
Perform a gradient-based optimization
- Parameters:
maxiter (int, optional) – Maximum number of iteration. Defaults to 100.
tolx (float, optional) – Stopping criterium for relative design change. Defaults to 1e-4.
tolf (float, optional) – Stopping criterium for relative objective change. Defaults to 1e-4.
- print_iteration_info(g: ndarray, report_feasibility: bool = False, xold: ndarray = None, xnew: ndarray = None)
Print iteration information
- Parameters:
g (np.ndarray) – Response values
report_feasibility (bool, optional) – Print # violated constraints and worst value. Defaults to False.
xold (np.ndarray, optional) – If provided, shows information on design change. Defaults to None.
xnew (np.ndarray, optional) – If provided, shows information on design change. Defaults to None.
- print_variable_info(dg: ndarray = None)
Print information on variables (and sensitivities)
- Parameters:
dg (np.ndarray, optional) – If provided, information on sensitivities will also be printed. Defaults to None.
- property x
Set current design variable vector