|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjecthSimulator.library.SimulatedTS
public class SimulatedTS
This object implements an optimized data structures for storing simulated time series.
Constructor Summary | |
---|---|
SimulatedTS(Model model,
int tMax,
double timeSampling)
Constructs a new object. |
|
SimulatedTS(Model model,
List<String> varsToBeSaved,
int tMax,
double timeSampling)
Constructs a new object. |
Method Summary | |
---|---|
void |
clear()
Clears the object. |
SimulatedTS |
clone()
Clones the time series. |
void |
exportToExcel(String fileName)
Exports the time series in an Excel document. |
void |
exportToTxt(String fileName)
Exports the time series in a txt document. |
static SimulatedTS |
getAveragedDynamics(SimulatedTS[] dynamics,
boolean roundToInteger)
Returns a time series of averaged values. |
double |
getComputationTime()
Returns the time (in seconds) spent for computing the stored time series. |
double[][] |
getDynamicsTs()
Returns a matrix storing the time series of the system dynamics. |
double[] |
getDynamicsTs(String varID)
Returns an array storing the time series of the dynamics of a specified variable. |
double |
getFirstTimeInstant()
Returns the first time instant stored in the object. |
double[] |
getInitialState()
Returns the initial (first) system state stored in the object. |
double[] |
getLastState()
Returns the last system state stored in the object. |
double |
getLastTimeInstant()
Returns the last time instant stored in the object. |
List<String> |
getSavedVariables()
Returns the list of variable IDs whose time series are stored in the object (in the corresponding order). |
org.jfree.chart.JFreeChart |
getSimulationPlot(String plotTitle,
boolean logScale)
Returns the plot of the time series stored in the object. |
double[] |
getState(double time)
Returns the system state related to the given time instant. |
Iterator<double[]> |
getStates()
Returns an iterator providing all the system states stored in the object. |
Iterator<Double> |
getTimeInstants()
Returns an iterator providing all the time instants stored in the object. |
double |
getTimeSampling()
Returns the time sampling used for storing the time series. |
double[] |
getTimeTs()
Returns an array storing the time instants of the time series. |
boolean |
isEmpty()
Returns true if the time series stored in the object are empty. |
static SimulatedTS |
loadTimeSeries(String filePath)
Loads a time series from file. |
void |
plotSimulation(String windowTitle)
Plots the time series stored in the object. |
void |
plotSimulation(String windowTitle,
boolean logScale)
Plots the time series stored in the object. |
void |
put(double time,
double[] state)
Puts a new state. |
void |
put(Double time,
double[] state)
Puts a new state. |
static void |
saveTimeSeries(SimulatedTS ts,
String filePath)
Saves a time series to file. |
int |
size()
Returns the length of the time series stored in the object. |
int |
stateSize()
Returns the number of variables whose time series are stored in the object. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public SimulatedTS(Model model, int tMax, double timeSampling)
model
- the model which will be simulatedtMax
- maximum time instant that will be stored (the insertion of subsequent time instants will be not optimized)timeSampling
- the time sampling used for storing time seriesModel
public SimulatedTS(Model model, List<String> varsToBeSaved, int tMax, double timeSampling)
variableName + Model.variableCompartmentSeparator + compartmentName
.
model
- the model which will be simulatedvarsToBeSaved
- the list of variable IDs whose time series will be stored in the object (in the corresponding order)tMax
- maximum time instant that will be stored (the insertion of subsequent time instants will be not optimized)timeSampling
- the time sampling used for storing time seriesModel
Method Detail |
---|
public void clear()
public SimulatedTS clone() throws CloneNotSupportedException
clone
in class Object
CloneNotSupportedException
public double getTimeSampling()
public List<String> getSavedVariables()
variableName + Model.variableCompartmentSeparator + compartmentName
.
public double getComputationTime()
public int stateSize()
public void put(Double time, double[] state)
time
- time instantstate
- system state that has to be storedpublic void put(double time, double[] state)
time
- time instantstate
- system state that has to be storedpublic int size()
public boolean isEmpty()
true
if the time series stored in the object are empty.
public Iterator<Double> getTimeInstants()
public Iterator<double[]> getStates()
public double[] getLastState()
null
if the data structure is empty)public double[] getInitialState()
null
if the data structure is empty)public double[] getState(double time)
time
- the time instant of the required system state
null
in case of error)public double getFirstTimeInstant()
-1
if the data structure is empty)public double getLastTimeInstant()
-1
if the data structure is empty)public double[] getTimeTs()
null
if the data structure is empty)public double[][] getDynamicsTs()
this.getTimeTs()
); each column corresponds to
a different system variable (in the same order of this.getSavedVariables()
).
null
if the data structure is empty)public double[] getDynamicsTs(String varID)
this.getTimeTs()
).
varID
- the ID of the required variable
null
if no variable with the specified ID is stored in the object)public org.jfree.chart.JFreeChart getSimulationPlot(String plotTitle, boolean logScale)
plotTitle
- the title of the plotlogScale
- indicates if the values of the domain axis has to be in log10 scale
JFreeChart
public void plotSimulation(String windowTitle)
windowTitle
- the title of the window containing the chartpublic void plotSimulation(String windowTitle, boolean logScale)
windowTitle
- the title of the window containing the chartlogScale
- indicates if the values of the domain axis has to be in log10 scalepublic static void saveTimeSeries(SimulatedTS ts, String filePath) throws FileNotFoundException, IOException
ts
- the SimulatedTS
object which needs to be savedfilePath
- path pointing out the resource where the time series needs to be saved
FileNotFoundException
- if the file specified in filePath
exists but is a directory rather than a regular file, does not exist but cannot be created, or cannot be opened for any other reason
IOException
- if an input/output error occurred while writing the objectpublic static SimulatedTS loadTimeSeries(String filePath) throws FileNotFoundException, IOException, ClassNotFoundException
filePath
- path pointing out the resource where the time series is saved
SimulatedTS
object
FileNotFoundException
- if the file specified in filePath
exists but is a directory rather than a regular file, does not exist but cannot be created, or cannot be opened for any other reason
IOException
- if an input/output error occurred while reading the object
ClassNotFoundException
- if the object saved in filePath
is not a SimulatedTS
objectpublic static SimulatedTS getAveragedDynamics(SimulatedTS[] dynamics, boolean roundToInteger)
dynamics.
- Parameters:
dynamics
- array of time series that has to be averagedroundToInteger
- boolean indicating if variable averaged values have to be rounded to integers
- Returns:
- an object storing the average of the provided time series
public void exportToTxt(String fileName) throws IOException
fileName
- the name of the Excel file to create
IOException
- if an input/output error occurred during the exportation processpublic void exportToExcel(String fileName) throws IOException
fileName
- the name of the Excel file to create
IOException
- if an input/output error occurred during the exportation process
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |