Class SearchTask
- java.lang.Object
-
- pulse.util.UpwardsNavigable
-
- pulse.util.Group
-
- pulse.util.Accessible
-
- pulse.search.GeneralTask
-
- pulse.tasks.SearchTask
-
- All Implemented Interfaces:
Serializable,Runnable,Descriptive
public class SearchTask extends GeneralTask
ASearchTaskis the most important class inPULsE. It combines access to all other bits and can be executed by theTaskManager. The execution consists in solving the reverse problem of heat conduction, which is done using thePathSolver. ASearchTaskhas an associatedExperimentalDataobject linked to it.- See Also:
TaskManager, Serialized Form
-
-
Constructor Summary
Constructors Constructor Description SearchTask(ExperimentalData curve)Creates a newSearchTaskfromcurve.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description List<NumericPropertyKeyword>activeParameters()Finds what properties are being altered in the search of this SearchTask.voidaddStatusChangeListener(StatusChangeListener toAdd)voidaddTaskListener(DataCollectionListener toAdd)List<NumericProperty>alteredParameters()voidassign(ParameterVector searchParameters)Assigns the values of the parameters of thisSearchTasktosearchParameters.voidcheckProblems()Checks if thisSearchTaskis ready to be run.Performs basic check to see whether the user has uploaded all necessary data.voidclear()Resets everything to default values (for a list of default values please see the.xmldocument.Stringdescribe()Uses the SearchTask id (if present) to describe this UpwardsNavigable.booleanequals(Object o)ASearchTaskis deemed equal to another one if it has the sameExperimentalData.CalculationfindBestCalculation()Finds the best calculation by comparing those already stored by their model selection statistics.CorrelationBuffergetCorrelationBuffer()CorrelationTestgetCorrelationTest()IdentifiergetIdentifier()ExperimentalDatagetInput()LoggetLog()NormalityTestgetNormalityTest()CalculationgetResponse()StatusgetStatus()List<Calculation>getStoredCalculations()voidinitCorrelationTest()voidinitListeners()voidinitNormalityTest()voidintermediateProcessing()Override this to add intermediate processing of results e.g.booleanisInProgress()voidonSolverException(SolverException e)Specifies what should be done when a solver exception is encountered.voidpostProcessing()Override this to add post-processing checks e.g.voidremoveStatusChangeListeners()voidremoveTaskListeners()voidrun()Runs this task if is eitherREADYorQUEUED.ParameterVectorsearchVector()Generates a search vector (= optimisation vector) using the search flags set by thePathSolver.voidset(NumericPropertyKeyword type, NumericProperty property)An abstract method, which must be overriden to gain access over setting the values of all relevant (selected by the programmer)NumericProperties in subclasses ofAccessible.voidsetExperimentalCurve(ExperimentalData curve)Adopts thecurveby thisSearchTask.booleansetStatus(Status status)Will returntrueif status could be updated.voidstoreCalculation()voidswitchTo(Calculation calc)voidswitchToBestModel()voidterminate()If the current task is eitherIN_PROGRESS,QUEUED, orREADY, terminates it by setting its status toTERMINATED.StringtoString()-
Methods inherited from class pulse.search.GeneralTask
getBestState, getBuffer, getIterativeState, objectiveFunction, setDefaultOptimiser, setIterativeState, setOptimiser, storeState
-
Methods inherited from class pulse.util.Accessible
accessibleChildren, genericProperties, genericProperty, numericProperties, numericProperty, property, update, update
-
Methods inherited from class pulse.util.Group
access, children, contents, getDescriptor, getSimpleName, subgroups
-
Methods inherited from class pulse.util.UpwardsNavigable
addHierarchyListener, getHierarchyListeners, getParent, identify, removeHierarchyListener, removeHierarchyListeners, setParent, specificAncestor, tellParent
-
-
-
-
Constructor Detail
-
SearchTask
public SearchTask(ExperimentalData curve)
Creates a new
SearchTaskfromcurve. Generates a newIdentifier, sets the parent ofcurvetothis, and invokes clear(). If any changes to theExperimentalDataoccur, a listener will ensure theDifferenceSchemeis modified accordingly.- Parameters:
curve- theExperimentalData
-
-
Method Detail
-
initListeners
public void initListeners()
- Overrides:
initListenersin classUpwardsNavigable
-
clear
public void clear()
Resets everything to default values (for a list of default values please see the
.xmldocument. Sets the status of this task toINCOMPLETE. curve.addDataListener(dataEvent -> { var scheme = current.getScheme(); if (scheme != null) { var curve = current.getProblem().getHeatingCurve(); var startTime = (double) curve.getTimeShift().getValue(); scheme.setTimeLimit(derive(TIME_LIMIT, RELATIVE_TIME_MARGIN * curve.timeLimit() - startTime)); } });
-
alteredParameters
public List<NumericProperty> alteredParameters()
-
addTaskListener
public void addTaskListener(DataCollectionListener toAdd)
-
addStatusChangeListener
public void addStatusChangeListener(StatusChangeListener toAdd)
-
removeTaskListeners
public void removeTaskListeners()
-
removeStatusChangeListeners
public void removeStatusChangeListeners()
-
setExperimentalCurve
public void setExperimentalCurve(ExperimentalData curve)
Adopts thecurveby thisSearchTask.- Parameters:
curve- theExperimentalData.
-
checkProblems
public void checkProblems()
Checks if this
Status will be set toSearchTaskis ready to be run.Performs basic check to see whether the user has uploaded all necessary data. If not, will create a status update with information about the missing data.READYif the task is ready to be run,DONEif has already been done previously,INCOMPLETEif some problems exist. For the latter, additional details will be available using thestatus.getDetails()method.
-
getIdentifier
public Identifier getIdentifier()
-
getLog
public Log getLog()
-
run
public void run()
Description copied from class:GeneralTaskRuns this task if is either
READYorQUEUED. Otherwise, will do nothing. After making some preparatory steps, will initiate a loop with successive calls toPathSolver.iteration(this), filling the buffer and notifying any data change listeners in parallel. This loop will go on until either converging results are obtained, or a timeout is reached, or if an execution error happens. Whether the run has been successful will be determined by comparing the associated R2 value with theSUCCESS_CUTOFF.- Specified by:
runin interfaceRunnable- Overrides:
runin classGeneralTask
-
terminate
public void terminate()
If the current task is eitherIN_PROGRESS,QUEUED, orREADY, terminates it by setting its status toTERMINATED. This change of status will then force therun()loop to stop (if running).
-
getNormalityTest
public NormalityTest getNormalityTest()
-
initNormalityTest
public void initNormalityTest()
-
initCorrelationTest
public void initCorrelationTest()
-
getCorrelationBuffer
public CorrelationBuffer getCorrelationBuffer()
-
getCorrelationTest
public CorrelationTest getCorrelationTest()
-
getStoredCalculations
public List<Calculation> getStoredCalculations()
-
storeCalculation
public void storeCalculation()
-
switchTo
public void switchTo(Calculation calc)
-
findBestCalculation
public Calculation findBestCalculation()
Finds the best calculation by comparing those already stored by their model selection statistics.- Returns:
- the calculation showing the optimal value of the model selection statistic.
-
switchToBestModel
public void switchToBestModel()
-
isInProgress
public boolean isInProgress()
- Specified by:
isInProgressin classGeneralTask
-
intermediateProcessing
public void intermediateProcessing()
Description copied from class:GeneralTaskOverride this to add intermediate processing of results e.g. with a correlation test.- Overrides:
intermediateProcessingin classGeneralTask
-
onSolverException
public void onSolverException(SolverException e)
Description copied from class:GeneralTaskSpecifies what should be done when a solver exception is encountered. Empty by default- Overrides:
onSolverExceptionin classGeneralTask- Parameters:
e- a solver exception
-
searchVector
public ParameterVector searchVector()
Generates a search vector (= optimisation vector) using the search flags set by thePathSolver.- Specified by:
searchVectorin classGeneralTask- Returns:
- an
IndexedVectorwith search parameters of thisSearchTaks
-
assign
public void assign(ParameterVector searchParameters) throws SolverException
Assigns the values of the parameters of thisSearchTasktosearchParameters.- Specified by:
assignin classGeneralTask- Parameters:
searchParameters- anIndexedVectorwith relevant search parameters- Throws:
SolverException
-
postProcessing
public void postProcessing()
Description copied from class:GeneralTaskOverride this to add post-processing checks e.g. normality tests or range checking.- Overrides:
postProcessingin classGeneralTask
-
activeParameters
public List<NumericPropertyKeyword> activeParameters()
Finds what properties are being altered in the search of this SearchTask.- Specified by:
activeParametersin classGeneralTask- Returns:
- a
Listof property types represented byNumericPropertyKeywords
-
setStatus
public boolean setStatus(Status status)
Will returntrueif status could be updated.- Parameters:
status- the status of the task- Returns:
- true if status has been updated.
falseif the status was already set tostatuspreviously, or if it could not be updated at this time.
-
getStatus
public Status getStatus()
-
set
public void set(NumericPropertyKeyword type, NumericProperty property)
Description copied from class:AccessibleAn abstract method, which must be overriden to gain access over setting the values of all relevant (selected by the programmer)
NumericProperties in subclasses ofAccessible. Typically this involves aswitchstatement that goes through the different options for thetypeand invokes differentset(...)methods to update the matchingNumericPropertywithproperty.- Specified by:
setin classAccessible- Parameters:
type- the type, which must be equal by definition toproperty.getType().property- the property, which contains new information.
-
equals
public boolean equals(Object o)
ASearchTaskis deemed equal to another one if it has the sameExperimentalData.
-
describe
public String describe()
Description copied from class:UpwardsNavigableUses the SearchTask id (if present) to describe this UpwardsNavigable.- Specified by:
describein interfaceDescriptive- Overrides:
describein classUpwardsNavigable- Returns:
- by default, this will return the name of the implementing class and the date of the calculation.
-
getInput
public ExperimentalData getInput()
- Specified by:
getInputin classGeneralTask
-
getResponse
public Calculation getResponse()
- Specified by:
getResponsein classGeneralTask
-
-