Package net.maswag.falcaun
Class SimulinkModel
java.lang.Object
net.maswag.falcaun.SimulinkModel
Raw Simulink model. We use the fixed step execution of Simulink to make sampling easier.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumEnum for the interpolation methods of the input signal -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate intprivate Signalprivate booleanprivate final com.mathworks.engine.MatlabEngineprivate final DoubleThe signal step of the input signal.private final TimeMeasureprivate doubleThe simulation step of Simulink.private boolean -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Clear the counter and the time measure.voidclose()Close the MATLAB engine.private voidconfigureSimulink(StringBuilder builder) Execute the Simulink model by feeding inputSignaldoubleThe current time of the simulationprotected double[][]doubleprotected double[]private voidmakeDataSet(StringBuilder builder) private voidpreventHugeTempFile(StringBuilder builder) voidreset()Reset the Simulink model to the initial state.private voidrunSimulation(StringBuilder builder, double stopTime) voidsetSimulationStep(double simulinkSimulationStep) Setter of simulinkSimulationStepExecute the Simulink model for one step by feeding inputSignal
-
Field Details
-
signalStep
The signal step of the input signal. -
simulinkSimulationStep
private double simulinkSimulationStepThe simulation step of Simulink.If this value is too large, Simulink can abort due to an computation error. In that case, you should make this value larger.
-
matlab
private final com.mathworks.engine.MatlabEngine matlab -
paramNames
-
inputSignal
-
isInitial
private boolean isInitial -
useFastRestart
private boolean useFastRestart -
counter
private int counter -
simulationTime
-
interpolationMethod
-
-
Constructor Details
-
SimulinkModel
public SimulinkModel(String initScript, List<String> paramNames, Double signalStep, Double simulinkSimulationStep) throws InterruptedException, ExecutionException
-
-
Method Details
-
getCurrentTime
public double getCurrentTime()The current time of the simulation -
setSimulationStep
public void setSimulationStep(double simulinkSimulationStep) Setter of simulinkSimulationStep- Parameters:
simulinkSimulationStep- The fixed simulation step of Simulink. If this value is too large, Simulink can abort due to an computation error.
-
reset
public void reset()Reset the Simulink model to the initial state. -
clear
public void clear()Clear the counter and the time measure. -
step
Execute the Simulink model for one step by feeding inputSignal- Parameters:
inputSignal- The input signal- Returns:
- The output signal with timestamps of the entire execution.
-
makeDataSet
-
configureSimulink
-
preventHugeTempFile
-
runSimulation
-
getResult
-
getTimestamps
-
execute
public ValueWithTime<List<Double>> execute(net.automatalib.word.Word<List<Double>> inputSignal) throws InterruptedException, ExecutionException Execute the Simulink model by feeding inputSignalFor inputSignal = a1, a2, ..., an, we construct a timed word w = (a1, 0), (a2, T), (a3, 2 * T), ... (an, (n - 1) * T) and execute the Simulink model by feeding the piecewise-linear interpolation of w.
- Parameters:
inputSignal- The input signal- Returns:
- The output signal. The size is same as the input.
- Throws:
InterruptedExceptionExecutionException
-
close
public void close() throws com.mathworks.engine.EngineExceptionClose the MATLAB engine. This method must be called when the object is no longer used.- Throws:
com.mathworks.engine.EngineException
-
getSimulationTimeSecond
public double getSimulationTimeSecond()
-