Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. More...
Namespaces | |
| sat | |
Classes | |
| struct | ClosedInterval |
| Represents a closed interval [start, end]. We must have start <= end. More... | |
| class | Domain |
| We call "domain" any subset of Int64 = [kint64min, kint64max]. More... | |
| class | SortedDisjointIntervalList |
| This class represents a sorted list of disjoint, closed intervals. More... | |
Functions | |
| std::ostream & | operator<< (std::ostream &out, const ClosedInterval &interval) |
| std::ostream & | operator<< (std::ostream &out, const std::vector< ClosedInterval > &intervals) |
| bool | IntervalsAreSortedAndNonAdjacent (absl::Span< const ClosedInterval > intervals) |
| Returns true iff we have: More... | |
| std::ostream & | operator<< (std::ostream &out, const Domain &domain) |
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. This file implements a wrapper around the CP-SAT model proto.
Here is a minimal example that shows how to create a model, solve it, and print out the solution.
CpModelBuilder cp_model; Domain all_animals(0, 20); IntVar rabbits = cp_model.NewIntVar(all_animals).WithName("rabbits"); IntVar pheasants = cp_model.NewIntVar(all_animals).WithName("pheasants");
cp_model.AddEquality(LinearExpr::Sum({rabbits, pheasants}), 20); cp_model.AddEquality(LinearExpr::ScalProd({rabbits, pheasants}, {4, 2}), 56);
const CpSolverResponse response = Solve(cp_model); if (response.status() == CpSolverStatus::FEASIBLE) { LOG(INFO) << SolutionIntegerValue(response, rabbits) << " rabbits, and " << SolutionIntegerValue(response, pheasants) << " pheasants."; }
You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
| bool operations_research::IntervalsAreSortedAndNonAdjacent | ( | absl::Span< const ClosedInterval > | intervals | ) |
Returns true iff we have:
| std::ostream& operations_research::operator<< | ( | std::ostream & | out, |
| const ClosedInterval & | interval | ||
| ) |
| std::ostream& operations_research::operator<< | ( | std::ostream & | out, |
| const std::vector< ClosedInterval > & | intervals | ||
| ) |
| std::ostream& operations_research::operator<< | ( | std::ostream & | out, |
| const Domain & | domain | ||
| ) |