Вот код
Код: Выделить всё
#include
#include
#include "ortools/base/logging.h"
#include "ortools/sat/cp_model.h"
#include "ortools/sat/cp_model.pb.h"
#include "ortools/sat/cp_model_solver.h"
#include "ortools/util/sorted_interval_list.h"
void SimpleSatProgram() {
const operations_research::Domain domain(0, 100);
operations_research::sat::CpSolverResponse response;
operations_research::sat::CpModelBuilder cp_model;
operations_research::sat::IntVar a = cp_model.NewIntVar(domain);
operations_research::sat::IntVar b = cp_model.NewIntVar(domain);
operations_research::sat::IntVar c = cp_model.NewIntVar(domain);
cp_model.AddEquality(a + b + c, 200);
for (int x=0; x < 10000; x++) {
response = operations_research::sat::Solve(cp_model.Build());
if (response.status() == operations_research::sat::CpSolverStatus::OPTIMAL ||
response.status() == operations_research::sat::CpSolverStatus::FEASIBLE) {
// for (auto i : all)
// std::cout
Подробнее здесь: [url]https://stackoverflow.com/questions/76170228/optimizing-ortools-cp-sat-for-best-speed[/url]