@@ -810,12 +810,12 @@ void RestrictObjectiveUsingHint(CpModelProto* model_proto) {
810810 }
811811}
812812
813- // Returns false if there is a complete solution hint that is infeasible, or
814- // true otherwise .
815- bool TestSolutionHintForFeasibility ( const CpModelProto& model_proto,
816- SolverLogger* logger = nullptr ,
817- SharedResponseManager* manager = nullptr ) {
818- if (!model_proto.has_solution_hint ()) return true ;
813+ // Returns true iff there is a hint, and (ignoring fixed variables) if it is
814+ // complete and feasible .
815+ bool SolutionHintIsCompleteAndFeasible (
816+ const CpModelProto& model_proto, SolverLogger* logger = nullptr ,
817+ SharedResponseManager* manager = nullptr ) {
818+ if (!model_proto.has_solution_hint ()) return false ;
819819
820820 int num_active_variables = 0 ;
821821 int num_hinted_variables = 0 ;
@@ -837,7 +837,7 @@ bool TestSolutionHintForFeasibility(const CpModelProto& model_proto,
837837 logger, " The solution hint is incomplete: " , num_hinted_variables,
838838 " out of " , num_active_variables, " non fixed variables hinted." );
839839 }
840- return true ;
840+ return false ;
841841 }
842842
843843 std::vector<int64_t > solution (model_proto.variables_size (), 0 );
@@ -1350,7 +1350,7 @@ class LnsSolver : public SubSolver {
13501350 bool hint_feasible_before_presolve = false ;
13511351 if (lns_parameters_.debug_crash_if_presolve_breaks_hint ()) {
13521352 hint_feasible_before_presolve =
1353- TestSolutionHintForFeasibility (lns_fragment, /* logger=*/ nullptr );
1353+ SolutionHintIsCompleteAndFeasible (lns_fragment, /* logger=*/ nullptr );
13541354 }
13551355
13561356 // If we use a hint, we will restrict the objective to be <= to the one
@@ -1389,7 +1389,8 @@ class LnsSolver : public SubSolver {
13891389
13901390 if (lns_parameters_.debug_crash_if_presolve_breaks_hint () &&
13911391 hint_feasible_before_presolve &&
1392- !TestSolutionHintForFeasibility (lns_fragment, /* logger=*/ nullptr )) {
1392+ !SolutionHintIsCompleteAndFeasible (lns_fragment,
1393+ /* logger=*/ nullptr )) {
13931394 LOG (FATAL) << " Presolve broke a feasible LNS hint. The model name is '"
13941395 << lns_fragment.name ()
13951396 << " ' (use the --cp_model_dump_submodels flag to dump it)." ;
@@ -2372,7 +2373,7 @@ CpSolverResponse SolveCpModel(const CpModelProto& model_proto, Model* model) {
23722373 bool hint_feasible_before_presolve = false ;
23732374 if (!context->ModelIsUnsat ()) {
23742375 hint_feasible_before_presolve =
2375- TestSolutionHintForFeasibility (model_proto, logger);
2376+ SolutionHintIsCompleteAndFeasible (model_proto, logger);
23762377 }
23772378
23782379 // If the objective was a floating point one, do some postprocessing on the
@@ -2708,11 +2709,11 @@ CpSolverResponse SolveCpModel(const CpModelProto& model_proto, Model* model) {
27082709 // different.
27092710 bool hint_feasible_after_presolve;
27102711 if (!params.enumerate_all_solutions ()) {
2711- hint_feasible_after_presolve = TestSolutionHintForFeasibility (
2712+ hint_feasible_after_presolve = SolutionHintIsCompleteAndFeasible (
27122713 *new_cp_model_proto, logger, shared_response_manager);
27132714 } else {
27142715 hint_feasible_after_presolve =
2715- TestSolutionHintForFeasibility (*new_cp_model_proto, logger, nullptr );
2716+ SolutionHintIsCompleteAndFeasible (*new_cp_model_proto, logger, nullptr );
27162717 }
27172718
27182719 if (hint_feasible_before_presolve && !hint_feasible_after_presolve &&
0 commit comments