Google OR-Tools v9.15
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
combine_solutions.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 ORTOOLS_SAT_COMBINE_SOLUTIONS_H_
15#define ORTOOLS_SAT_COMBINE_SOLUTIONS_H_
16
17#include <cstdint>
18#include <memory>
19#include <optional>
20#include <string>
21#include <vector>
22
23#include "absl/strings/string_view.h"
24#include "absl/types/span.h"
26#include "ortools/sat/model.h"
28
29namespace operations_research {
30namespace sat {
31
32// Given a `new_solution` that was created by changing a bit a `base_solution`,
33// try to apply the same changes to the other solutions stored in the
34// `response_manager` and return any such generated solution that is valid.
35std::optional<std::vector<int64_t>> FindCombinedSolution(
36 const CpModelProto& model, absl::Span<const int64_t> new_solution,
37 absl::Span<const int64_t> base_solution,
38 const SharedResponseManager* response_manager, std::string* solution_info);
39
40// This is equivalent to calling SharedResponseManager::NewSolution() then, if
41// `base_solution` is non-empty, trying to find a combined solution and calling
42// SharedResponseManager::NewSolution() again if an improved solution is found.
44 std::shared_ptr<const SharedSolutionRepository<int64_t>::Solution>
46 // nullptr if no improvement was found.
47 std::shared_ptr<const SharedSolutionRepository<int64_t>::Solution>
49};
51 SharedResponseManager* response_manager, const CpModelProto& model_proto,
52 absl::Span<const int64_t> new_solution, absl::string_view solution_info,
54 base_solution);
55
56} // namespace sat
57} // namespace operations_research
58
59#endif // ORTOOLS_SAT_COMBINE_SOLUTIONS_H_
PushedSolutionPointers PushAndMaybeCombineSolution(SharedResponseManager *response_manager, const CpModelProto &model_proto, absl::Span< const int64_t > new_solution, absl::string_view solution_info, std::shared_ptr< const SharedSolutionRepository< int64_t >::Solution > base_solution)
std::optional< std::vector< int64_t > > FindCombinedSolution(const CpModelProto &model, absl::Span< const int64_t > new_solution, absl::Span< const int64_t > base_solution, const SharedResponseManager *response_manager, std::string *solution_info)
OR-Tools root namespace.
std::shared_ptr< const SharedSolutionRepository< int64_t >::Solution > improved_solution
std::shared_ptr< const SharedSolutionRepository< int64_t >::Solution > pushed_solution