Skip to content

Fix: handle MPS OBJSENSE MAXIMIZE in reader#93

Open
LucasBoTang wants to merge 1 commit into
MIT-Lu-Lab:mainfrom
LucasBoTang:fix/mps-objsense-maximize
Open

Fix: handle MPS OBJSENSE MAXIMIZE in reader#93
LucasBoTang wants to merge 1 commit into
MIT-Lu-Lab:mainfrom
LucasBoTang:fix/mps-objsense-maximize

Conversation

@LucasBoTang

Copy link
Copy Markdown
Collaborator

Fixes #92.

Problem

Two bugs in src/mps_parser.c made every maximization MPS instance silently wrong (status OPTIMAL, no warning) — full write-up in #92.

  1. Wrong optimum. The OBJSENSE value line (MAXIMIZE) is a single token, which the section detector consumed as a (bogus) header, so is_maximize was never set and the problem was solved as a minimization.
  2. Wrong reported objective sign. The parser negates the objective to convert max→min, but the sense was a parser-local flag that was never propagated, so the reported objective kept the wrong sign.

Fix

  • Treat a single token as a section header only when it matches a known section keyword; otherwise fall through to the section handler, so the OBJSENSE value reaches case SEC_OBJSENSE.
  • Carry the sense on lp_problem_t (objective_sense_t objective_sense), derive it once into objective_sign on the solver state, and apply it when reporting the primal/dual objectives (and in the presolve postsolve path).

Verification

  • maximize x s.t. x <= 5x = 5, objective = 5 (previously x = 0, obj = 0)
  • a minimization instance is unchanged
  • builds clean; both the main-solver and presolve paths report the correct sign

@ZedongPeng

Copy link
Copy Markdown
Collaborator

We might also need to support the same line section declaration.
https://github.com/scipopt/scip/blob/f8a5aa2ac5681bbbdf41be6e491f7d0c3e84299d/src/scip/reader_mps.c#L788-L799

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.

MPS reader mishandles OBJSENSE: maximization is solved as minimization and reported with the wrong objective sign

2 participants