pyoptsparse_driver.py

pyoptsparse_driver.py#

OpenMDAO Wrapper for pyoptsparse.

pyoptsparse is based on pyOpt, which is an object-oriented framework for formulating and solving nonlinear constrained optimization problems, with additional MPI capability.

exception openmdao.drivers.pyoptsparse_driver.UserRequestedException[source]

Bases: Exception

User Requested Exception.

This exception indicates that the user has requested that SNOPT/pyoptsparse ceases model execution and reports to SNOPT that execution should be terminated.

class openmdao.drivers.pyoptsparse_driver.pyOptSparseDriver(**kwargs)[source]

Bases: Driver

Driver wrapper for pyoptsparse.

Pyoptsparse is based on pyOpt, which is an object-oriented framework for formulating and solving nonlinear constrained optimization problems, with additional MPI capability. pypptsparse has interfaces to the following optimizers: ALPSO, CONMIN, FSQP, IPOPT, NLPQLP, NSGA2, PSQP, SLSQP, SNOPT, NLPY_AUGLAG, NOMAD, ParOpt. Note that some of these are not open source and therefore not included in the pyoptsparse source code.

pyOptSparseDriver supports the following:

equality_constraints

inequality_constraints

two_sided_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.

opt_settingsdict

Dictionary for setting optimizer-specific options.

pyopt_solutionSolution

Pyopt_sparse solution object.

_fill_NANsbool

Used internally to control when to return NANs for a bad evaluation.

_check_jacbool

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

_in_user_function :bool

This is set to True at the start of a pyoptsparse callback to _objfunc and _gradfunc, and restored to False at the finish of each callback.

_nl_responseslist

Contains the objectives plus nonlinear constraints.

_signal_cache<Function>

Cached function pointer that was assigned as handler for signal defined in option user_terminate_signal.

_total_jac_sparsitydict, str, or None

Specifies sparsity of sub-jacobians of the total jacobian.

_user_termination_flagbool

This is set to True when the user sends a signal to terminate the job.

_model_ranbool

This is set to True after the full model has been run at least once.

_Optimization: class

The pyoptsparse Optimization class, lazily imported.

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()

Excute pyOptsparse.

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 pyopt.

property hist_file

Get the ‘hist_file’ option for this driver.

property hotstart_file

Get the ‘hotstart_file’ option for this driver.

run()[source]

Excute pyOptsparse.

Note that pyOpt controls the execution, and the individual optimizers (e.g., SNOPT) control the iteration.

Returns:
bool

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