CompositeModel#
- class progpy.CompositeModel(models: list, connections: list = [], **kwargs)#
Bases:
progpy.prognostics_model.PrognosticsModel
New in version 1.5.0.
A CompositeModel is a PrognosticsModel that is composed of multiple PrognosticsModels. This is a tool for modeling system-of-systems. I.e., interconnected systems, where the behavior and state of one system effects the state of another system. The composite prognostics models are connected using defined connections between the output or state of one model, and the input of another model. The resulting CompositeModel behaves as a single model.
- Parameters
models (list[PrognosticsModel or function] or list[tuple[str, PrognosticsModel or function]]) –
A list of PrognosticsModels to be combined into a single model. Provided in one of two forms:
A list of PrognosticsModels or functions. The name of each model will be the class name for models or ‘function’ for functions. A number will be added for duplicates
A list of tuples where the first element is the model/function name and the second element is the model/function
Note: Order provided will be the order that models are executed
connections (list[tuple[str, str]], optional) – A list of tuples where the first element is the name of the output, state, or performance metrics of one model or function return and the second element is the name of the input of another model or argument of a function. The first element of the tuple must be of the form “model_name.output_name”, “model_name.state_name”, or “model_name.performance_metric_key”. The second element of the tuple must be of the form “model_name.input_name”. For example, if you have two models, “Batt1” and “Batt2”, and you want to connect the output of “Batt1” to the input of “Batt2”, you would use the following connection: (“Batt1.output”, “Batt2.input”)
- Keyword Arguments
outputs (list[str]) – Model outputs in format “model_name.output_name”. Must be subset of all outputs from models. If not provided, all outputs will be included.
Example
>>> m = SomeModel() >>> m2 = SomeOtherModel() >>> def kelvin_to_celcius(temp_in_kelvin): >>> return temp_in_kelvin - 273.15 >>> connections = [ >>> ('m1.temp', 'kelvin_to_celcius.temp_in_kelvin') >>> ('kelvin_to_celcius.return', 'm2.temp') >>> ] >>> m_composite = CompositeModel( >>> (('m1', m), ('kelvin_to_celcius', kelvin_to_celcius), ('m2', m2)), # models >>> connections=connections >>> )
Note
Model parameters can be set and accessed using the ‘[model].[param]’ format. For example, for composite model m, m[‘foo.bar’] would set the parameter ‘bar’ for the model ‘foo’.