Google OR-Tools v9.14
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
cp_model_solver.h
Go to the documentation of this file.
1// Copyright 2010-2025 Google LLC
2// Licensed under the Apache License, Version 2.0 (the "License");
3// you may not use this file except in compliance with the License.
4// You may obtain a copy of the License at
5//
6// http://www.apache.org/licenses/LICENSE-2.0
7//
8// Unless required by applicable law or agreed to in writing, software
9// distributed under the License is distributed on an "AS IS" BASIS,
10// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11// See the License for the specific language governing permissions and
12// limitations under the License.
13
14#ifndef OR_TOOLS_SAT_CP_MODEL_SOLVER_H_
15#define OR_TOOLS_SAT_CP_MODEL_SOLVER_H_
16
17#include <functional>
18#include <string>
19
20#include "absl/flags/declare.h"
21#include "absl/strings/string_view.h"
22#include "ortools/sat/cp_model.pb.h"
23#include "ortools/sat/model.h"
24#include "ortools/sat/sat_parameters.pb.h"
25
26ABSL_DECLARE_FLAG(bool, cp_model_dump_response);
27
28namespace operations_research {
29namespace sat {
30
32std::string CpSatSolverVersion();
33
35CpSolverResponse Solve(const CpModelProto& model_proto);
36
38CpSolverResponse SolveWithParameters(const CpModelProto& model_proto,
39 const SatParameters& params);
40
42std::string CpModelStats(const CpModelProto& model);
43
50std::string CpSolverResponseStats(const CpSolverResponse& response,
51 bool has_objective = true);
52
66CpSolverResponse SolveCpModel(const CpModelProto& model_proto, Model* model);
67
68#if !defined(__PORTABLE_PLATFORM__)
73CpSolverResponse SolveWithParameters(const CpModelProto& model_proto,
74 absl::string_view params);
75#endif // !__PORTABLE_PLATFORM__
76
96std::function<void(Model*)> NewFeasibleSolutionObserver(
97 const std::function<void(const CpSolverResponse& response)>& callback);
98
107std::function<void(Model*)> NewFeasibleSolutionLogCallback(
108 const std::function<std::string(const CpSolverResponse& response)>&
109 callback);
110
117std::function<void(Model*)> NewBestBoundCallback(
118 const std::function<void(double)>& callback);
119
127std::function<SatParameters(Model*)> NewSatParameters(absl::string_view params);
128std::function<SatParameters(Model*)> NewSatParameters(
129 const SatParameters& parameters);
130
132void StopSearch(Model* model);
133
134} // namespace sat
135} // namespace operations_research
136
137#endif // OR_TOOLS_SAT_CP_MODEL_SOLVER_H_
Definition model.h:341
ABSL_DECLARE_FLAG(bool, cp_model_dump_response)
CpSolverResponse Solve(const CpModelProto &model_proto)
Solves the given CpModelProto and returns an instance of CpSolverResponse.
std::string CpModelStats(const CpModelProto &model_proto)
Returns a string with some statistics on the given CpModelProto.
std::function< SatParameters(Model *)> NewSatParameters(absl::string_view params)
std::string CpSatSolverVersion()
Returns a string that describes the version of the solver.
CpSolverResponse SolveCpModel(const CpModelProto &model_proto, Model *model)
std::function< void(Model *)> NewBestBoundCallback(const std::function< void(double)> &callback)
CpSolverResponse SolveWithParameters(const CpModelProto &model_proto, const SatParameters &params)
Solves the given CpModelProto with the given parameters.
std::function< void(Model *)> NewFeasibleSolutionLogCallback(const std::function< std::string(const CpSolverResponse &response)> &callback)
void StopSearch(Model *model)
Stops the current search.
std::function< void(Model *)> NewFeasibleSolutionObserver(const std::function< void(const CpSolverResponse &response)> &callback)
std::string CpSolverResponseStats(const CpSolverResponse &response, bool has_objective)
In SWIG mode, we don't want anything besides these top-level includes.