p3j.experiment.results
Class AbstractAggregationSelector

java.lang.Object
  extended by p3j.experiment.results.AbstractAggregationSelector
All Implemented Interfaces:
IAggregationSelector
Direct Known Subclasses:
ChooseAgesForSingleYearSelector, SumOverAgesSelector, YearlyAgeTrialMatrixSelector

public abstract class AbstractAggregationSelector
extends Object
implements IAggregationSelector

An abstract class containing functionality all aggregation selectors may share. The basic idea here is that, for the given structure in ResultsOfTrial, aggregation is essentially a three-step process: 1) Select the sub-population and generation of interest: this means to select a BasicResults object from the lists in ResultsOfTrial. 2) Select the variable of interest from the BasicResults object, i.e. which aspect of the given sub-population's results are of interest (e.g. the year-end numbers of males). The result of this selection is a matrix. 3) The actual aggregation of the matrices to some result; this is the only aspect that cannot be re-used and has to be implemented for any kind of aggregation.

Author:
Christina Bohk, Roland Ewald
See Also:
BasicResults, ResultsOfTrial

Field Summary
protected  double[][] aggregation
          The aggregated data.
 
Constructor Summary
AbstractAggregationSelector(p3j.experiment.results.IOutputVariableSelector resultsSelector, p3j.experiment.results.ISubPopulationSelector trialSelector, int generationForSelection)
          Instantiates a new abstract aggregation selector.
 
Method Summary
protected  double[][] cutOffUnused(double[][] aggregatedData, int numOfLines)
          Cuts off unused lines in data.
protected static AbstractAggregationSelector[] getCopy(AbstractAggregationSelector[] selArray)
          Gets a copy of an array.
protected  String getFileName()
          Gets the file name.
protected  double[][] reorderResults(List<Integer> indexOrdering, double[][] orderedResults)
          Reorders results according to list of indices.
protected  Matrix2D select(ResultsOfTrial resultsOfTrial)
          Select the result of interest.
protected  double[] sumPerElement(List<double[]> additionArrays, List<double[]> subtractionArrays)
          Sum to array by element-wise adding all array in the first list to one another, and then subtracting all arrays in the second list.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface p3j.experiment.results.IAggregationSelector
consider, finish, init
 

Field Detail

aggregation

protected double[][] aggregation
The aggregated data.

Constructor Detail

AbstractAggregationSelector

public AbstractAggregationSelector(p3j.experiment.results.IOutputVariableSelector resultsSelector,
                                   p3j.experiment.results.ISubPopulationSelector trialSelector,
                                   int generationForSelection)
Instantiates a new abstract aggregation selector.

Parameters:
resultsSelector - the results selector
trialSelector - the trial selector
generationForSelection - the generation for selection
Method Detail

select

protected Matrix2D select(ResultsOfTrial resultsOfTrial)
Select the result of interest.

Parameters:
resultsOfTrial - the results of trial
Returns:
the matrix2 d

getFileName

protected String getFileName()
Gets the file name.

Returns:
the file name

reorderResults

protected double[][] reorderResults(List<Integer> indexOrdering,
                                    double[][] orderedResults)
Reorders results according to list of indices.

Parameters:
indexOrdering - the index ordering
orderedResults - the ordered results
Returns:
the reordered results

cutOffUnused

protected double[][] cutOffUnused(double[][] aggregatedData,
                                  int numOfLines)
Cuts off unused lines in data. This is necessary for any conditional results, i.e. where not all trial results are considered.

Parameters:
aggregatedData - the aggregation
numOfLines - the size
Returns:
the trimmed results

getCopy

protected static AbstractAggregationSelector[] getCopy(AbstractAggregationSelector[] selArray)
Gets a copy of an array.

Parameters:
selArray - the array of selectors
Returns:
the copy of the array

sumPerElement

protected double[] sumPerElement(List<double[]> additionArrays,
                                 List<double[]> subtractionArrays)
Sum to array by element-wise adding all array in the first list to one another, and then subtracting all arrays in the second list.

Parameters:
additionArrays - the addition arrays
subtractionArrays - the subtraction arrays
Returns:
the double[]


Copyright © 2012. All Rights Reserved.