From fe434eb494a1a0480b3bc45f00f6fe4dd2072876 Mon Sep 17 00:00:00 2001 From: Laurent Perron Date: Mon, 25 Nov 2024 20:46:51 +0100 Subject: [PATCH] DCHECK cp-sat subsolver status in routing --- ortools/routing/lp_scheduling.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ortools/routing/lp_scheduling.h b/ortools/routing/lp_scheduling.h index 7e84b1eb4f..96ca77c0a6 100644 --- a/ortools/routing/lp_scheduling.h +++ b/ortools/routing/lp_scheduling.h @@ -591,7 +591,9 @@ class RoutingCPSatWrapper : public RoutingLinearSolverWrapper { model_.mutable_constraints(ct)->add_enforcement_literal(condition); } DimensionSchedulingStatus Solve(absl::Duration duration_limit) override { - parameters_.set_max_time_in_seconds(absl::ToDoubleSeconds(duration_limit)); + const double max_time = absl::ToDoubleSeconds(duration_limit); + if (max_time <= 0.0) return DimensionSchedulingStatus::INFEASIBLE; + parameters_.set_max_time_in_seconds(max_time); VLOG(2) << ProtobufDebugString(model_); if (hint_.vars_size() == model_.variables_size()) { *model_.mutable_solution_hint() = hint_; @@ -600,6 +602,7 @@ class RoutingCPSatWrapper : public RoutingLinearSolverWrapper { model.Add(sat::NewSatParameters(parameters_)); response_ = sat::SolveCpModel(model_, &model); VLOG(2) << response_; + DCHECK_NE(response_.status(), sat::CpSolverStatus::MODEL_INVALID); if (response_.status() == sat::CpSolverStatus::OPTIMAL || (response_.status() == sat::CpSolverStatus::FEASIBLE && !model_.has_floating_point_objective())) {