Package io.deephaven.modelfarm
Class ConditionalModels<DATA_TYPE,STATE_TYPE,KEY_TYPE>
java.lang.Object
io.deephaven.modelfarm.ConditionalModels<DATA_TYPE,STATE_TYPE,KEY_TYPE>
- All Implemented Interfaces:
ModelMultiExec.Models<DATA_TYPE>
public class ConditionalModels<DATA_TYPE,STATE_TYPE,KEY_TYPE>
extends Object
implements ModelMultiExec.Models<DATA_TYPE>
A set of multiple models where predicates determine which of the models execute on any iteration. The predicates use
input data and the most recent state for an underlying to determine which models should execute on an iteration. For
example, the state could be the most recent valid result from a numerical model.
Active models are executed in their input order.
-
Constructor Summary
ConstructorDescriptionConditionalModels
(Model<DATA_TYPE>[] models, BiPredicate<DATA_TYPE, STATE_TYPE>[] predicates, Map<KEY_TYPE, STATE_TYPE> stateMap, Function<DATA_TYPE, KEY_TYPE> dataToKey) Creates a new set of conditionally active models. -
Method Summary
-
Constructor Details
-
ConditionalModels
public ConditionalModels(Model<DATA_TYPE>[] models, BiPredicate<DATA_TYPE, STATE_TYPE>[] predicates, Map<KEY_TYPE, STATE_TYPE> stateMap, Function<DATA_TYPE, KEY_TYPE> dataToKey) Creates a new set of conditionally active models.Active models are executed in their input order.
- Parameters:
models
- models to execute.predicates
- predicates used to determine if each model should execute.stateMap
- map of state by underlying id. THIS MAP SHOULD BE THREAD SAFE, OR RESULTS WILL BE UNPREDICTABLE!dataToKey
- function to get a key from data.
-
-
Method Details
-
getLock
Description copied from interface:ModelMultiExec.Models
Gets the synchronization lock to hold while executing the models in the iterator.- Specified by:
getLock
in interfaceModelMultiExec.Models<DATA_TYPE>
- Parameters:
data
- model data- Returns:
- synchronization lock to hold while executing the models in the iterator.
-
iterator
Description copied from interface:ModelMultiExec.Models
Creates an iterator for the models to exec for the model data instance.- Specified by:
iterator
in interfaceModelMultiExec.Models<DATA_TYPE>
- Parameters:
data
- model data- Returns:
- iterator for the models to exec for the model data instance.
-