Class FWSimulationControlCache
java.lang.Object
net.simplace.sim.io.FWSimCache
net.simplace.sim.control.FWSimulationControlCache
- All Implemented Interfaces:
FWSimFieldContainer
State of a project run (one instance per session): the project ids, the current project and iteration, the
simulation counters and progress, the calibration mode, the selected simulations and the control variable map
(a copy of the solution variable map used by generators, iterators and selectors). As cache it holds the project
data of the selected simulations by simulation id (see
loadProjectData()).- Author:
- lap
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected intthe current count of simulations in that projectprotected intthe current count of update simulations cycle in that projectFields inherited from class FWSimCache
iArrayMode, iCache, iFieldcount, iFrequence, iHeaderVariables, iName, iOrderNumber, iVariablesIndexes -
Constructor Summary
ConstructorsConstructorDescriptionFWSimulationControlCache(FWSimSession aSession) Creates the control cache with a control copy of the solution variable map. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddProject(String aProjectID) Adds a project id; the first one becomes the first project id.voidIncreases the project counter by 1.voidIncreases the simulation counter by 1.voidIncreases the chunk counter by 1.voidcalculateFractionFinished(long aCompletedTaskCount) Calculates the progress of the run from the finished projects, the iterations and the completed simulations of the current (started) project.Removes all project ids and resets first, last and current project.org.jdom2.ElementNo form.intintorg.jdom2.ElementgetEditFormXML(boolean aEnabled) No form.doubleintReturns the progress last calculated bycalculateFractionFinished(long).intString[]intReturns the control variable map.voidkeepIterationData(Boolean aKeepFlag) voidLoads the project data of the selected simulations fromPROJECT_DATAinto the cache, keyed by simulation id.voidStarts a new iteration: increases the iteration number and resets the project counter.voidputAllVariables(LinkedHashMap<String, FWSimVariable<?>> aFieldMap) Adds the variables of a field map (except outputs) as columns of the cache.voidResets the control variable map, the iteration number (to 0) and the project counter, e.g.voidResets the project counter to 0.voidResets the simulation counter to 0.voidResets the chunk counter to 0.voidsetCalibrationMode(FWSimSession.CALIBRATION_MODE aCalibrationMode) voidsetFractionFinished(double aFractionFinished) voidsetProjectCount(int aProjectCount) voidsetSelectedSimulations(String[] aSelectedSimulations) voidsetSimulationCount(int aSimulationCount) voidstartProject(String aProjectID) Starts a project: resets the simulation counters, increases the project counter and remembers the previous project.org.jdom2.ElementtoXML()Not implemented.Methods inherited from class FWSimCache
addVariable, checkCondition, createVariables, getCache, getContentType, getFieldcount, getFieldMap, getFrequence, getInputVariables, getName, getOrderNumber, getOutputVariables, getVariable, getVariableIndex, getVariables, isArrayMode, isConditionCheck, removeVariable, setCacheMap
-
Field Details
-
iCurrentSimulationCount
protected int iCurrentSimulationCountthe current count of simulations in that project -
iCurrentUpdateSimulationCount
protected int iCurrentUpdateSimulationCountthe current count of update simulations cycle in that project
-
-
Constructor Details
-
FWSimulationControlCache
Creates the control cache with a control copy of the solution variable map.- Parameters:
aSession- the session (its solution must already exist)
-
-
Method Details
-
toXML
public org.jdom2.Element toXML()Not implemented.- Returns:
- always
null - See Also:
-
getCreateFormXML
public org.jdom2.Element getCreateFormXML()No form.- Returns:
- always
null - See Also:
-
getEditFormXML
public org.jdom2.Element getEditFormXML(boolean aEnabled) No form.- Parameters:
aEnabled- iffalse, the form fields are read-only- Returns:
- always
null - See Also:
-
keepIterationData
- Returns:
trueif the project data of the selected simulations of all iterations is kept
-
keepIterationData
- Parameters:
aKeepFlag-trueto keep the project data of the selected simulations of all iterations
-
getIteration
- Returns:
- the variable holding the current iteration
-
newIteration
public void newIteration()Starts a new iteration: increases the iteration number and resets the project counter. -
resetIteration
public void resetIteration()Resets the control variable map, the iteration number (to 0) and the project counter, e.g. before the next project in INDIVIDUAL mode. -
getProjectIDs
- Returns:
- the project ids in the order they were added (the live set)
-
getProjectCount
public int getProjectCount()- Returns:
- the number of projects, at least 1
-
getFirstProjectID
- Returns:
- the first project id, or
null
-
startProject
Starts a project: resets the simulation counters, increases the project counter and remembers the previous project.- Parameters:
aProjectID- id of the project
-
getCurrentProjectID
- Returns:
- the id of the current project
-
getCurrentProjectCount
public int getCurrentProjectCount()- Returns:
- the number of projects started in the current iteration
-
addProjectCount
public void addProjectCount()Increases the project counter by 1. -
setProjectCount
public void setProjectCount(int aProjectCount) - Parameters:
aProjectCount- the number of projects started in the current iteration
-
resetProjectCount
public void resetProjectCount()Resets the project counter to 0. -
getLastProjectID
- Returns:
- the last project id added, or
null
-
getPrevProjectID
- Returns:
- the id of the previous project, or
null
-
addProject
Adds a project id; the first one becomes the first project id.- Parameters:
aProjectID- id of the project
-
getSession
- Returns:
- the session
-
clearProjectIDs
Removes all project ids and resets first, last and current project.- Returns:
- a copy of the removed project ids
-
getCalibrationMode
- Returns:
- the calibration mode of the run
-
setCalibrationMode
- Parameters:
aCalibrationMode- the calibration mode of the run
-
getSelectedSimulations
- Returns:
- the ids of the selected simulations, or
null
-
getSelectedSimulationsVar
- Returns:
- the variable holding the selected simulations
-
setSelectedSimulations
- Parameters:
aSelectedSimulations- the ids of the selected simulations
-
putAllVariables
Adds the variables of a field map (except outputs) as columns of the cache.- Parameters:
aFieldMap- the variables
-
loadProjectData
Loads the project data of the selected simulations fromPROJECT_DATAinto the cache, keyed by simulation id. In INDIVIDUAL mode only the rows of the current project are read. Unless iterations are kept, the cache is cleared first. Without selected simulations nothing is read.- Throws:
SQLException- if reading fails
-
getControlMap
- Returns:
- the control variable map
-
getCurrentSimulationCount
public int getCurrentSimulationCount()- Returns:
- the number of simulations of the current project
-
addSimulationCount
public void addSimulationCount()Increases the simulation counter by 1. -
setSimulationCount
public void setSimulationCount(int aSimulationCount) - Parameters:
aSimulationCount- the number of simulations of the current project
-
resetSimulationCount
public void resetSimulationCount()Resets the simulation counter to 0. -
getUpdateSimulationCount
public int getUpdateSimulationCount()- Returns:
- the number of simulation chunks created for the current project
-
addUpdateSimulationCount
public void addUpdateSimulationCount()Increases the chunk counter by 1. -
resetUpdateSimulationCount
public void resetUpdateSimulationCount()Resets the chunk counter to 0. -
getPercentFinished
public int getPercentFinished()Returns the progress last calculated bycalculateFractionFinished(long).- Returns:
- the progress in percent [0-100]
-
getFractionFinished
public double getFractionFinished()- Returns:
- the progress [0-1]
-
setFractionFinished
public void setFractionFinished(double aFractionFinished) - Parameters:
aFractionFinished- the progress of the run [0-1]
-
getVarMap
Returns the control variable map.- Returns:
- the var map this container belongs to
- See Also:
-
getSynchronizeRule
- Returns:
- the rule for synchronized simulations from the control map
-
getSynchronizeFrequence
- Returns:
- the synchronization frequency from the control map
-
calculateFractionFinished
public void calculateFractionFinished(long aCompletedTaskCount) Calculates the progress of the run from the finished projects, the iterations and the completed simulations of the current (started) project.- Parameters:
aCompletedTaskCount- number of completed simulations of the current project
-