driver.py¶
Base class for Driver.
-
class
openmdao.core.driver.
Driver
[source]¶ Bases:
object
Base class for drivers in OpenMDAO. Drivers can only be placed in a Problem, and every problem has a Driver. Driver is the simplest driver that runs (solves using solve_nonlinear) a problem once.
-
add_constraint
(name, ctype='ineq', linear=False, jacs=None, indices=None, adder=0.0, scaler=1.0)[source]¶ Adds a constraint to this driver.
Args: name : string
Promoted pathname of the output that will serve as the objective.
ctype : string
Set to ‘ineq’ for inequality constraints, or ‘eq’ for equality constraints. Make sure your driver supports the ctype of constraint that you are adding.
linear : bool, optional
Set to True if this constraint is linear with respect to all params so that it can be calculated once and cached.
jacs : dict of functions, optional
Dictionary of user-defined functions that return the flattened Jacobian of this constraint with repsect to the params of this driver, as indicated by the dictionary keys. Default is None to let OpenMDAO calculate all derivatives. Note, this is currently unsupported
indices : iter of int, optional
If a constraint is an array, these indicate which entries are of interest for derivatives.
adder : float or ndarray, optional
Value to add to the model value to get the scaled value. Adder is first in precedence.
scaler : float or ndarray, optional
value to multiply the model value to get the scaled value. Scaler is second in precedence.
-
add_objective
(name, indices=None, adder=0.0, scaler=1.0)[source]¶ Adds an objective to this driver.
Args: name : string
Promoted pathname of the output that will serve as the objective.
indices : iter of int, optional
If an objective is an array, these indicate which entries are of interest for derivatives.
adder : float or ndarray, optional
Value to add to the model value to get the scaled value. Adder is first in precedence.
scaler : float or ndarray, optional
value to multiply the model value to get the scaled value. Scaler is second in precedence.
-
add_param
(name, low=None, high=None, indices=None, adder=0.0, scaler=1.0)[source]¶ Adds a parameter to this driver.
Args: name : string
Name of the paramcomp in the root system.
low : float or ndarray, optional
Lower boundary for the param
high : upper or ndarray, optional
Lower boundary for the param
indices : iter of int, optional
If a param is an array, these indicate which entries are of interest for derivatives.
adder : float or ndarray, optional
Value to add to the model value to get the scaled value. Adder is first in precedence.
scaler : float or ndarray, optional
value to multiply the model value to get the scaled value. Scaler is second in precedence.
-
add_recorder
(recorder)[source]¶ Adds a recorder to the driver.
Args: recorder : BaseRecorder
A recorder instance.
-
get_constraint_metadata
()[source]¶ Returns a dict of constraint metadata.
Returns: dict
Keys are the constraint object names, and the values are the param values.
-
get_constraints
(ctype='all', lintype='all')[source]¶ Gets all constraints for this driver.
Args: ctype : string
Default is ‘all’. Optionally return just the inequality constraints with ‘ineq’ or the equality constraints with ‘eq’.
lintype : string
Default is ‘all’. Optionally return just the linear constraints with ‘linear’ or the nonlinear constraints with ‘nonlinear’.
Returns: dict
Key is the constraint name string, value is an ndarray with the values.
-
get_objectives
(return_type='dict')[source]¶ Gets all objectives of this driver.
Args: return_type : string
Set to ‘dict’ to return a dictionary, or set to ‘array’ to return a flat ndarray.
Returns: dict (for return_type ‘dict’)
Key is the objective name string, value is an ndarray with the values.
ndarray (for return_type ‘array’)
Array containing all objective values in the order they were added.
-
get_param_metadata
()[source]¶ Returns a dict of parameter metadata.
Returns: dict
Keys are the param object names, and the values are the param values.
-
get_params
()[source]¶ Returns a dict of parameters.
Returns: dict
Keys are the param object names, and the values are the param values.
-
outputs_of_interest
()[source]¶ Returns: list of tuples of str
The list of constraints and objectives, organized into tuples according to previously defined VOI groups.
-
parallel_derivs
(vnames)[source]¶ Specifies that the named variables of interest are to be grouped together so that their derivatives can be solved for concurrently.
Args: vnames : iter of str
The names of variables of interest that are to be grouped.
-
params_of_interest
()[source]¶ Returns: list of tuples of str
The list of params, organized into tuples according to previously defined VOI groups.
-