Class PooledScoreWrapper
java.lang.Object
edu.cmu.tetrad.algcomparison.utils.PooledScoreWrapper
- All Implemented Interfaces:
ScoreWrapper, HasParameters, TetradSerializable, Serializable
A score wrapper that pools several data sets into one IMaGES score built from an inner score wrapper. This is how
"IMaGES" becomes a property of the score rather than a separate algorithm: any score-based algorithm that extends
AbstractBootstrapAlgorithm, when handed a DataModelList, has its score wrapper replaced by one of
these for the duration of the search, so BOSS + SEM-BIC on a list of data sets IS IMaGES-BOSS, and BOSS + BF-BIC is
IMaGES with the basis-function score, with no separate wrapper class per combination.
The data model passed to getScore(DataModel, Parameters) is ignored; the pooled score is built over the data sets registered for
the calling thread (set by the bootstrap loop for each replicate) or, failing that, the default list given at
construction. Inner wrappers implementing MultiDataSetScoreWrapper are asked for a coordinated list of
scores so that data-dependent representation choices are shared across data sets; other wrappers are called once
per data set.
Instances are transient: they exist only during a search and are never serialized as the algorithm's score.
- Author:
- josephramsey
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionPooledScoreWrapper(ScoreWrapper inner, List<DataModel> defaultDataSets) Constructs a pooled score wrapper. -
Method Summary
Modifier and TypeMethodDescriptionThe data sets being pooled for the calling thread: those registered bysetThreadDataSets(List), or the default list if none are registered.Returns the data type the inner score wrapper accepts; pooling does not change it.Returns a description of the pooled score, formed by prefixing the inner wrapper's description with "Pooled (IMaGES)".getInner()Returns the score wrapper that is built on each pooled data set.Returns the names of the parameters the inner score wrapper uses.getScore(DataModel ignored, Parameters parameters) Builds one score per pooled data set and combines them into anImagesScore, which sums the local scores across data sets.getVariable(String name) Returns the variable with the given name.voidsetThreadDataSets(List<DataModel> dataSets) Registers the data sets to pool for scores subsequently built on the calling thread, overriding the default list.
-
Constructor Details
-
PooledScoreWrapper
Constructs a pooled score wrapper.- Parameters:
inner- the score wrapper used to build one score per pooled data set; if it implementsMultiDataSetScoreWrapper, its coordinated multi-data-set method is used instead.defaultDataSets- the data sets pooled when none have been registered for the calling thread viasetThreadDataSets(List); a defensive copy is kept. All pooled data sets must have the same variables by name.- Throws:
NullPointerException- ifinneris null.IllegalArgumentException- ifdefaultDataSetsis null or empty.
-
-
Method Details
-
getScore
Builds one score per pooled data set and combines them into anImagesScore, which sums the local scores across data sets. The data sets used are those registered for the calling thread bysetThreadDataSets(List), or the default list given at construction if none are registered.- Specified by:
getScorein interfaceScoreWrapper- Parameters:
ignored- ignored; the pooled data sets are used instead of this argument.parameters- the parameters, passed through to the inner wrapper for every data set.- Returns:
- the pooled IMaGES score.
-
setThreadDataSets
Registers the data sets to pool for scores subsequently built on the calling thread, overriding the default list. The registration is thread-local, so concurrent searches (e.g., bootstrap replicates run in parallel) can each pool their own resampled data sets through a single shared wrapper. Pass null to clear the registration and revert to the default list.- Parameters:
dataSets- the data sets to pool on this thread, or null to clear.
-
getDataSets
The data sets being pooled for the calling thread: those registered bysetThreadDataSets(List), or the default list if none are registered. For an algorithm whose search has a stage that works from the data directly rather than through the score, so that it can run that stage over the same data sets.- Returns:
- the data sets, as an unmodifiable list
-
getInner
Returns the score wrapper that is built on each pooled data set.- Returns:
- the inner score wrapper.
-
getDescription
Returns a description of the pooled score, formed by prefixing the inner wrapper's description with "Pooled (IMaGES)".- Specified by:
getDescriptionin interfaceScoreWrapper- Returns:
- the description.
-
getDataType
Returns the data type the inner score wrapper accepts; pooling does not change it.- Specified by:
getDataTypein interfaceScoreWrapper- Returns:
- the data type of the inner score wrapper.
-
getParameters
Returns the names of the parameters the inner score wrapper uses. Pooling itself adds no parameters.- Specified by:
getParametersin interfaceHasParameters- Specified by:
getParametersin interfaceScoreWrapper- Returns:
- the parameter names of the inner score wrapper.
-
getVariable
Returns the variable with the given name. The inner wrapper is consulted first, since it records the last data set it built a score for; if that yields nothing, the first pooled data set is used, whose variables are shared by name across all pooled data sets.- Specified by:
getVariablein interfaceScoreWrapper- Parameters:
name- the variable name.- Returns:
- the variable, or null if no pooled data set has a variable of that name.
-