Fix: handle MPS OBJSENSE MAXIMIZE in reader#93
Conversation
|
We might also need to support the same line section declaration. |
|
@ZedongPeng |
… MPS reader Keep problems in their original sense and normalize max→min once inside the core, reporting results back in the caller's sense (replaces the scattered sign-flipping that caused objective/dual-sign bugs).
|
6fc8b81 makes objective-sense handling consistent across the whole stack. Previously the maximize→minimize sign flip was applied in several different places (MPS parser, Python layer, presolve), which caused the objective/dual-sign bugs (e.g. the objective-constant issue in #90). DesignKeep every problem in its original objective sense end-to-end, normalize maximize → minimize exactly once inside the core ( What changed
TestsFixed the maximize dual-solution signs in |
|
Example: Log of 5329a0e $ ./build/cupdlpx bigmax.mps test/ -v
---------------------------------------------------------------------------------------
cuPDLPx v0.2.9
A GPU-Accelerated First-Order LP Solver
(c) Haihao Lu, Massachusetts Institute of Technology, 2025
---------------------------------------------------------------------------------------
Problem: 5 rows, 6 columns, 30 nonzeros
Settings:
iter_limit : 2147483647
time_limit : 3600.00 sec
eps_opt : 1.0e-04
eps_feas : 1.0e-04
spmv_backend : cusparseSpMVOp (auto)
Running presolver (PSLP v0.0.8)...
status : UNCHANGED
presolve time : 0.000277 sec
reduced problem : 5 rows, 6 columns, 30 nonzeros
Preconditioning
Ruiz scaling (10 iterations)
Pock-Chambolle scaling (alpha=1.0000)
Bound-objective scaling
---------------------------------------------------------------------------------------
runtime | objective | absolute residuals | relative residuals
iter time | pr obj du obj | pr res du res gap | pr res du res gap
---------------------------------------------------------------------------------------
0 0.0e+00 | 0.0e+00 0.0e+00 | 0.0e+00 0.0e+00 0.0e+00 | 0.0e+00 0.0e+00 0.0e+00
200 0.0e+00 | -1.4e+02 -1.4e+02 | 2.0e-01 4.0e-02 8.5e-01 | 2.5e-03 3.1e-03 3.0e-03
400 6.4e-03 | -1.4e+02 -1.4e+02 | 8.9e-04 3.5e-04 1.6e-03 | 1.1e-05 2.8e-05 5.8e-06
---------------------------------------------------------------------------------------
Solution Summary
Status : OPTIMAL
Presolve time : 0.000277 sec
Precondition time : 0.001526 sec
Solve time : 0.00884 sec
Iterations : 400
Primal objective : 140.0019964
Dual objective : 140.0003713
Objective gap : 5.783e-06
Primal infeas : 1.124e-05
Dual infeas : 2.771e-05Log of acc8205 $ ./build/cupdlpx bigmax.mps test/ -v
---------------------------------------------------------------------------------------
cuPDLPx v0.2.9
A GPU-Accelerated First-Order LP Solver
(c) Haihao Lu, Massachusetts Institute of Technology, 2025
---------------------------------------------------------------------------------------
Problem: 5 rows, 6 columns, 30 nonzeros
Settings:
iter_limit : 2147483647
time_limit : 3600.00 sec
eps_opt : 1.0e-04
eps_feas : 1.0e-04
spmv_backend : cusparseSpMVOp (auto)
Running presolver (PSLP v0.0.8)...
status : UNCHANGED
presolve time : 0.000214 sec
reduced problem : 5 rows, 6 columns, 30 nonzeros
Preconditioning
Ruiz scaling (10 iterations)
Pock-Chambolle scaling (alpha=1.0000)
Bound-objective scaling
---------------------------------------------------------------------------------------
runtime | objective | absolute residuals | relative residuals
iter time | pr obj du obj | pr res du res gap | pr res du res gap
---------------------------------------------------------------------------------------
0 0.0e+00 | -0.0e+00 -0.0e+00 | 0.0e+00 0.0e+00 0.0e+00 | 0.0e+00 0.0e+00 0.0e+00
200 0.0e+00 | 1.4e+02 1.4e+02 | 2.0e-01 4.0e-02 8.5e-01 | 2.5e-03 3.1e-03 3.0e-03
400 6.3e-03 | 1.4e+02 1.4e+02 | 8.9e-04 3.5e-04 1.6e-03 | 1.1e-05 2.8e-05 5.8e-06
---------------------------------------------------------------------------------------
Solution Summary
Status : OPTIMAL
Presolve time : 0.000214 sec
Precondition time : 0.001596 sec
Solve time : 0.00867 sec
Iterations : 400
Primal objective : 140.0019964
Dual objective : 140.0003713
Objective gap : 5.783e-06
Primal infeas : 1.124e-05
Dual infeas : 2.771e-05 |
|
Hi @ZedongPeng , I pushed two commits (959a783, efa3b9d) on top of your objective-sense refactor. The overall approach looks great. My changes are mostly API/test cleanup:
|
Fixes #92.
Problem
Two bugs in
src/mps_parser.cmade every maximization MPS instance silently wrong (statusOPTIMAL, no warning) — full write-up in #92.OBJSENSEvalue line (MAXIMIZE) is a single token, which the section detector consumed as a (bogus) header, sois_maximizewas never set and the problem was solved as a minimization.Fix
OBJSENSEvalue reachescase SEC_OBJSENSE.lp_problem_t(objective_sense_t objective_sense), derive it once intoobjective_signon the solver state, and apply it when reporting the primal/dual objectives (and in the presolve postsolve path).Verification
maximize x s.t. x <= 5→x = 5, objective = 5(previouslyx = 0, obj = 0)