SimulatorBase
csdl.core.simulator_base
#
_ReprClass Objectsclass _ReprClass(object)
Class for defining objects with a simple constant string repr.
This is useful for constants used in arg lists when you want them to appear in automatically generated source documentation as a certain string instead of python's default representation.
#
__init__def __init__(repr_string)
Inititialize the repr string.
Parameters
repr_string : str The string to be returned by repr
#
__repr__def __repr__()
Return our _repr_string.
Returns
str Whatever string we were initialized with.
#
SimulatorBase Objectsclass SimulatorBase()
A class that can be used as a base class for the Simulator
class
that a CSDL compiler back end would provide.
This class is only here so that CSDL users and CSDL compiler back end
developers have API documentation.
CSDL users are not to use the SimulatorBase
class provided by
csdl
, only the Simulator
class provided by the CSDL compiler
back end of choice.
#
__init__def __init__(model, reorder=False)
Constructor.
#
__getitem__def __getitem__(key) -> np.ndarray
Method to get variable values before or after a simulation run
#
__setitem__def __setitem__(key, val)
Method to set values for variables by name
#
rundef run()
Method to run a simulation once. This method should be implemented so that it can be called repeatedly to solve an optimization problem.
#
compute_total_derivativesdef compute_total_derivatives(return_format='array') -> Union[OrderedDict, np.ndarray]
Method to compute total derivatives (objective gradient and constraint jacobian)
Returns
Union[OrderedDict, np.ndarray]`
#
compute_exact_hessiandef compute_exact_hessian()
Method to compute exact Hessian
#
check_partialsdef check_partials()
Method to compute the error for all partial derivatives of all operations within the model.
Returns
An object that is compatible with assert_check_partials
#
assert_check_partialsdef assert_check_partials(result, atol=1e-8, rtol=1e-8)
Method to check that the partial derivatives of all operations are within a specified tolerance.
Parameters
result
: Return type of check_partials
#
visualize_implementationdef visualize_implementation()
A method for the back end to provide its own visualization of the model.
#
get_design_variable_metadatadef get_design_variable_metadata() -> dict
Method to get design variable metadata that an optimizer needs to define an optimization problem
Returns
`dict`
#
get_constraints_metadatadef get_constraints_metadata() -> OrderedDict
Method to get constraint metadata that an optimizer needs to define an optimization problem
Returns
`OrderedDict`
#
update_design_variablesdef update_design_variables(x: np.ndarray, input_format='array')
Method for external optimizer to update design variable values
#
design_variablesdef design_variables(return_format='array') -> Union[OrderedDict, np.ndarray]
Method to provide optimizer with design variables Returns
`Union[OrderedDict, np.ndarray]`
#
objectivedef objective() -> float
Method to provide optimizer with objective
#
constraintsdef constraints(return_format='array') -> Union[OrderedDict, np.ndarray]
Method to provide optimizer with constraints
Returns
`Union[OrderedDict, np.ndarray]`
#
implicit_outputsdef implicit_outputs()
Method to provide optimizer with implicit_outputs
#
residualsdef residuals() -> Union[OrderedDict, np.ndarray]
Method to provide optimizer with residuals
#
objective_gradientdef objective_gradient() -> Union[OrderedDict, np.ndarray]
Method to provide optimizer with total derivative of objective
with respect to design variables; does not compute derivatives;
must call Simulator.compute_total_derivatives
to compute
derivatives
Returns
`Union[OrderedDict, np.ndarray]`
#
constraint_jacobiandef constraint_jacobian() -> Union[OrderedDict, np.ndarray]
Method to provide optimizer with total derivative of constraints
with respect to design variables; does not compute derivatives;
must call Simulator.compute_total_derivatives
to compute
derivatives
Returns
`Union[OrderedDict, np.ndarray]`
#
residuals_jacobiandef residuals_jacobian() -> Union[OrderedDict, np.ndarray]
Method to provide optimizer with total derivatives of residuals with respect to design variables