Class LinearizationResult

java.lang.Object
neqsim.process.mpc.LinearizationResult
All Implemented Interfaces:
Serializable

public class LinearizationResult extends Object implements Serializable
Result of a linearization operation containing the gain matrix and metadata.

The linearization result captures the sensitivity of controlled variables (CVs) to manipulated variables (MVs) and disturbance variables (DVs) around an operating point. These sensitivities form the gain matrices used by linear MPC algorithms.

The gain matrix G[i][j] represents ∂CV[i]/∂MV[j], the change in CV[i] per unit change in MV[j]. Similarly, the disturbance gain matrix D[i][k] represents ∂CV[i]/∂DV[k].

Since:
3.0
Version:
1.0
Author:
Even Solbraa
See Also:
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      See Also:
    • gainMatrix

      private final double[][] gainMatrix
      Gain matrix: gainMatrix[cv][mv] = ∂CV/∂MV.
    • disturbanceGainMatrix

      private final double[][] disturbanceGainMatrix
      Disturbance gain matrix: disturbanceGainMatrix[cv][dv] = ∂CV/∂DV.
    • mvOperatingPoint

      private final double[] mvOperatingPoint
      Operating point values for MVs.
    • cvOperatingPoint

      private final double[] cvOperatingPoint
      Operating point values for CVs.
    • dvOperatingPoint

      private final double[] dvOperatingPoint
      Operating point values for DVs.
    • mvNames

      private final String[] mvNames
      Names of MVs.
    • cvNames

      private final String[] cvNames
      Names of CVs.
    • dvNames

      private final String[] dvNames
      Names of DVs.
    • perturbationSize

      private final double perturbationSize
      Perturbation size used for finite differences.
    • computationTimeMs

      private final long computationTimeMs
      Time taken for linearization (milliseconds).
    • successful

      private final boolean successful
      Whether linearization was successful.
    • errorMessage

      private final String errorMessage
      Error message if linearization failed.
  • Constructor Details

    • LinearizationResult

      public LinearizationResult(double[][] gainMatrix, double[][] disturbanceGainMatrix, double[] mvOperatingPoint, double[] cvOperatingPoint, double[] dvOperatingPoint, String[] mvNames, String[] cvNames, String[] dvNames, double perturbationSize, long computationTimeMs)
      Construct a successful linearization result.
      Parameters:
      gainMatrix - the MV-to-CV gain matrix
      disturbanceGainMatrix - the DV-to-CV gain matrix
      mvOperatingPoint - MV values at operating point
      cvOperatingPoint - CV values at operating point
      dvOperatingPoint - DV values at operating point
      mvNames - names of MVs
      cvNames - names of CVs
      dvNames - names of DVs
      perturbationSize - perturbation used
      computationTimeMs - time taken
    • LinearizationResult

      public LinearizationResult(String errorMessage, long computationTimeMs)
      Construct a failed linearization result.
      Parameters:
      errorMessage - the error description
      computationTimeMs - time taken before failure
  • Method Details

    • deepCopy

      private double[][] deepCopy(double[][] matrix)
    • isSuccessful

      public boolean isSuccessful()
      Check if linearization was successful.
      Returns:
      true if successful
    • getErrorMessage

      public String getErrorMessage()
      Get the error message if linearization failed.
      Returns:
      the error message, or null if successful
    • getGainMatrix

      public double[][] getGainMatrix()
      Get the full gain matrix.
      Returns:
      copy of the gain matrix [numCV][numMV]
    • getGain

      public double getGain(int cvIndex, int mvIndex)
      Get a single gain value.
      Parameters:
      cvIndex - index of the controlled variable
      mvIndex - index of the manipulated variable
      Returns:
      the gain ∂CV/∂MV
    • getGain

      public double getGain(String cvName, String mvName)
      Get a gain by variable names.
      Parameters:
      cvName - name of the controlled variable
      mvName - name of the manipulated variable
      Returns:
      the gain ∂CV/∂MV
    • getDisturbanceGainMatrix

      public double[][] getDisturbanceGainMatrix()
      Get the disturbance gain matrix.
      Returns:
      copy of the disturbance gain matrix [numCV][numDV]
    • getDisturbanceGain

      public double getDisturbanceGain(int cvIndex, int dvIndex)
      Get a single disturbance gain value.
      Parameters:
      cvIndex - index of the controlled variable
      dvIndex - index of the disturbance variable
      Returns:
      the gain ∂CV/∂DV
    • getMvOperatingPoint

      public double[] getMvOperatingPoint()
      Get the MV operating point values.
      Returns:
      copy of MV operating point
    • getCvOperatingPoint

      public double[] getCvOperatingPoint()
      Get the CV operating point values.
      Returns:
      copy of CV operating point
    • getDvOperatingPoint

      public double[] getDvOperatingPoint()
      Get the DV operating point values.
      Returns:
      copy of DV operating point
    • getMvNames

      public String[] getMvNames()
      Get the MV names.
      Returns:
      copy of MV names
    • getCvNames

      public String[] getCvNames()
      Get the CV names.
      Returns:
      copy of CV names
    • getDvNames

      public String[] getDvNames()
      Get the DV names.
      Returns:
      copy of DV names
    • getNumMV

      public int getNumMV()
      Get the number of MVs.
      Returns:
      number of manipulated variables
    • getNumCV

      public int getNumCV()
      Get the number of CVs.
      Returns:
      number of controlled variables
    • getNumDV

      public int getNumDV()
      Get the number of DVs.
      Returns:
      number of disturbance variables
    • getPerturbationSize

      public double getPerturbationSize()
      Get the perturbation size used.
      Returns:
      the perturbation as a fraction
    • getComputationTimeMs

      public long getComputationTimeMs()
      Get the computation time.
      Returns:
      time in milliseconds
    • getGainsForCV

      public double[] getGainsForCV(int cvIndex)
      Get the gain matrix row for a specific CV.
      Parameters:
      cvIndex - index of the controlled variable
      Returns:
      array of gains for this CV with respect to all MVs
    • getGainsForMV

      public double[] getGainsForMV(int mvIndex)
      Get the gain matrix column for a specific MV.
      Parameters:
      mvIndex - index of the manipulated variable
      Returns:
      array of gains for all CVs with respect to this MV
    • findIndex

      private int findIndex(String[] names, String name)
    • formatGainMatrix

      public String formatGainMatrix()
      Format the gain matrix as a string table.
      Returns:
      formatted string representation
    • toString

      public String toString()
      Overrides:
      toString in class Object