Package com.illumon.modelfarm
Class ConditionalModels<DATA_TYPE extends FitDataUnderlying,STATE_TYPE>
java.lang.Object
com.illumon.modelfarm.ConditionalModels<DATA_TYPE,STATE_TYPE>
- All Implemented Interfaces:
ModelMultiExec.Models<DATA_TYPE>
public class ConditionalModels<DATA_TYPE extends FitDataUnderlying,STATE_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
Constructors Constructor Description ConditionalModels(Model<DATA_TYPE>[] models, BiPredicate<DATA_TYPE,STATE_TYPE>[] predicates, Map<Long,STATE_TYPE> stateMap)
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<Long,STATE_TYPE> stateMap)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!
-
-
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 extends FitDataUnderlying>
- 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 extends FitDataUnderlying>
- Parameters:
data
- model data- Returns:
- iterator for the models to exec for the model data instance.
-