C++ Reference: cp_model

This documentation is automatically generated.

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."; }

Classes

AutomatonConstraint
BoolVar
CircuitConstraint
Constraint
CpModelBuilder
CumulativeConstraint
IntervalVar
IntVar
LinearExpr
NoOverlap2DConstraint
ReservoirConstraint
TableConstraint

Send feedback about...