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 enum
Enum for the interpolation methods of the input signal -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate int
private Signal
private boolean
private final com.mathworks.engine.MatlabEngine
private final Double
The signal step of the input signal.private final TimeMeasure
private double
The simulation step of Simulink.private boolean
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
Clear the counter and the time measure.void
close()
Close the MATLAB engine.private void
configureSimulink
(StringBuilder builder) Execute the Simulink model by feeding inputSignaldouble
The current time of the simulationprotected double[][]
double
protected double[]
private void
makeDataSet
(StringBuilder builder) private void
preventHugeTempFile
(StringBuilder builder) void
reset()
Reset the Simulink model to the initial state.private void
runSimulation
(StringBuilder builder, double stopTime) void
setSimulationStep
(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:
InterruptedException
ExecutionException
-
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()
-