Skip to content

[BUG] Reduced cost computation error for maximization problem #271

@Iroy30

Description

@Iroy30

Describe the bug
The RC values are computed wrong when objective sense is set to maximize

Steps/Code to reproduce bug
MPS File: RCBug.mps.zip

from cuopt.linear_programming import DataModel, Solve, SolverSettings
import numpy as np
from cuopt_mps_parser import ParseMps
dm = ParseMps("Bug2.mps")
sol = Solve(dm)
print("OBJECTIVE: - x[1] + x[2] - x[3] + x[4] - x[5] + x[6] - x[7] + x[8] - x[9] + x[10] - x[11] + x[12] , maximize")
print("PRIMAL SOLUTION: ", sol.get_primal_solution())
print("REDUCED COST: ", sol.get_reduced_cost())

Output:

Solving a problem with 12 constraints 12 variables (0 integers) and 12 nonzeros
Objective offset -0.000000 scaling_factor -1.000000
Running concurrent

Dual simplex finished in 0.00 seconds
   Iter    Primal Obj.      Dual Obj.    Gap        Primal Res.  Dual Res.   Time
      0 -0.00000000e+00 +2.00000000e+00  2.00e+00   2.83e+00     3.16e+00   0.014s
PDLP finished
Concurrent time:  0.015s
Solved with dual simplex
Status: Optimal   Objective: 4.00000000e+00  Iterations: 12  Time: 0.015s
OBJECTIVE: - x[1] + x[2] - x[3] + x[4] - x[5] + x[6] - x[7] + x[8] - x[9] + x[10] - x[11] + x[12] , maximize
PRIMAL SOLUTION:  [-1.  1. -1.  1. -1. -1.  1.  1. -1. -1.  1.  1.]
REDUCED COST:  [ 1. -1.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.]

Expected behavior
REDUCED COST: [ -1. 1. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions