Commit 86baf59
feat(model): allow {0,1} bounds for binaries in add_variables (#778)
* fix(io): write LP bounds for tightened binary variables
Per-element bounds set below the implied [0, 1] on a binary variable
(e.g. masking out entries with upper = 0) were silently dropped by the LP
file export: binaries appeared only in the `binary` section. The direct
API honored them, so the same model relaxed when solved through
io_api="lp". bounds_to_file now emits a bounds row for any binary whose
bounds differ from (0, 1) anywhere, matching the direct path.
Closes #776
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* docs: tone down binary-bounds release note
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* feat(model): allow {0,1} bounds for binaries in add_variables
Binary bounds could previously only be set via the .lower/.upper setters
after creation; add_variables(binary=True, ...) raised on any lower/upper.
Now it accepts bounds as long as every value is 0 or 1 (unset bounds still
default to 0/1), and validates the rest.
Refs #776
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* test: group LP binary-bounds tests into a class with a shared factory fixture
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* test: add type annotations to binary bounds test params
---------
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-authored-by: Fabian <fab.hof@gmx.de>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>1 parent 081cd8b commit 86baf59
3 files changed
Lines changed: 75 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
9 | 13 | | |
10 | 14 | | |
11 | 15 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
620 | 620 | | |
621 | 621 | | |
622 | 622 | | |
623 | | - | |
624 | | - | |
| 623 | + | |
| 624 | + | |
625 | 625 | | |
626 | | - | |
627 | | - | |
| 626 | + | |
| 627 | + | |
628 | 628 | | |
629 | 629 | | |
630 | 630 | | |
| |||
773 | 773 | | |
774 | 774 | | |
775 | 775 | | |
776 | | - | |
777 | | - | |
778 | | - | |
779 | | - | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
780 | 784 | | |
781 | 785 | | |
782 | 786 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
| 7 | + | |
6 | 8 | | |
7 | 9 | | |
8 | 10 | | |
| |||
248 | 250 | | |
249 | 251 | | |
250 | 252 | | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
251 | 310 | | |
252 | 311 | | |
253 | 312 | | |
| |||
0 commit comments