Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions cpp/cuopt_cli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ inline auto make_async() { return std::make_shared<rmm::mr::cuda_async_memory_re
*/
int run_single_file(const std::string& file_path,
const std::string& initial_solution_file,
bool solve_relaxation,
const std::map<std::string, std::string>& settings_strings)
{
const raft::handle_t handle_{};
Expand Down Expand Up @@ -131,7 +132,7 @@ int run_single_file(const std::string& file_path,
initial_solution_file, mps_data_model.get_variable_names());

try {
if (is_mip) {
if (is_mip && !solve_relaxation) {
auto& mip_settings = settings.get_mip_settings();
if (initial_solution.size() > 0) {
mip_settings.set_initial_solution(initial_solution.data(), initial_solution.size());
Expand Down Expand Up @@ -191,6 +192,11 @@ int main(int argc, char* argv[])
.help("path to the initial solution .sol file")
.default_value("");

program.add_argument("--relaxation")
.help("solve the LP relaxation of the MIP")
.default_value(false)
.implicit_value(true);

std::map<std::string, std::string> arg_name_to_param_name;
{
// Add all solver settings as arguments
Expand Down Expand Up @@ -257,8 +263,9 @@ int main(int argc, char* argv[])
std::string file_name = program.get<std::string>("filename");

const auto initial_solution_file = program.get<std::string>("--initial-solution");
const auto solve_relaxation = program.get<bool>("--relaxation");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this handle true false words as well? or just 0 and 1 ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It works like a flag. If you add --relaxation the value is true, if you don't add that option the value is false. I thought it should be different than the other parameter settings (since this is not a parameter).


auto memory_resource = make_async();
rmm::mr::set_current_device_resource(memory_resource.get());
return run_single_file(file_name, initial_solution_file, settings_strings);
return run_single_file(file_name, initial_solution_file, solve_relaxation, settings_strings);
}
20 changes: 18 additions & 2 deletions cpp/src/dual_simplex/crossover.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1217,6 +1217,15 @@ crossover_status_t crossover(const lp_problem_t<i_t, f_t>& lp,
std::vector<f_t> edge_norms;
dual::status_t status =
dual_phase2(2, 0, start_time, lp, settings, vstatus, solution, dual_iter, edge_norms);
if (toc(start_time) > settings.time_limit) {
settings.log.printf("Time limit exceeded\n");
return crossover_status_t::TIME_LIMIT;
}
if (settings.concurrent_halt != nullptr &&
settings.concurrent_halt->load(std::memory_order_acquire) == 1) {
settings.log.printf("Concurrent halt\n");
return crossover_status_t::CONCURRENT_LIMIT;
}
primal_infeas = primal_infeasibility(lp, settings, vstatus, solution.x);
dual_infeas = dual_infeasibility(lp, settings, vstatus, solution.z);
primal_res = primal_residual(lp, solution);
Expand Down Expand Up @@ -1337,6 +1346,15 @@ crossover_status_t crossover(const lp_problem_t<i_t, f_t>& lp,
std::vector<f_t> edge_norms;
dual::status_t status = dual_phase2(
2, iter == 0 ? 1 : 0, start_time, lp, settings, vstatus, solution, iter, edge_norms);
if (toc(start_time) > settings.time_limit) {
settings.log.printf("Time limit exceeded\n");
return crossover_status_t::TIME_LIMIT;
}
if (settings.concurrent_halt != nullptr &&
settings.concurrent_halt->load(std::memory_order_acquire) == 1) {
settings.log.printf("Concurrent halt\n");
return crossover_status_t::CONCURRENT_LIMIT;
}
solution.iterations += iter;
primal_infeas = primal_infeasibility(lp, settings, vstatus, solution.x);
dual_infeas = dual_infeasibility(lp, settings, vstatus, solution.z);
Expand All @@ -1345,7 +1363,6 @@ crossover_status_t crossover(const lp_problem_t<i_t, f_t>& lp,
if (status != dual::status_t::OPTIMAL) {
print_crossover_info(lp, settings, vstatus, solution, "Dual phase 2 complete");
}

primal_feasible = primal_infeas <= primal_tol && primal_res <= primal_tol;
dual_feasible = dual_infeas <= dual_tol && dual_res <= dual_tol;
} else {
Expand All @@ -1355,7 +1372,6 @@ crossover_status_t crossover(const lp_problem_t<i_t, f_t>& lp,

settings.log.printf("Crossover time %.2f seconds\n", toc(crossover_start));
settings.log.printf("Total time %.2f seconds\n", toc(start_time));
settings.log.printf("\n");

crossover_status_t status = crossover_status_t::NUMERICAL_ISSUES;
if (dual_feasible) { status = crossover_status_t::DUAL_FEASIBLE; }
Expand Down
1 change: 1 addition & 0 deletions cpp/src/linear_programming/solve.cu
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,7 @@ optimization_problem_solution_t<i_t, f_t> run_pdlp(detail::problem_t<i_t, f_t>&
info,
termination_status);
sol.copy_from(problem.handle_ptr, sol_crossover);
CUOPT_LOG_INFO("Crossover status %s", sol.get_termination_status_string().c_str());
}
if (crossover_info == 0 && settings.concurrent_halt != nullptr) {
// We finished. Tell dual simplex to stop if it is still running.
Expand Down