Class CapacityConstraintAdapter

java.lang.Object
neqsim.process.util.optimizer.CapacityConstraintAdapter
All Implemented Interfaces:
ProcessConstraint

public class CapacityConstraintAdapter extends Object implements ProcessConstraint
Adapts equipment-level CapacityConstraint instances to the unified ProcessConstraint interface.

This adapter bridges the equipment capacity layer with the optimization constraint layer, allowing equipment-level physical limits (compressor surge, separator flooding, pipe velocity, etc.) to be consumed by any optimizer — both internal NeqSim optimizers and external solvers such as SciPy, NLopt, or Pyomo.

Margin convention: A positive margin means the constraint is satisfied (within capacity). Specifically, margin = 1.0 - utilization, where utilization is currentValue / designValue.

Example:

// Wrap an equipment constraint for use with any optimizer
CapacityConstraint speedLimit = compressor.getCapacityConstraints().get("speed");
ProcessConstraint unified = new CapacityConstraintAdapter("Compressor1/speed", speedLimit);

double margin = unified.margin(processSystem); // positive = ok
boolean ok = unified.isSatisfied(processSystem); // true if within limit
ConstraintSeverityLevel level = unified.getSeverityLevel(); // HARD, SOFT, etc.
Version:
1.0
Author:
NeqSim Development Team
See Also:
  • Field Details

    • delegate

      private final CapacityConstraint delegate
      The wrapped equipment capacity constraint.
    • qualifiedName

      private final String qualifiedName
      Qualified name (typically "equipmentName/constraintName").
    • DEFAULT_PENALTY_WEIGHT

      private static final double DEFAULT_PENALTY_WEIGHT
      Default penalty weight for capacity constraints.
      See Also:
    • penaltyWeight

      private double penaltyWeight
      Custom penalty weight (negative means use default).
  • Constructor Details

    • CapacityConstraintAdapter

      public CapacityConstraintAdapter(String qualifiedName, CapacityConstraint delegate)
      Creates an adapter wrapping the given capacity constraint.
      Parameters:
      qualifiedName - qualified name for this constraint (e.g., "Compressor1/speed")
      delegate - the equipment capacity constraint to wrap
      Throws:
      IllegalArgumentException - if qualifiedName or delegate is null
    • CapacityConstraintAdapter

      public CapacityConstraintAdapter(String qualifiedName, CapacityConstraint delegate, double penaltyWeight)
      Creates an adapter with a custom penalty weight.
      Parameters:
      qualifiedName - qualified name for this constraint
      delegate - the equipment capacity constraint to wrap
      penaltyWeight - custom penalty weight (must be non-negative)
      Throws:
      IllegalArgumentException - if arguments are invalid
  • Method Details

    • getName

      public String getName()
      Returns the name of this constraint.

      Returns the qualified name (e.g., "Compressor1/speed").

      Specified by:
      getName in interface ProcessConstraint
      Returns:
      constraint name, never null
    • margin

      public double margin(ProcessSystem process)
      Computes the constraint margin for the given process state.

      Convention:

      • margin >= 0 means the constraint is satisfied
      • margin < 0 means the constraint is violated (more negative = worse)

      Margin is computed as 1.0 - utilization, where utilization is the equipment's current operating point relative to its design value. A value of 0.2 means 20% headroom remains.

      Specified by:
      margin in interface ProcessConstraint
      Parameters:
      process - the process system (not used for value lookup, since the underlying CapacityConstraint has its own value supplier; the process must have been run so equipment state is current)
      Returns:
      margin (positive = satisfied, negative = violated)
    • getSeverityLevel

      public ConstraintSeverityLevel getSeverityLevel()
      Returns the severity of this constraint.

      Uses the unified ConstraintSeverityLevel enum that maps across all constraint types.

      Maps from the 4-level CapacityConstraint.ConstraintSeverity to the unified ConstraintSeverityLevel.

      Specified by:
      getSeverityLevel in interface ProcessConstraint
      Returns:
      constraint severity level
    • getPenaltyWeight

      public double getPenaltyWeight()
      Returns the penalty weight for this constraint.

      Higher weight means constraint violations are penalized more strongly in penalty-based optimization methods.

      Specified by:
      getPenaltyWeight in interface ProcessConstraint
      Returns:
      penalty weight (non-negative)
    • getDescription

      public String getDescription()
      Returns a human-readable description of this constraint.
      Specified by:
      getDescription in interface ProcessConstraint
      Returns:
      constraint description, may be empty but never null
    • getDelegate

      public CapacityConstraint getDelegate()
      Returns the underlying equipment capacity constraint.
      Returns:
      the wrapped CapacityConstraint
    • getUtilization

      public double getUtilization()
      Returns the current utilization of the equipment for this constraint.
      Returns:
      utilization as fraction (1.0 = 100% of design)
    • getUnit

      public String getUnit()
      Returns the unit of measurement for the underlying constraint.
      Returns:
      unit string