Class ProcessLinkedMPC

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

public class ProcessLinkedMPC extends Object implements Serializable
Bridge class that auto-configures and links MPC to a ProcessSystem.

ProcessLinkedMPC provides automatic integration between NeqSim's ProcessSystem simulation and Model Predictive Control. It handles:

  • Automatic model identification through linearization or step testing
  • Variable binding between MPC and process equipment
  • Model updating during online operation
  • Coordinated execution between controller and simulation

Example usage:


// Build process
ProcessSystem process = new ProcessSystem();
Stream feed = new Stream("feed", fluid);
Valve valve = new Valve("valve", feed);
Separator sep = new Separator("separator", valve.getOutletStream());
process.add(feed);
process.add(valve);
process.add(sep);
process.run();

// Create linked MPC
ProcessLinkedMPC mpc = new ProcessLinkedMPC("levelController", process);

// Define variables
mpc.addMV("valve", "opening", 0.0, 1.0);
mpc.addCV("separator", "liquidLevel", 50.0); // setpoint 50%
mpc.setConstraint("separator", "liquidLevel", 20.0, 80.0);

// Auto-identify model
mpc.identifyModel(60.0); // 60s sample time

// Configure tuning
mpc.setPredictionHorizon(20);
mpc.setControlHorizon(5);
mpc.setMoveSuppressionWeight("valve", 0.1);

