-
-
Notifications
You must be signed in to change notification settings - Fork 238
Description
Problem:
When defining variables with bounds using @variables (e.g., @variables x [bounds=(0, 1)]), these bounds are not enforced during nonlinear equation solving with NonlinearSolve.jl. This leads to solutions violating the specified physical/domain constraints, requiring manual post-solution checks.
Expected Behavior:
Bounds defined in variable metadata should automatically constrain the solution space. For example, a variable with bounds=(0, 1) should only accept solutions within [0, 1], either via:
Automatic variable transformation (e.g., logit transforms for (0,1))
Constraint-aware nonlinear solvers
Clear warnings/errors if bounds are ignored
Alternatives Considered:
Manually adding penalty functions to equations (cumbersome and solver-dependent)
Post-processing solutions to check bounds (defeats the purpose of declarative modeling)
Context:
Example use case:
julia
@variables z[1:numcomp] [bounds=(0,1), guess=0.2]
@variables T [bounds=(100,500), guess=298.15]
Suggested Path:
Add bounds validation/transforms in MTK variable processing
Integrate with constrained nonlinear solvers (e.g., via NonlinearSolve.jl or Optimization.jl)
At minimum, throw clear warnings when bounds are declared but unused