Interface ProcessConstraint
- All Known Implementing Classes:
CapacityConstraintAdapter, ProcessSimulationEvaluator.ConstraintDefinition, ProductionOptimizer.OptimizationConstraint
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:
ProductionOptimizer.OptimizationConstraint— functional constraints on process-level metricsProcessSimulationEvaluator.ConstraintDefinition— NLP-style bounds for external optimizers- Equipment capacity constraints via
CapacityConstraintAdapter
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 TypeMethodDescriptiondefault StringReturns 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.default booleanisHard()Checks if this is a hard constraint that makes the solution infeasible when violated.default booleanisSatisfied(ProcessSystem process) Checks if this constraint is satisfied for the given process state.doublemargin(ProcessSystem process) Computes the constraint margin for the given process state.default doublepenalty(ProcessSystem process) Computes the penalty for the current constraint violation.
-
Method Details
-
getName
-
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)
- Parameters:
process- the process system in its current state (already run)- Returns:
- constraint margin (positive = satisfied, negative = violated)
-
isSatisfied
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
ConstraintSeverityLevelenum 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
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
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
-