Class CapacityConstraintAdapter
- All Implemented Interfaces:
ProcessConstraint
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 Summary
FieldsModifier and TypeFieldDescriptionprivate static final doubleDefault penalty weight for capacity constraints.private final CapacityConstraintThe wrapped equipment capacity constraint.private doubleCustom penalty weight (negative means use default).private final StringQualified name (typically "equipmentName/constraintName"). -
Constructor Summary
ConstructorsConstructorDescriptionCapacityConstraintAdapter(String qualifiedName, CapacityConstraint delegate) Creates an adapter wrapping the given capacity constraint.CapacityConstraintAdapter(String qualifiedName, CapacityConstraint delegate, double penaltyWeight) Creates an adapter with a custom penalty weight. -
Method Summary
Modifier and TypeMethodDescriptionReturns the underlying equipment capacity constraint.Returns a human-readable description of this constraint.getName()Returns the name of this constraint.doubleReturns the penalty weight for this constraint.Returns the severity of this constraint.getUnit()Returns the unit of measurement for the underlying constraint.doubleReturns the current utilization of the equipment for this constraint.doublemargin(ProcessSystem process) Computes the constraint margin for the given process state.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ProcessConstraint
isHard, isSatisfied, penalty
-
Field Details
-
delegate
The wrapped equipment capacity constraint. -
qualifiedName
Qualified name (typically "equipmentName/constraintName"). -
DEFAULT_PENALTY_WEIGHT
private static final double DEFAULT_PENALTY_WEIGHTDefault penalty weight for capacity constraints.- See Also:
-
penaltyWeight
private double penaltyWeightCustom penalty weight (negative means use default).
-
-
Constructor Details
-
CapacityConstraintAdapter
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 constraintdelegate- the equipment capacity constraint to wrappenaltyWeight- custom penalty weight (must be non-negative)- Throws:
IllegalArgumentException- if arguments are invalid
-
-
Method Details
-
getName
Returns the name of this constraint.Returns the qualified name (e.g., "Compressor1/speed").
- Specified by:
getNamein interfaceProcessConstraint- Returns:
- constraint name, never null
-
margin
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:
marginin interfaceProcessConstraint- Parameters:
process- the process system (not used for value lookup, since the underlyingCapacityConstrainthas its own value supplier; the process must have been run so equipment state is current)- Returns:
- margin (positive = satisfied, negative = violated)
-
getSeverityLevel
Returns the severity of this constraint.Uses the unified
ConstraintSeverityLevelenum that maps across all constraint types.Maps from the 4-level
CapacityConstraint.ConstraintSeverityto the unifiedConstraintSeverityLevel.- Specified by:
getSeverityLevelin interfaceProcessConstraint- 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:
getPenaltyWeightin interfaceProcessConstraint- Returns:
- penalty weight (non-negative)
-
getDescription
Returns a human-readable description of this constraint.- Specified by:
getDescriptionin interfaceProcessConstraint- Returns:
- constraint description, may be empty but never null
-
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
Returns the unit of measurement for the underlying constraint.- Returns:
- unit string
-