diff --git a/cpp/src/mip/problem/problem_helpers.cuh b/cpp/src/mip/problem/problem_helpers.cuh index 2104f7eaf..ddb9cbe7e 100644 --- a/cpp/src/mip/problem/problem_helpers.cuh +++ b/cpp/src/mip/problem/problem_helpers.cuh @@ -138,7 +138,6 @@ static void convert_to_maximization_problem(detail::problem_t& op_prob // negating objective coeffs op_problem.presolve_data.objective_scaling_factor = -op_problem.presolve_data.objective_scaling_factor; - op_problem.presolve_data.objective_offset = -op_problem.presolve_data.objective_offset; } /* diff --git a/cpp/tests/linear_programming/pdlp_test.cu b/cpp/tests/linear_programming/pdlp_test.cu index 212e4e1d3..a9e042812 100644 --- a/cpp/tests/linear_programming/pdlp_test.cu +++ b/cpp/tests/linear_programming/pdlp_test.cu @@ -906,6 +906,42 @@ TEST(pdlp_class, run_empty_matrix_dual_simplex) EXPECT_FALSE(solution.get_additional_termination_information().solved_by_pdlp); } +TEST(pdlp_class, test_max) +{ + const raft::handle_t handle_{}; + + auto path = make_path_absolute("linear_programming/good-max.mps"); + cuopt::mps_parser::mps_data_model_t op_problem = + cuopt::mps_parser::parse_mps(path); + + auto solver_settings = pdlp_solver_settings_t{}; + solver_settings.method = cuopt::linear_programming::method_t::PDLP; + + optimization_problem_solution_t solution = + solve_lp(&handle_, op_problem, solver_settings); + EXPECT_EQ((int)solution.get_termination_status(), CUOPT_TERIMINATION_STATUS_OPTIMAL); + EXPECT_NEAR( + solution.get_additional_termination_information().primal_objective, 17.0, factor_tolerance); +} + +TEST(pdlp_class, test_max_with_offset) +{ + const raft::handle_t handle_{}; + + auto path = make_path_absolute("linear_programming/max_offset.mps"); + cuopt::mps_parser::mps_data_model_t op_problem = + cuopt::mps_parser::parse_mps(path); + + auto solver_settings = pdlp_solver_settings_t{}; + solver_settings.method = cuopt::linear_programming::method_t::PDLP; + + optimization_problem_solution_t solution = + solve_lp(&handle_, op_problem, solver_settings); + EXPECT_EQ((int)solution.get_termination_status(), CUOPT_TERIMINATION_STATUS_OPTIMAL); + EXPECT_NEAR( + solution.get_additional_termination_information().primal_objective, 0.0, factor_tolerance); +} + } // namespace cuopt::linear_programming::test CUOPT_TEST_PROGRAM_MAIN() diff --git a/datasets/linear_programming/good-max.mps b/datasets/linear_programming/good-max.mps new file mode 100644 index 000000000..dbf3249d7 --- /dev/null +++ b/datasets/linear_programming/good-max.mps @@ -0,0 +1,19 @@ +NAME MAXEX +OBJSENSE + MAX +ROWS + N OBJ + L LIM1 +COLUMNS + X1 OBJ 2 LIM1 1 + X2 OBJ 3 LIM1 2 + X3 OBJ 1 LIM1 1 +RHS + RHS1 LIM1 10 +BOUNDS + LO BND1 X1 0 + UP BND1 X1 4 + LO BND1 X2 0 + UP BND1 X2 6 + LO BND1 X3 0 +ENDATA \ No newline at end of file diff --git a/datasets/linear_programming/max_offset.mps b/datasets/linear_programming/max_offset.mps new file mode 100644 index 000000000..99ee7a69f --- /dev/null +++ b/datasets/linear_programming/max_offset.mps @@ -0,0 +1,25 @@ +NAME +OBJSENSE + MAXIMIZE +ROWS + N OBJ + L c1 +COLUMNS + x1 c1 3 + x1 OBJ 1 + x2 c1 2 + x2 OBJ 2 + x3 c1 1 + x3 OBJ 3 +RHS + rhs c1 2 + rhs OBJ 4 +RANGES +BOUNDS + LO bounds x1 0 + PL bounds x1 + LO bounds x2 0 + PL bounds x2 + LO bounds x3 0 + UP bounds x3 1 +ENDATA \ No newline at end of file