Class SimulinkModel

java.lang.Object
net.maswag.falcaun.SimulinkModel

public class SimulinkModel extends Object
Raw Simulink model. We use the fixed step execution of Simulink to make sampling easier.
  • Field Details

    • signalStep

      private final Double signalStep
      The signal step of the input signal.
    • simulinkSimulationStep

      private double simulinkSimulationStep
      The 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

      private final List<String> paramNames
    • inputSignal

      private Signal inputSignal
    • isInitial

      private boolean isInitial
    • useFastRestart

      private boolean useFastRestart
    • counter

      private int counter
    • simulationTime

      private final TimeMeasure simulationTime
    • interpolationMethod

      private SimulinkModel.InterpolationMethod interpolationMethod
  • Constructor Details

  • 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

      @Nonnull public ValueWithTime<List<Double>> step(@Nonnull List<Double> inputSignal)
      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

      private void makeDataSet(StringBuilder builder) throws ExecutionException, InterruptedException
      Throws:
      ExecutionException
      InterruptedException
    • configureSimulink

      private void configureSimulink(StringBuilder builder)
    • preventHugeTempFile

      private void preventHugeTempFile(StringBuilder builder)
    • runSimulation

      private void runSimulation(StringBuilder builder, double stopTime)
    • getResult

      protected double[][] getResult() throws ExecutionException, InterruptedException
      Throws:
      ExecutionException
      InterruptedException
    • getTimestamps

      protected double[] getTimestamps() throws ExecutionException, InterruptedException
      Throws:
      ExecutionException
      InterruptedException
    • execute

      public ValueWithTime<List<Double>> execute(net.automatalib.word.Word<List<Double>> inputSignal) throws InterruptedException, ExecutionException
      Execute the Simulink model by feeding inputSignal

      For 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.EngineException
      Close the MATLAB engine. This method must be called when the object is no longer used.
      Throws:
      com.mathworks.engine.EngineException
    • getSimulationTimeSecond

      public double getSimulationTimeSecond()