Class LinearizationResult
java.lang.Object
neqsim.process.mpc.LinearizationResult
- All Implemented Interfaces:
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 Summary
FieldsModifier and TypeFieldDescriptionprivate final longTime taken for linearization (milliseconds).private final String[]Names of CVs.private final double[]Operating point values for CVs.private final double[][]Disturbance gain matrix: disturbanceGainMatrix[cv][dv] = ∂CV/∂DV.private final String[]Names of DVs.private final double[]Operating point values for DVs.private final StringError message if linearization failed.private final double[][]Gain matrix: gainMatrix[cv][mv] = ∂CV/∂MV.private final String[]Names of MVs.private final double[]Operating point values for MVs.private final doublePerturbation size used for finite differences.private static final longprivate final booleanWhether linearization was successful. -
Constructor Summary
ConstructorsConstructorDescriptionLinearizationResult(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.LinearizationResult(String errorMessage, long computationTimeMs) Construct a failed linearization result. -
Method Summary
Modifier and TypeMethodDescriptionprivate double[][]deepCopy(double[][] matrix) private intFormat the gain matrix as a string table.longGet the computation time.String[]Get the CV names.double[]Get the CV operating point values.doublegetDisturbanceGain(int cvIndex, int dvIndex) Get a single disturbance gain value.double[][]Get the disturbance gain matrix.String[]Get the DV names.double[]Get the DV operating point values.Get the error message if linearization failed.doublegetGain(int cvIndex, int mvIndex) Get a single gain value.doubleGet a gain by variable names.double[][]Get the full gain matrix.double[]getGainsForCV(int cvIndex) Get the gain matrix row for a specific CV.double[]getGainsForMV(int mvIndex) Get the gain matrix column for a specific MV.String[]Get the MV names.double[]Get the MV operating point values.intgetNumCV()Get the number of CVs.intgetNumDV()Get the number of DVs.intgetNumMV()Get the number of MVs.doubleGet the perturbation size used.booleanCheck if linearization was successful.toString()
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
gainMatrix
private final double[][] gainMatrixGain matrix: gainMatrix[cv][mv] = ∂CV/∂MV. -
disturbanceGainMatrix
private final double[][] disturbanceGainMatrixDisturbance gain matrix: disturbanceGainMatrix[cv][dv] = ∂CV/∂DV. -
mvOperatingPoint
private final double[] mvOperatingPointOperating point values for MVs. -
cvOperatingPoint
private final double[] cvOperatingPointOperating point values for CVs. -
dvOperatingPoint
private final double[] dvOperatingPointOperating point values for DVs. -
mvNames
Names of MVs. -
cvNames
Names of CVs. -
dvNames
Names of DVs. -
perturbationSize
private final double perturbationSizePerturbation size used for finite differences. -
computationTimeMs
private final long computationTimeMsTime taken for linearization (milliseconds). -
successful
private final boolean successfulWhether linearization was successful. -
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 matrixdisturbanceGainMatrix- the DV-to-CV gain matrixmvOperatingPoint- MV values at operating pointcvOperatingPoint- CV values at operating pointdvOperatingPoint- DV values at operating pointmvNames- names of MVscvNames- names of CVsdvNames- names of DVsperturbationSize- perturbation usedcomputationTimeMs- time taken
-
LinearizationResult
Construct a failed linearization result.- Parameters:
errorMessage- the error descriptioncomputationTimeMs- 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
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 variablemvIndex- index of the manipulated variable- Returns:
- the gain ∂CV/∂MV
-
getGain
-
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 variabledvIndex- 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
-
getCvNames
-
getDvNames
-
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
-
formatGainMatrix
Format the gain matrix as a string table.- Returns:
- formatted string representation
-
toString
-