Google OR-Tools
v9.15
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
solve_mp_model.cc
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
#include "
ortools/linear_solver/solve_mp_model.h
"
15
16
#include <atomic>
17
#include <string>
18
#include <utility>
19
20
#include "absl/base/nullability.h"
21
#include "
ortools/linear_solver/linear_solver.h
"
22
#include "
ortools/linear_solver/linear_solver.pb.h
"
23
#include "
ortools/util/lazy_mutable_copy.h
"
24
#include "
ortools/util/solve_interrupter.h
"
25
26
namespace
operations_research
{
27
28
// TODO(b/311704821): this function should not delegate to MPSolver, also true
29
// for the functions below.
30
MPSolutionResponse
SolveMPModel
(
31
LazyMutableCopy<MPModelRequest>
request,
32
const
SolveInterrupter
* absl_nullable interrupter) {
33
MPSolutionResponse
response;
34
if
(interrupter !=
nullptr
) {
35
std::atomic<bool> atomic_bool =
false
;
36
ScopedSolveInterrupterCallback
cleanup(
37
interrupter, [&atomic_bool] { atomic_bool.store(
true
); });
38
MPSolver::SolveLazyMutableRequest
(std::move(request), &response,
39
&atomic_bool);
40
}
else
{
41
MPSolver::SolveLazyMutableRequest
(std::move(request), &response);
42
}
43
return
response;
44
}
45
46
bool
SolverTypeSupportsInterruption
(
const
MPModelRequest::SolverType
solver) {
47
return
MPSolver::SolverTypeSupportsInterruption(solver);
48
}
49
50
std::string
MPModelRequestLoggingInfo
(
const
MPModelRequest
& request) {
51
return
MPSolver::GetMPModelRequestLoggingInfo
(request);
52
}
53
54
}
// namespace operations_research
operations_research::LazyMutableCopy
Definition
lazy_mutable_copy.h:44
operations_research::MPModelRequest
Definition
linear_solver.pb.h:5365
operations_research::MPModelRequest::SolverType
MPModelRequest_SolverType SolverType
Definition
linear_solver.pb.h:5503
operations_research::MPSolutionResponse
Definition
linear_solver.pb.h:3749
operations_research::MPSolver::SolveLazyMutableRequest
static void SolveLazyMutableRequest(LazyMutableCopy< MPModelRequest > request, MPSolutionResponse *response, std::atomic< bool > *interrupt=nullptr)
Definition
linear_solver.cc:887
operations_research::MPSolver::GetMPModelRequestLoggingInfo
static std::string GetMPModelRequestLoggingInfo(const MPModelRequest &request)
Definition
linear_solver.cc:2190
operations_research::ScopedSolveInterrupterCallback
Definition
solve_interrupter.h:127
operations_research::SolveInterrupter
Definition
solve_interrupter.h:37
lazy_mutable_copy.h
linear_solver.h
linear_solver.pb.h
operations_research
OR-Tools root namespace.
Definition
binary_indexed_tree.h:21
operations_research::SolverTypeSupportsInterruption
bool SolverTypeSupportsInterruption(const MPModelRequest::SolverType solver)
Definition
solve_mp_model.cc:46
operations_research::SolveMPModel
MPSolutionResponse SolveMPModel(LazyMutableCopy< MPModelRequest > request, const SolveInterrupter *absl_nullable interrupter)
Definition
solve_mp_model.cc:30
operations_research::MPModelRequestLoggingInfo
std::string MPModelRequestLoggingInfo(const MPModelRequest &request)
Definition
solve_mp_model.cc:50
solve_interrupter.h
solve_mp_model.h
ortools
linear_solver
solve_mp_model.cc
Generated by
1.15.0