scipy_optimizer.py

scipy_optimizer.py#

OpenMDAO Wrapper for the scipy.optimize.minimize family of local optimizers.

class openmdao.drivers.scipy_optimizer.ScipyOptimizeDriver(**kwargs)[source]

Bases: Driver

Driver wrapper for the scipy.optimize.minimize family of local optimizers.

Inequality constraints are supported by COBYLA and SLSQP, but equality constraints are only supported by SLSQP. None of the other optimizers support constraints.

ScipyOptimizeDriver supports the following:

equality_constraints inequality_constraints

Parameters:
**kwargsdict of keyword arguments

Keyword arguments that will be mapped into the Driver options.

Attributes:
failbool

Flag that indicates failure of most recent optimization.

iter_countint

Counter for function evaluations.

_scipy_optimize_resultOptimizeResult

Result returned from scipy.optimize call.

opt_settingsdict

Dictionary of solver-specific options. See the scipy.optimize.minimize documentation.

_check_jacbool

Used internally to control when to perform singular checks on computed total derivs.

_con_cachedict

Cached result of constraint evaluations because scipy asks for them in a separate function.

_con_idxdict

Used for constraint bookkeeping in the presence of 2-sided constraints.

_grad_cache{}

Cached result of nonlinear constraint derivatives because scipy asks for them in a separate function.

_obj_and_nlconslist

List of objective + nonlinear constraints. Used to compute total derivatives for all except linear constraints.

_dvlistlist

Copy of _designvars.

_lincongrad_cachenp.ndarray

Pre-calculated gradients of linear constraints.

_desvar_array_cachenp.ndarray

Cached array for setting design variables.

Methods

add_recorder(recorder)

Add a recorder to the driver.

check_relevance()

Check if there are constraints that don't depend on any design vars.

cleanup()

Clean up resources prior to exit.

compute_lagrange_multipliers([...])

Get the approximated Lagrange multipliers of one or more constraints.

declare_coloring([num_full_jacs, tol, ...])

Set options for total deriv coloring.

get_coloring_fname([mode])

Get the filename for the coloring file.

get_constraint_values([ctype, lintype, ...])

Return constraint values.

get_design_var_values([get_remote, ...])

Return the design variable values.

get_driver_derivative_calls()

Return number of derivative evaluations made during a driver run.

get_driver_objective_calls()

Return number of objective evaluations made during a driver run.

get_exit_status()

Return exit status of driver run.

get_objective_values([driver_scaling])

Return objective values.

get_reports_dir()

Get the path to the directory where the report files should go.

record_derivatives()

Record the current total jacobian.

record_iteration()

Record an iteration of the current Driver.

run()

Optimize the problem using selected Scipy optimizer.

scaling_report([outfile, title, ...])

Generate a self-contained html file containing a detailed connection viewer.

set_design_var(name, value[, set_remote])

Set the value of a design variable.

use_fixed_coloring([coloring])

Tell the driver to use a precomputed coloring.

__init__(**kwargs)[source]

Initialize the ScipyOptimizeDriver.

run()[source]

Optimize the problem using selected Scipy optimizer.

Returns:
bool

Failure flag; True if failed to converge, False is successful.

openmdao.drivers.scipy_optimizer.signature_extender(fcn, extra_args)[source]

Closure function, which appends extra arguments to the original function call.

The first argument is the design vector. The possible extra arguments from the callback of scipy.optimize.minimize() are not passed to the function.

Some algorithms take a sequence of NonlinearConstraint as input for the constraints. For this class it is not possible to pass additional arguments. With this function the signature will be correct for both scipy and the driver.

Parameters:
fcncallable

Function, which takes the design vector as the first argument.

extra_argstuple or list

Extra arguments for the function.

Returns:
callable

The function with the signature expected by the driver.