Class FWSimulationGenerator
java.lang.Object
net.simplace.sim.control.FWSimulationControlContainer
net.simplace.sim.control.FWSimulationGenerator
- All Implemented Interfaces:
FWSimFieldContainer
- Direct Known Subclasses:
DefaultSimulationGenerator, SimpleSimulationGenerator
Base class of the simulation generators: a generator creates the simulations (
FWSimSimulation) of a project
(FWSimProject). Implementations:
DefaultSimulationGenerator: generates nothing itself; used forFWSimProject.PROJECT_MODE.SIMULATION(the simulations come from the project data) and as base for own generator plug-ins- generators in
net.simplace.sim.control.generators(e.g.EquidistantCalSimGenerator): generate simulations by varying calibration variables SimpleSimulationGenerator: for solutions without project; currently not used
generate(FWSimulationControlCache, ResultSet) writes the parameter combinations of the simulations into
the database table PROJECT_DATA (addSimulation(FWSimVarMap)); updateSimulations(FWSimulationControlCache, String, int) then reads them in chunks of FWSimEngine.MAX_SIMULATION_COUNT and
creates the simulation objects.- Author:
- Andreas Enders
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected FWSimVariable.CONTENT_TYPEcontent type of the generated variables:sim(project data) orresDeprecated.not used by the frameworkFields inherited from class FWSimulationControlContainer
iCache, iCals, iConstraint, iContainerElement, iControlMap, iFieldMap, iIdentifier, iInputMap, iInputs, iName, iParams, iSession, iSimulationMap -
Constructor Summary
ConstructorsModifierConstructorDescriptionConstructor for instantiation via reflection (documentation).protectedFWSimulationGenerator(org.jdom2.Element aControlContainerElement, FWSimSession aSession, HashMap<String, FWSimVariable<?>> aFieldMap, FWSimVariable.CONTENT_TYPE aContentType) Creates the generator; to be called by the subclasses. -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanaddSimulation(FWSimVarMap aVarMap) Adds a generated parameter combination as simulation: generates the simulation id and writes the values toPROJECT_DATA, if the constraint allows it.booleanprotected voidClears the simulations of the current chunk.static FWSimulationGeneratorcreateSimulationGenerator(org.jdom2.Element aContainerElement, FWSimSession aSession, HashMap<String, FWSimVariable<?>> aFieldMap, FWSimVariable.CONTENT_TYPE aContentType) Factory method: creates the generator of the class given in the attributeclassvia its constructor(Element, FWSimSession, HashMap, CONTENT_TYPE).voidfinalize()Returns the connections of the insert, select and count statements to the pool (each has its own connection).abstract voidgenerate(FWSimulationControlCache aControlCache, ResultSet aSimulationsResultSet) Generates the parameter combinations of a project for the current iteration and adds them withaddSimulation(FWSimVarMap); to be implemented by the subclasses.protected FWSimSimulationgetSimulation(int index) protected intprotected ResultSetinitializeProject(String aProjectID, FWSimulationControlCache aControlCache) Reads the project data (iteration 0) of a project and sets the values of the first row to the control variable map (not simulation id and iteration).voidreset()Discards the remembered calibration values (GLOBAL mode).protected voidMarks the generator as finished (no more simulations).voidResets the generator so it can deliver simulations again.updateSimulations(FWSimulationControlCache aCache, String aProjectID, int aStartNumber) Creates the next chunk of simulations of a project fromPROJECT_DATA(at mostFWSimEngine.MAX_SIMULATION_COUNT); on the first call the simulations are counted.voidwriteSimulation(FWSimVarMap aSimulationMap) Writes the values of a simulation (all variables of the control cache) intoPROJECT_DATA; with an identifier rule the simulation name is generated first.Methods inherited from class FWSimulationControlContainer
addProcessTime, addVariable, checkCondition, evaluate, getContentType, getCreateFormXML, getEditFormXML, getFieldMap, getFrequence, getInputVariables, getName, getOrderNumber, getOutputVariables, getVariable, getVarMap, init, isConditionCheck, readInputCalAndConstraint, removeVariable, setPropertyValue, toXMLMethods inherited from class Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface FWSimFieldContainer
createVariables
-
Field Details
-
iSimulationsMap
@Deprecated protected HashMap<String, HashMap<String, HashMap<String, FWSimVariable<?>>>> iSimulationsMapDeprecated.not used by the frameworknot used -
iContentType
content type of the generated variables:sim(project data) orres
-
-
Constructor Details
-
FWSimulationGenerator
public FWSimulationGenerator()Constructor for instantiation via reflection (documentation). -
FWSimulationGenerator
protected FWSimulationGenerator(org.jdom2.Element aControlContainerElement, FWSimSession aSession, HashMap<String, FWSimVariable<?>> aFieldMap, FWSimVariable.CONTENT_TYPE aContentType) Creates the generator; to be called by the subclasses. Except in SOLUTION_ONLY mode it reads the configuration and prepares the tablePROJECT_DATAand the statements. Database errors are logged.- Parameters:
aControlContainerElement- thegeneratorelement, may benullaSession- the sessionaFieldMap- variables of the project dataaContentType-FWSimVariable.CONTENT_TYPE.resorFWSimVariable.CONTENT_TYPE.sim
-
-
Method Details
-
createSimulationGenerator
public static FWSimulationGenerator createSimulationGenerator(org.jdom2.Element aContainerElement, FWSimSession aSession, HashMap<String, FWSimVariable<?>> aFieldMap, FWSimVariable.CONTENT_TYPE aContentType) Factory method: creates the generator of the class given in the attributeclassvia its constructor(Element, FWSimSession, HashMap, CONTENT_TYPE). Errors are logged.- Parameters:
aContainerElement- thegeneratorelementaSession- the sessionaFieldMap- variables of the project dataaContentType- content type of the generated variables- Returns:
- the generator, or
nullif it cannot be created
-
clearSimulations
protected void clearSimulations()Clears the simulations of the current chunk. -
getSimulationsListSize
protected int getSimulationsListSize()- Returns:
- the number of simulations in the current chunk
-
getSimulation
- Parameters:
index- index in the current chunk- Returns:
- the simulation
- Throws:
IndexOutOfBoundsException- if the index is invalid
-
addSimulation
Adds a generated parameter combination as simulation: generates the simulation id and writes the values toPROJECT_DATA, if the constraint allows it. In GLOBAL mode the constraint is only checked for the first project, whose calibration values are remembered for the other projects.- Parameters:
aVarMap- control variable map with the values of the simulation- Returns:
trueif the simulation was added
-
writeSimulation
Writes the values of a simulation (all variables of the control cache) intoPROJECT_DATA; with an identifier rule the simulation name is generated first. SQL and type errors are logged.- Parameters:
aSimulationMap- variable map with the values of the simulation
-
updateSimulations
public List<FWSimSimulation> updateSimulations(FWSimulationControlCache aCache, String aProjectID, int aStartNumber) Creates the next chunk of simulations of a project fromPROJECT_DATA(at mostFWSimEngine.MAX_SIMULATION_COUNT); on the first call the simulations are counted. Without database statements (SOLUTION_ONLY) a single simulation of the solution is created. If the chunk is not full, the generator is finished. Database errors are logged.- Parameters:
aCache- control cache of the runaProjectID- id of the projectaStartNumber- offset of the chunk- Returns:
- the simulations of the chunk, or
nullif there are none
-
initializeProject
protected ResultSet initializeProject(String aProjectID, FWSimulationControlCache aControlCache) throws SQLException Reads the project data (iteration 0) of a project and sets the values of the first row to the control variable map (not simulation id and iteration). If the project has no rows, a warning is logged and no values are set.- Parameters:
aProjectID- id of the projectaControlCache- control cache of the run- Returns:
- the result set, positioned on the first row
- Throws:
SQLException- if reading fails
-
generate
public abstract void generate(FWSimulationControlCache aControlCache, ResultSet aSimulationsResultSet) throws Exception Generates the parameter combinations of a project for the current iteration and adds them withaddSimulation(FWSimVarMap); to be implemented by the subclasses.- Parameters:
aControlCache- control cache of the runaSimulationsResultSet- project data of the project (first iteration only), may benull- Throws:
Exception- if generating fails
-
canUpdate
- Parameters:
aProjectName- not used- Returns:
trueas long as the generator can deliver more simulations
-
setFinished
protected void setFinished()Marks the generator as finished (no more simulations). -
setInitial
public void setInitial()Resets the generator so it can deliver simulations again. -
finalize
-
reset
public void reset()Discards the remembered calibration values (GLOBAL mode).
-