Google OR-Tools v9.12
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 "ortools/sat/cp_model.pb.h"
22#include "ortools/sat/model.h"
23#include "ortools/sat/sat_parameters.pb.h"
24
25ABSL_DECLARE_FLAG(bool, cp_model_dump_response);
26
27namespace operations_research {
28namespace sat {
29
31std::string CpSatSolverVersion();
32
34CpSolverResponse Solve(const CpModelProto& model_proto);
35
37CpSolverResponse SolveWithParameters(const CpModelProto& model_proto,
38 const SatParameters& params);
39
41std::string CpModelStats(const CpModelProto& model);
42
49std::string CpSolverResponseStats(const CpSolverResponse& response,
50 bool has_objective = true);
51
63CpSolverResponse SolveCpModel(const CpModelProto& model_proto, Model* model);
64
65#if !defined(__PORTABLE_PLATFORM__)
70CpSolverResponse SolveWithParameters(const CpModelProto& model_proto,
71 const std::string& params);
72#endif // !__PORTABLE_PLATFORM__
73
93std::function<void(Model*)> NewFeasibleSolutionObserver(
94 const std::function<void(const CpSolverResponse& response)>& callback);
95
104std::function<void(Model*)> NewFeasibleSolutionLogCallback(
105 const std::function<std::string(const CpSolverResponse& response)>&
106 callback);
107
114std::function<void(Model*)> NewBestBoundCallback(
115 const std::function<void(double)>& callback);
116
124#if !defined(__PORTABLE_PLATFORM__)
125std::function<SatParameters(Model*)> NewSatParameters(
126 const std::string& params);
127#endif // !__PORTABLE_PLATFORM__
128std::function<SatParameters(Model*)> NewSatParameters(
129 const SatParameters& parameters);
130
131// TODO(user): Clean this up.
133void LoadAndSolveCpModelForTest(const CpModelProto& model_proto, Model* model);
134
135} // namespace sat
136} // namespace operations_research
137
138#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::function< SatParameters(Model *)> NewSatParameters(const std::string &params)
void LoadAndSolveCpModelForTest(const CpModelProto &model_proto, Model *model)
std::string CpModelStats(const CpModelProto &model_proto)
Returns a string with some statistics on the given CpModelProto.
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)
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.