Skip to content

Report cause of infeasibility - #2398

Merged
verheem merged 27 commits into
mainfrom
report-cause-of-infeasibility
Jul 1, 2025
Merged

verheem merged 27 commits into
mainfrom
report-cause-of-infeasibility

Conversation

@verheem

@verheem verheem commented Jun 24, 2025 •

Copy link
Copy Markdown
Contributor

Fixes #2328

The cause of the infeasibility is determined by solving the same optimization problem, with relaxed constraints.
The violation of the constraints is minimized, and so we find the least violating constraint to make the problem feasible.

Next we check which variables contribute in this constraint, and report all other constraints that also contain these variables. This way we get a set of possible conflicting constraints, and log the value of each variable.

We only relax the volume- and flow conservation constraints. This makes sure that we immediately know at which node/edge the constraints are violated.

@verheem
verheem marked this pull request as ready for review June 24, 2025 12:42

@SouthEndMusic SouthEndMusic left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this work, this will be very helpful for debugging allocation. I left some small comments, nothing major.

Comment thread core/src/allocation_optim.jl Resolved
Comment thread core/src/allocation_optim.jl Resolved
Comment thread core/src/allocation_optim.jl Resolved
Comment thread core/src/allocation_optim.jl Resolved
Comment thread core/src/allocation_optim.jl Resolved
Comment thread core/src/allocation_util.jl Resolved
Comment thread core/test/allocation_physics_test.jl Resolved
Comment thread core/test/allocation_physics_test.jl Resolved
Co-authored-by: Bart de Koning <74617371+SouthEndMusic@users.noreply.github.com>
Comment thread core/src/allocation_optim.jl Resolved
Comment thread core/src/allocation_optim.jl Resolved

@SouthEndMusic SouthEndMusic left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overal this looks good! I left some final comments. There's also a failing test

Comment thread core/src/allocation_util.jl Resolved
Comment thread core/src/allocation_util.jl Resolved
Comment thread core/src/allocation_util.jl Resolved
Comment thread core/src/allocation_util.jl Resolved
nonzero_slack_count += 1

@info "infeasible constraint: $constraint"
@info " ______________________________________________________________________________________________"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mister logging @evetion is this OK?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really. The logging system has its own formatting to avoid the need for this. Also you don't know how wide the console is, so this may overflow to multiple lines.

julia> @info "Something happened." pi sin(pi) cos(pi) x=sqrt(9)
┌ Info: Something happened.
│   pi = π = 3.1415926535897...
│   sin(pi) = 0.0
│   cos(pi) = -1.0
└   x = 3.0

Comment thread core/src/allocation_util.jl Resolved
Comment thread core/src/allocation_util.jl Resolved
Comment thread core/src/allocation_util.jl Resolved
@verheem
verheem merged commit 5f0368a into main Jul 1, 2025
@verheem
verheem deleted the report-cause-of-infeasibility branch July 1, 2025 09:27

@jarsarasty jarsarasty left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The infeasibility detection/reporting feature is currently documented in inline code comments and log outputs. It is clear, well-structured, and suitable for developers.

To improve usability, consider adding a section to the Quarto-based documentation detailing:

  • How the model reports infeasibility
  • Where users can find these logs
  • How to interpret them
  • Practical troubleshooting steps for model infeasibility.

Moreover, mentioning this improvement briefly in the main README or in a troubleshooting guide would also help more users benefit from it.

verheem added a commit that referenced this pull request Jul 1, 2025
Fixes #2328

The cause of the infeasibility is determined by solving the same
optimization problem, with relaxed constraints.
The violation of the constraints is minimized, and so we find the least
violating constraint to make the problem feasible.

Next we check which variables contribute in this constraint, and report
all other constraints that also contain these variables. This way we get
a set of possible conflicting constraints, and log the value of each
variable.

We only relax the volume- and flow conservation constraints. This makes
sure that we immediately know at which node/edge the constraints are
violated.

---------

Co-authored-by: Bart de Koning <74617371+SouthEndMusic@users.noreply.github.com>
Co-authored-by: Jesús A. Rodríguez <jesusandres.rodriguez@deltares.nl>
Co-authored-by: Martijn Visser <mgvisser@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allocation infeasibility handling

4 participants