|
49 | 49 | #include "absl/types/span.h" |
50 | 50 | #include "google/protobuf/arena.h" |
51 | 51 | #include "google/protobuf/text_format.h" |
52 | | -#include "ortools/base/file.h" |
53 | 52 | #include "ortools/base/helpers.h" |
54 | 53 | #include "ortools/base/logging.h" |
55 | 54 | #include "ortools/base/options.h" |
@@ -132,32 +131,6 @@ ABSL_FLAG(bool, cp_model_use_hint_for_debug_only, false, |
132 | 131 | "complete, validate that no buggy propagator make it infeasible."); |
133 | 132 | ABSL_FLAG(bool, cp_model_fingerprint_model, true, "Fingerprint the model."); |
134 | 133 |
|
135 | | -ABSL_FLAG(std::string, cp_model_drat_output, "", |
136 | | - "If non-empty, a proof in DRAT format will be written to this file. " |
137 | | - "This only works in the same conditions as the --cp_model_lrat_check " |
138 | | - "flag, and only for pure SAT models."); |
139 | | - |
140 | | -ABSL_FLAG(bool, cp_model_drat_check, false, |
141 | | - "If true, a proof in DRAT format will be stored in memory and " |
142 | | - "checked if the problem is UNSAT. This only works in the same " |
143 | | - "conditions as the --cp_model_lrat_check flag, and only for pure SAT " |
144 | | - "models."); |
145 | | - |
146 | | -ABSL_FLAG(bool, cp_model_lrat_check, false, |
147 | | - "If true, inferred clauses are checked with an LRAT checker as they " |
148 | | - "are learned. As of November 2025, this only works with a single " |
149 | | - "worker and symmetry level 0 or 1. This also works with presolve, if " |
150 | | - "find_clauses_that_are_exactly_one is false and " |
151 | | - "merge_at_most_one_work_limit is 0. However, in this case, the " |
152 | | - "presolved problem is assumed to be correct, without proof. If the " |
153 | | - "model is not pure SAT, the checks are only partial (some clauses " |
154 | | - "can be assumed without proof)."); |
155 | | - |
156 | | -ABSL_FLAG(double, cp_model_max_drat_time_in_seconds, |
157 | | - std::numeric_limits<double>::infinity(), |
158 | | - "Maximum time in seconds to check the DRAT proof. This will only " |
159 | | - "be used is the cp_model_drat_check flag is enabled."); |
160 | | - |
161 | 134 | ABSL_FLAG(bool, cp_model_check_intermediate_solutions, false, |
162 | 135 | "When true, all intermediate solutions found by the solver will be " |
163 | 136 | "checked. This can be expensive, therefore it is off by default."); |
@@ -1035,26 +1008,6 @@ bool SolutionHintIsCompleteAndFeasible( |
1035 | 1008 | } |
1036 | 1009 | } |
1037 | 1010 |
|
1038 | | -std::unique_ptr<LratProofHandler> MaybeCreateLratProofHandler(Model* model) { |
1039 | | - const bool check_lrat = absl::GetFlag(FLAGS_cp_model_lrat_check); |
1040 | | - const bool check_drat = absl::GetFlag(FLAGS_cp_model_drat_check); |
1041 | | - File* drat_output = nullptr; |
1042 | | - if (!absl::GetFlag(FLAGS_cp_model_drat_output).empty()) { |
1043 | | - CHECK_OK(file::Open(absl::GetFlag(FLAGS_cp_model_drat_output), "w", |
1044 | | - &drat_output, file::Defaults())); |
1045 | | - } |
1046 | | - if (!check_lrat && !check_drat && drat_output == nullptr) return nullptr; |
1047 | | - |
1048 | | - // TODO(user): pass the [presolved] model proto to the handler, so that |
1049 | | - // it can map internal problem clause IDs to constraint indices in the |
1050 | | - // original model. This will be needed to write the LRAT proof in a file that |
1051 | | - // can be checked with an external LRAT checker, expecting the standard LRAT |
1052 | | - // ASCII file format (which requires problem clauses IDs between 1 and n). |
1053 | | - return std::make_unique<LratProofHandler>(model, check_lrat, check_drat, |
1054 | | - drat_output, |
1055 | | - /*in_binary_drat_format=*/false); |
1056 | | -} |
1057 | | - |
1058 | 1011 | // Encapsulate a full CP-SAT solve without presolve in the SubSolver API. |
1059 | 1012 | class FullProblemSolver : public SubSolver { |
1060 | 1013 | public: |
@@ -1082,7 +1035,7 @@ class FullProblemSolver : public SubSolver { |
1082 | 1035 | shared_->RegisterSharedClassesInLocalModel(&local_model_); |
1083 | 1036 |
|
1084 | 1037 | std::unique_ptr<LratProofHandler> lrat_proof_handler = |
1085 | | - MaybeCreateLratProofHandler(&local_model_); |
| 1038 | + LratProofHandler::MaybeCreate(&local_model_); |
1086 | 1039 | if (lrat_proof_handler != nullptr) { |
1087 | 1040 | local_model_.Register<LratProofHandler>(lrat_proof_handler.get()); |
1088 | 1041 | local_model_.TakeOwnership(lrat_proof_handler.release()); |
@@ -1111,8 +1064,7 @@ class FullProblemSolver : public SubSolver { |
1111 | 1064 | WallTimer timer; |
1112 | 1065 | timer.Start(); |
1113 | 1066 | const bool valid = local_model_.GetOrCreate<SatSolver>()->ModelIsUnsat() |
1114 | | - ? lrat_proof_handler->Check(absl::GetFlag( |
1115 | | - FLAGS_cp_model_max_drat_time_in_seconds)) |
| 1067 | + ? lrat_proof_handler->Check() |
1116 | 1068 | : lrat_proof_handler->Valid(); |
1117 | 1069 | shared_->lrat_proof_status->NewSubsolverProofStatus( |
1118 | 1070 | valid ? DratChecker::Status::VALID : DratChecker::Status::INVALID, |
@@ -1801,12 +1753,8 @@ void SolveCpModelParallel(SharedClasses* shared, Model* global_model) { |
1801 | 1753 | const SatParameters& params = *global_model->GetOrCreate<SatParameters>(); |
1802 | 1754 | if (global_model->GetOrCreate<TimeLimit>()->LimitReached()) return; |
1803 | 1755 |
|
1804 | | - if (absl::GetFlag(FLAGS_cp_model_drat_check) || |
1805 | | - !absl::GetFlag(FLAGS_cp_model_drat_output).empty()) { |
1806 | | - LOG(WARNING) |
1807 | | - << "DRAT check and output are skipped when using several workers"; |
1808 | | - absl::SetFlag(&FLAGS_cp_model_drat_check, false); |
1809 | | - absl::SetFlag(&FLAGS_cp_model_drat_output, ""); |
| 1756 | + if (params.check_drat_proof() || params.output_drat_proof()) { |
| 1757 | + LOG(FATAL) << "DRAT proofs are not supported with several workers"; |
1810 | 1758 | } |
1811 | 1759 |
|
1812 | 1760 | // If specified by the user, we might disable some parameters based on their |
|
0 commit comments