OR-Tools  8.1
cp_model.h File Reference

Detailed Description

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.Build());
<< " rabbits, and " << SolutionIntegerValue(response, pheasants)
<< " pheasants.";
}

Definition in file cp_model.h.

Go to the source code of this file.

Classes

class  BoolVar
 A Boolean variable. More...
 
class  IntVar
 An integer variable. More...
 
class  LinearExpr
 A dedicated container for linear expressions. More...
 
class  IntervalVar
 Represents a Interval variable. More...
 
class  Constraint
 A constraint. More...
 
class  CircuitConstraint
 Specialized circuit constraint. More...
 
class  MultipleCircuitConstraint
 Specialized circuit constraint. More...
 
class  TableConstraint
 Specialized assignment constraint. More...
 
class  ReservoirConstraint
 Specialized reservoir constraint. More...
 
class  AutomatonConstraint
 Specialized automaton constraint. More...
 
class  NoOverlap2DConstraint
 Specialized no_overlap2D constraint. More...
 
class  CumulativeConstraint
 Specialized cumulative constraint. More...
 
class  CpModelBuilder
 Wrapper class around the cp_model proto. More...
 

Namespaces

 operations_research
 The vehicle routing library lets one model and solve generic vehicle routing problems ranging from the Traveling Salesman Problem to more complex problems such as the Capacitated Vehicle Routing Problem with Time Windows.
 
 operations_research::sat
 

Functions

std::ostream & operator<< (std::ostream &os, const BoolVar &var)
 
BoolVar Not (BoolVar x)
 A convenient wrapper so we can write Not(x) instead of x.Not() which is sometimes clearer. More...
 
std::ostream & operator<< (std::ostream &os, const IntVar &var)
 
std::ostream & operator<< (std::ostream &os, const IntervalVar &var)
 
int64 SolutionIntegerValue (const CpSolverResponse &r, const LinearExpr &expr)
 Evaluates the value of an linear expression in a solver response. More...
 
int64 SolutionIntegerMin (const CpSolverResponse &r, IntVar x)
 Returns the min of an integer variable in a solution. More...
 
int64 SolutionIntegerMax (const CpSolverResponse &r, IntVar x)
 Returns the max of an integer variable in a solution. More...
 
bool SolutionBooleanValue (const CpSolverResponse &r, BoolVar x)
 Evaluates the value of a Boolean literal in a solver response. More...
 
INFO
const int INFO
Definition: log_severity.h:31
response
SharedResponseManager * response
Definition: cp_model_solver.cc:2105
operations_research::sat::FEASIBLE
@ FEASIBLE
Definition: cp_model.pb.h:225
LOG
#define LOG(severity)
Definition: base/logging.h:420
operations_research::sat::SolutionIntegerValue
int64 SolutionIntegerValue(const CpSolverResponse &r, const LinearExpr &expr)
Evaluates the value of an linear expression in a solver response.
Definition: cp_model.cc:799
operations_research::sat::Solve
CpSolverResponse Solve(const CpModelProto &model_proto)
Solves the given CpModelProto and returns an instance of CpSolverResponse.
Definition: cp_model_solver.cc:3206