Skip to content

fix: LP objective without a live term writes a zero term instead of a phantom x - #1177

Draft
FabianHofmann wants to merge 2 commits into
masterfrom
claude/vigilant-einstein-vz4l34
Draft

FabianHofmann wants to merge 2 commits into
masterfrom
claude/vigilant-einstein-vz4l34

Conversation

@FabianHofmann

@FabianHofmann FabianHofmann commented Nov 18, 2026 •

Copy link
Copy Markdown
Collaborator

Closes #1176.

Changes proposed in this Pull Request

Note

The following content was generated by AI.

When the objective has no live term, objective_to_file writes +0.0 x<first live label>.

  • Before, an all-masked objective wrote a bare x, which the solution parser could not map back to a label (all LP solvers).
  • An empty obj: section is no option: GLPK rejects it ("missing variable name"). That already broke m.add_objective(0 * x) with GLPK on master. A constant (obj: +0.0) fails too: GLPK rejects it, and Gurobi reads 0.0 as a variable name.
  • Test test_objective_without_live_terms covers an all-masked objective and 0 * x over all params. On master, 14 of 52 cases fail; with this PR, all pass.
Local checks

Checklist

  • AI-generated content is marked (see AGENTS.md).
  • Code changes are sufficiently documented; i.e. new functions contain docstrings and further explanations may be given in doc.
  • Unit tests for new features were added (if applicable).
  • A note for the release notes doc/release-notes.md of the upcoming release is included.
  • I consent to the release of this PR's code under the MIT license.

…live variable

An objective whose variables are all masked is constant, so its polars
frame holds one row with null vars. The LP writer formatted that row as a
bare `x`, which the solver read as a new column and the solution parser
could not map back to a label.

Closes #1176
@codspeed

codspeed Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 181 untouched benchmarks
⏩ 181 skipped benchmarks1


Comparing claude/vigilant-einstein-vz4l34 (38b3a98) with master (cfedd1e)

Open in CodSpeed

Footnotes

  1. 181 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

GLPK rejects an LP file whose objective section holds no term, which
an all-masked objective or 0 * x produces. Write a zero-coefficient
term on the first live variable instead. The test now also pins x to a
unique optimum, as a zero objective left SCIP free to return any x >= 1.
@FabianHofmann FabianHofmann changed the title fix: write no objective term to an LP file when the objective has no live variable fix: LP objective without a live term writes a zero term instead of a phantom x Nov 18, 2026

This branch has not been deployed

No deployments
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.

LP solve fails with invalid literal for int() when the objective has no live variable term

2 participants