// Run control step
double[] moves = mpc.calculate();
mpc.applyMoves();

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

    • serialVersionUID

      private static final long serialVersionUID
      See Also:
    • name

      private final String name
      Controller name.
    • processSystem

      private final ProcessSystem processSystem
      The process system being controlled.
    • manipulatedVariables

      private final List<ManipulatedVariable> manipulatedVariables
      Manipulated variables.
    • controlledVariables

      private final List<ControlledVariable> controlledVariables
      Controlled variables.
    • disturbanceVariables

      private final List<DisturbanceVariable> disturbanceVariables
      Disturbance variables.
    • stateVariables

      private final List<StateVariable> stateVariables
      State variables (for nonlinear MPC).
    • linearizer

      private ProcessLinearizer linearizer
      Linearizer for model identification.
    • linearizationResult

      private LinearizationResult linearizationResult
      Last linearization result.
    • sampleTime

      private double sampleTime
      Sample time in seconds.
    • predictionHorizon

      private int predictionHorizon
      Prediction horizon (number of samples).
    • controlHorizon

      private int controlHorizon
      Control horizon (number of samples).
    • modelIdentified

      private boolean modelIdentified
      Whether model has been identified.
    • lastMoves

      private double[] lastMoves
      Last calculated MV moves.
    • useNonlinearPrediction

      private boolean useNonlinearPrediction
      Whether to use nonlinear prediction.
    • nonlinearPredictor

      private NonlinearPredictor nonlinearPredictor
      Nonlinear predictor.
    • modelUpdateInterval

      private int modelUpdateInterval
      Model update interval (number of steps).
    • stepsSinceModelUpdate

      private int stepsSinceModelUpdate
      Steps since last model update.
    • executionId

      private UUID executionId
      UUID for execution tracking.
    • moveSuppressionWeights

      private double[] moveSuppressionWeights
      Move suppression weights for MVs.
    • errorWeights

      private double[] errorWeights
      Error weights for CVs.
  • Constructor Details

    • ProcessLinkedMPC

      public ProcessLinkedMPC(String name, ProcessSystem processSystem)
      Construct a process-linked MPC controller.
      Parameters:
      name - the controller name
      processSystem - the process system to control
  • Method Details

    • addMV

      public ManipulatedVariable addMV(String equipmentName, String propertyName, double minValue, double maxValue)
      Add a manipulated variable.
      Parameters:
      equipmentName - the equipment name
      propertyName - the property name (opening, duty, flowRate, etc.)
      minValue - minimum value
      maxValue - maximum value
      Returns:
      the created ManipulatedVariable
    • addMV

      public ManipulatedVariable addMV(String equipmentName, String propertyName, double minValue, double maxValue, double maxRateOfChange)
      Add a manipulated variable with rate limits.
      Parameters:
      equipmentName - the equipment name
      propertyName - the property name
      minValue - minimum value
      maxValue - maximum value
      maxRateOfChange - maximum rate of change per sample
      Returns:
      the created ManipulatedVariable
    • addCV

      public ControlledVariable addCV(String equipmentName, String propertyName, double setpoint)
      Add a controlled variable with setpoint.
      Parameters:
      equipmentName - the equipment name
      propertyName - the property name (pressure, temperature, level, etc.)
      setpoint - the setpoint value
      Returns:
      the created ControlledVariable
    • addCVZone

      public ControlledVariable addCVZone(String equipmentName, String propertyName, double lowSetpoint, double highSetpoint)
      Add a controlled variable with zone control.
      Parameters:
      equipmentName - the equipment name
      propertyName - the property name
      lowSetpoint - low zone boundary
      highSetpoint - high zone boundary
      Returns:
      the created ControlledVariable
    • setConstraint

      public void setConstraint(String equipmentName, String propertyName, double minValue, double maxValue)
      Set constraints on a controlled variable.
      Parameters:
      equipmentName - the equipment name
      propertyName - the property name
      minValue - minimum constraint
      maxValue - maximum constraint
    • addDV

      public DisturbanceVariable addDV(String equipmentName, String propertyName)
      Add a disturbance variable.
      Parameters:
      equipmentName - the equipment name
      propertyName - the property name
      Returns:
      the created DisturbanceVariable
    • addSVR

      public StateVariable addSVR(String equipmentName, String propertyName)
      Add a state variable (SVR) for nonlinear MPC.

      State variables are internal model states that evolve according to dynamic equations. They are tracked for model accuracy but not directly controlled. Examples include flow rates, internal pressures, and calculated gains.

      Parameters:
      equipmentName - the equipment name
      propertyName - the property name
      Returns:
      the created StateVariable
    • addSVR

      public StateVariable addSVR(String equipmentName, String propertyName, String dtaIx)
      Add a state variable with a data index.
      Parameters:
      equipmentName - the equipment name
      propertyName - the property name
      dtaIx - data index for C++ code linking
      Returns:
      the created StateVariable
    • getStateVariables

      public List<StateVariable> getStateVariables()
      Get all state variables.
      Returns:
      list of SVRs
    • getManipulatedVariables

      public List<ManipulatedVariable> getManipulatedVariables()
      Get all manipulated variables.
      Returns:
      list of MVs
    • getControlledVariables

      public List<ControlledVariable> getControlledVariables()
      Get all controlled variables.
      Returns:
      list of CVs
    • getDisturbanceVariables

      public List<DisturbanceVariable> getDisturbanceVariables()
      Get all disturbance variables.
      Returns:
      list of DVs
    • getProcessSystem

      public ProcessSystem getProcessSystem()
      Get the process system being controlled.
      Returns:
      the process system
    • setSampleTime

      public void setSampleTime(double sampleTimeSeconds)
      Set the sample time.
      Parameters:
      sampleTimeSeconds - sample time in seconds
    • getSampleTime

      public double getSampleTime()
      Get the sample time.
      Returns:
      sample time in seconds
    • setPredictionHorizon

      public void setPredictionHorizon(int horizon)
      Set the prediction horizon.
      Parameters:
      horizon - number of samples
    • getPredictionHorizon

      public int getPredictionHorizon()
      Get the prediction horizon.
      Returns:
      number of samples
    • setControlHorizon

      public void setControlHorizon(int horizon)
      Set the control horizon.
      Parameters:
      horizon - number of samples
    • getControlHorizon

      public int getControlHorizon()
      Get the control horizon.
      Returns:
      number of samples
    • setMoveSuppressionWeight

      public void setMoveSuppressionWeight(String mvName, double weight)
      Set move suppression weight for an MV.
      Parameters:
      mvName - the MV name
      weight - the suppression weight
    • setErrorWeight

      public void setErrorWeight(String cvName, double weight)
      Set error weight for a CV.
      Parameters:
      cvName - the CV name
      weight - the error weight
    • setUseNonlinearPrediction

      public void setUseNonlinearPrediction(boolean enable)
      Enable nonlinear prediction using full NeqSim simulation.
      Parameters:
      enable - true to enable
    • setModelUpdateInterval

      public void setModelUpdateInterval(int steps)
      Set the model update interval.
      Parameters:
      steps - number of control steps between model updates (0 = no updates)
    • identifyModel

      public void identifyModel(double sampleTimeSeconds)
      Identify the process model using linearization.
      Parameters:
      sampleTimeSeconds - the sample time in seconds
    • isModelIdentified

      public boolean isModelIdentified()
      Check if the model has been identified.
      Returns:
      true if model is available
    • getLinearizationResult

      public LinearizationResult getLinearizationResult()
      Get the linearization result.
      Returns:
      the linearization result, or null if not identified
    • updateMeasurements

      public void updateMeasurements()
      Update CV measurements from the process.
    • updateDisturbances

      public void updateDisturbances()
      Update DV measurements from the process.
    • calculate

      public double[] calculate()
      Calculate the next MV moves.
      Returns:
      array of MV move values
    • calculateLinear

      private double[] calculateLinear()
    • applyMoves

      public void applyMoves()
      Apply the calculated MV moves to the process.
    • runProcess

      public void runProcess()
      Run the process simulation.
    • step

      public double[] step()
      Execute one complete control step: calculate, apply, and run.
      Returns:
      the applied MV values
    • updateModel

      public void updateModel()
      Update the process model at current operating point.
    • exportModel

      public StateSpaceExporter exportModel()
      Export the model to a state-space representation.
      Returns:
      a StateSpaceExporter for export operations
    • getLastMoves

      public double[] getLastMoves()
      Get the last calculated moves.
      Returns:
      copy of last moves, or null if none calculated
    • setSetpoint

      public void setSetpoint(String cvName, double setpoint)
      Set a CV setpoint.
      Parameters:
      cvName - the CV name
      setpoint - the new setpoint
    • getCurrentCVs

      public double[] getCurrentCVs()
      Get current CV values.
      Returns:
      array of current CV values
    • getCurrentMVs

      public double[] getCurrentMVs()
      Get current MV values.
      Returns:
      array of current MV values
    • getName

      public String getName()
      Get the controller name.
      Returns:
      the name
    • getConfigurationSummary

      public String getConfigurationSummary()
      Get a summary of the controller configuration.
      Returns:
      configuration summary string
    • createIndustrialExporter

      public IndustrialMPCExporter createIndustrialExporter()
      Create an industrial MPC exporter for this controller.

      The exporter can generate model files in formats compatible with industrial MPC platforms, including step response models, gain matrices, and variable configurations.

      Returns:
      a new IndustrialMPCExporter instance
    • createDataExchange

      public ControllerDataExchange createDataExchange()
      Create a data exchange interface for real-time integration.

      The data exchange interface provides standardized methods for bidirectional communication with external control systems, including timestamped data vectors, quality flags, and execution status.

      Returns:
      a new ControllerDataExchange instance
    • createSubrModlExporter

      public SubrModlExporter createSubrModlExporter()
      Create a SubrModl exporter for nonlinear MPC integration.

      The SubrModl exporter generates configuration files compatible with industrial nonlinear MPC systems that use programmed model objects. This includes SubrXvr definitions with DtaIx mappings, model parameters, and state variables.

      Returns:
      a new SubrModlExporter instance populated from this controller
    • toString

      public String toString()
      Overrides:
      toString in class Object