feat: add sign parameter to add_piecewise_formulation#662
feat: add sign parameter to add_piecewise_formulation#662FBumann wants to merge 13 commits intoPyPSA:feat/piecewise-api-refactorfrom
Conversation
Adds "==" (default), "<=", and ">=" as a uniform modifier on the link constraint. Works for N-variable formulations — sign applies symmetrically to all expressions, bounding the operating point above/below the curve. For 2-var convex/concave cases, users can still use tangent_lines() for pure LP. This adds the inequality option for non-convex cases and for N-variable feasible-region modelling. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
for more information, see https://pre-commit.ci
Walks through the dominated region vs hypograph distinction, shows per-tuple sign options, and argues the sign parameter exposes complexity that should stay hidden. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
for more information, see https://pre-commit.ci
Adds a second pair of plots showing that per-tuple signs ((x, ==) + (y, <=) and (x, >=) + (y, <=)) recover the hypograph — demonstrates why the "fix" requires per-tuple signs, not just a uniform flag. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
for more information, see https://pre-commit.ci
Shows each segment's chord extended across the domain. The pointwise min of all chords (tangent_lines bound) equals f(x) inside the domain, visually explaining why tangent_lines gives the hypograph. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
for more information, see https://pre-commit.ci
Shows feasible regions for every (sign_x, sign_y) pair, plus prose on which matches user intent. Notes that (==, <=) is the clean choice for "y bounded by f(x) in operating range". Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
for more information, see https://pre-commit.ci
The chord lines extend infinitely, so the tangent_lines feasible region continues past x_0 and x_n. Prose now points out this extrapolation and suggests using variable bounds for hard domain cutoffs. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
for more information, see https://pre-commit.ci
Clarification on Looking at the current def tangent_lines(x, x_points, y_points):
# ... computes slopes, intercepts
return slopes * _to_linexpr(x) + interceptsIt returns a So in the visualisation, the feasible region continues past In the pre-refactor code, Why this matters for the sign discussionNone of the
This nudges toward folding tangent_lines into
|
Add a side-by-side showing both tight uses of tangent_lines (concave + <= giving hypograph, convex + >= giving epigraph), with the rejectable mismatched directions overlaid in red. Annotate each region with what it represents. Also extend the earlier chord-bounds plot with a companion showing the effect of xmin/xmax variable bounds on feasibility. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
A exploratory artifact, superseeded by #663 |
Adds "==" (default), "<=", and ">=" as a uniform modifier on the link constraint. Works for N-variable formulations — sign applies symmetrically to all expressions, bounding the operating point above/below the curve.
For 2-var convex/concave cases, users can still use tangent_lines() for pure LP. This adds the inequality option for non-convex cases and for N-variable feasible-region modelling.
Closes # (if applicable).
Changes proposed in this Pull Request
Checklist
doc.doc/release_notes.rstof the upcoming release is included.