Interface ProcessConstraint

All Known Implementing Classes:
CapacityConstraintAdapter, ProcessSimulationEvaluator.ConstraintDefinition, ProductionOptimizer.OptimizationConstraint

public interface ProcessConstraint
Unified constraint interface for process optimization.

This interface provides a common contract for constraints used by both internal NeqSim optimizers (ProductionOptimizer, ProcessOptimizationEngine) and external optimizers (SciPy, NLopt, Pyomo, etc.) through ProcessSimulationEvaluator.

All constraint types in the system implement this interface:

Convention: margin is positive when satisfied, negative when violated. margin(process) >= 0 means the constraint is satisfied.

Example for external SciPy optimizer:

// Java side: build constraint vector from ProcessConstraint list
List<ProcessConstraint> allConstraints = evaluator.getAllProcessConstraints();
double[] margins = new double[allConstraints.size()];
for (int i = 0; i < allConstraints.size(); i++) {
  margins[i] = allConstraints.get(i).margin(process);
}
// margins array is the g(x) >= 0 vector for NLP solvers
Version:
1.0
Author:
NeqSim Development Team
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    default String
    Returns a human-readable description of this constraint.
    Returns the name of this constraint.
    double
    Returns the penalty weight for this constraint.
    Returns the severity of this constraint.
    default boolean
    Checks if this is a hard constraint that makes the solution infeasible when violated.
    default boolean
    Checks if this constraint is satisfied for the given process state.
    double
    Computes the constraint margin for the given process state.
    default double
    Computes the penalty for the current constraint violation.
  • Method Details

    • getName

      String getName()
      Returns the name of this constraint.
      Returns:
      constraint name, never null
    • margin

      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)
      Parameters:
      process - the process system in its current state (already run)
      Returns:
      constraint margin (positive = satisfied, negative = violated)
    • isSatisfied

      default boolean isSatisfied(ProcessSystem process)
      Checks if this constraint is satisfied for the given process state.

      Default implementation returns margin(process) >= 0.

      Parameters:
      process - the process system
      Returns:
      true if satisfied
    • getSeverityLevel

      ConstraintSeverityLevel getSeverityLevel()
      Returns the severity of this constraint.

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

      Returns:
      constraint severity level
    • getPenaltyWeight

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

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

      Returns:
      penalty weight (non-negative)
    • penalty

      default double penalty(ProcessSystem process)
      Computes the penalty for the current constraint violation.

      Returns 0 when satisfied, positive value proportional to violation magnitude when violated. Default implementation uses quadratic penalty: weight * margin^2.

      Parameters:
      process - the process system
      Returns:
      penalty value (0 if satisfied, positive if violated)
    • getDescription

      default String getDescription()
      Returns a human-readable description of this constraint.
      Returns:
      constraint description, may be empty but never null
    • isHard

      default boolean isHard()
      Checks if this is a hard constraint that makes the solution infeasible when violated.
      Returns:
      true if CRITICAL or HARD severity