![]() |
OR-Tools
8.1
|
Go to the source code of this file.
Classes | |
struct | DefaultPhaseParameters |
This struct holds all parameters for the default search. More... | |
class | Solver |
Solver Class. More... | |
struct | Solver::IntegerCastInfo |
Holds semantic information stating that the 'expression' has been cast into 'variable' using the Var() method, and that 'maintainer' is responsible for maintaining the equality between 'variable' and 'expression'. More... | |
struct | Solver::SearchLogParameters |
Creates a search monitor from logging parameters. More... | |
class | BaseObject |
A BaseObject is the root of all reversibly allocated objects. More... | |
class | PropagationBaseObject |
NOLINT. More... | |
class | Decision |
A Decision represents a choice point in the search tree. More... | |
class | DecisionVisitor |
A DecisionVisitor is used to inspect a decision. More... | |
class | DecisionBuilder |
A DecisionBuilder is responsible for creating the search tree. More... | |
class | Demon |
A Demon is the base element of a propagation queue. More... | |
class | ModelVisitor |
Model visitor. More... | |
class | Constraint |
A constraint is the main modeling object. More... | |
class | CastConstraint |
Cast constraints are special channeling constraints designed to keep a variable in sync with an expression. More... | |
class | SearchMonitor |
A search monitor is a simple set of callbacks to monitor all search events. More... | |
class | Rev< T > |
This class adds reversibility to a POD type. More... | |
class | NumericalRev< T > |
Subclass of Rev<T> which adds numerical operations. More... | |
class | RevArray< T > |
Reversible array of POD types. More... | |
class | NumericalRevArray< T > |
Subclass of RevArray<T> which adds numerical operations. More... | |
class | IntExpr |
The class IntExpr is the base of all integer expressions in constraint programming. More... | |
class | IntVarIterator |
The class Iterator has two direct subclasses. More... | |
class | InitAndGetValues |
Utility class to encapsulate an IntVarIterator and use it in a range-based loop. More... | |
struct | InitAndGetValues::Iterator |
class | IntVar |
The class IntVar is a subset of IntExpr. More... | |
class | SolutionCollector |
This class is the root class of all solution collectors. More... | |
struct | SolutionCollector::SolutionData |
class | OptimizeVar |
This class encapsulates an objective. More... | |
class | SearchLimit |
Base class of all search limits. More... | |
class | RegularLimit |
Usual limit based on wall_time, number of explored branches and number of failures in the search tree. More... | |
class | ImprovementSearchLimit |
class | IntervalVar |
Interval variables are often used in scheduling. More... | |
class | SequenceVar |
A sequence variable is a variable whose domain is a set of possible orderings of the interval variables. More... | |
class | AssignmentElement |
class | IntVarElement |
class | IntervalVarElement |
class | SequenceVarElement |
The SequenceVarElement stores a partial representation of ranked interval variables in the underlying sequence variable. More... | |
class | AssignmentContainer< V, E > |
class | Assignment |
An Assignment is a variable -> domains mapping, used to report solutions to the user. More... | |
class | Pack |
class | DisjunctiveConstraint |
class | SolutionPool |
This class is used to manage a pool of solutions. 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. | |
Functions | |
ABSL_DECLARE_FLAG (int64, cp_random_seed) | |
Declaration of the core objects for the constraint solver. More... | |
int64 | CpRandomSeed () |
std::ostream & | operator<< (std::ostream &out, const Solver *const s) |
int64 | Zero () |
NOLINT. More... | |
int64 | One () |
This method returns 1. More... | |
std::ostream & | operator<< (std::ostream &out, const BaseObject *const o) |
std::ostream & | operator<< (std::ostream &out, const Assignment &assignment) |
void | SetAssignmentFromAssignment (Assignment *target_assignment, const std::vector< IntVar * > &target_vars, const Assignment *source_assignment, const std::vector< IntVar * > &source_vars) |
NOLINT. More... | |
ABSL_DECLARE_FLAG | ( | int64 | , |
cp_random_seed | |||
) |
Declaration of the core objects for the constraint solver.
The literature around constraint programming is extremely dense but one can find some basic introductions in the following links:
Here is a very simple Constraint Programming problem:
Knowing that we see 56 legs and 20 heads, how many pheasants and rabbits are we looking at?
Here is some simple Constraint Programming code to find out:
void pheasant() { Solver s("pheasant"); IntVar* const p = s.MakeIntVar(0, 20, "pheasant")); IntVar* const r = s.MakeIntVar(0, 20, "rabbit")); IntExpr* const legs = s.MakeSum(s.MakeProd(p, 2), s.MakeProd(r, 4)); IntExpr* const heads = s.MakeSum(p, r); Constraint* const ct_legs = s.MakeEquality(legs, 56); Constraint* const ct_heads = s.MakeEquality(heads, 20); s.AddConstraint(ct_legs); s.AddConstraint(ct_heads); DecisionBuilder* const db = s.MakePhase(p, r, Solver::CHOOSE_FIRST_UNBOUND, Solver::ASSIGN_MIN_VALUE); s.NewSearch(db); CHECK(s.NextSolution()); LOG(INFO) << "rabbits -> " << r->Value() << ", pheasants -> " << p->Value(); LOG(INFO) << s.DebugString(); s.EndSearch(); }
which outputs:
rabbits -> 8, pheasants -> 12 Solver(name = "pheasant", state = OUTSIDE_SEARCH, branches = 0, fails = 0, decisions = 0 propagation loops = 11, demons Run = 25, Run time = 0 ms)