Google OR-Tools v9.15
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
operations_research::sat::CpModelBuilder Class Reference

Detailed Description

Wrapper class around the cp_model proto.

This class provides two types of methods:

  • NewXXX to create integer, boolean, or interval variables.
  • AddXXX to create new constraints and add them to the model.

Definition at line 735 of file cp_model.h.

#include <cp_model.h>

Public Member Functions

*Sets the name of the model void SetName (absl::string_view name)
*Creates an integer variable with the given domain IntVar NewIntVar (const Domain &domain)
*Creates a Boolean variable BoolVar NewBoolVar ()
*Creates a constant variable This is a shortcut for * NewVariable (Domain(value)).but it will return the same variable if used *twice with the same const ant. IntVar NewConstant(int64_t value)
*Creates an always true Boolean variable *If this is called multiple the same variable will always be *returned BoolVar TrueVar ()
*Creates an always false Boolean variable *If this is called multiple the same variable will always be *returned BoolVar FalseVar ()
*Creates an interval variable from affine expressions IntervalVar NewIntervalVar (const LinearExpr &start, const LinearExpr &size, const LinearExpr &end)
*Creates an interval variable with a fixed size IntervalVar NewFixedSizeIntervalVar (const LinearExpr &start, int64_t size)
*Creates an optional interval variable from affine expressions and a *Boolean variable IntervalVar NewOptionalIntervalVar (const LinearExpr &start, const LinearExpr &size, const LinearExpr &end, BoolVar presence)
*Creates an optional interval variable with a fixed size IntervalVar NewOptionalFixedSizeIntervalVar (const LinearExpr &start, int64_t size, BoolVar presence)
*It is sometime convenient when building a model to create a bunch of *variables that will later be fixed Instead of doing AddEquality (var, *value) which add a const raint
*It is sometime convenient when building a model to create a bunch of *variables that will later be fixed Instead of doing these functions modify directly the *underlying variable domain *note this ignore completely the original variable domain and just fix *the given variable to the given even if it was outside the given *variable domain You can still use AddEquality () if this is not what you *want. void FixVariable(IntVar var
void FixVariable (BoolVar var, bool value)
*Adds the constraint that at least one of the literals must be true Constraint AddBoolOr (absl::Span< const BoolVar > literals)
*Same as AddBoolOr (). Sum literals >
*At most one literal is true Sum literals<=1. Constraint AddAtMostOne(absl::Span< const BoolVar > literals); *Exactly one literal is true. Sum literals==1. Constraint AddExactlyOne(absl::Span< const BoolVar > literals); *Adds the constraint that all literals must be true. Constraint AddBoolAnd(absl::Span< const BoolVar > literals); *Adds the constraint that an odd number of literals is true. Constraint AddBoolXor(absl::Span< const BoolVar > literals); *Adds a=> b Constraint AddImplication (BoolVar a, BoolVar b)
*Adds left right Constraint AddGreaterThan (const LinearExpr &left, const LinearExpr &right)

Public Attributes

*Creates an always true Boolean variable *If this is called multiple times
*Creates an always false Boolean variable *If this is called multiple times
*It is sometime convenient when building a model to create a bunch of *variables that will later be fixed Instead of doing these functions modify directly the *underlying variable domain *note this ignore completely the original variable domain and just fix *the given variable to the given value
*It is sometime convenient when building a model to create a bunch of *variables that will later be fixed Instead of doing these functions modify directly the *underlying variable domain *note this ignore completely the original variable domain and just fix *the given variable to the given even if it was outside the given *variable domain You can still use int64_t value
*Adds implication: if all lhs vars are true then all rhs vars must be true. Constraint AddImplication(absl::Span<const BoolVar> lhs
*Adds absl::Span< const BoolVarrhs
*Adds left

Member Function Documentation

◆ AddBoolOr() [1/2]

*Same as operations_research::sat::CpModelBuilder::AddBoolOr ( )

◆ AddBoolOr() [2/2]

Constraint operations_research::sat::CpModelBuilder::AddBoolOr ( absl::Span< const BoolVar > literals)

Definition at line 781 of file cp_model.cc.

◆ AddEquality() [1/2]

*It is sometime convenient when building a model to create a bunch of *variables that will later be fixed Instead of doing these functions modify directly the *underlying variable domain *note this ignore completely the original variable domain and just fix *the given variable to the given even if it was outside the given *variable domain You can still use operations_research::sat::CpModelBuilder::AddEquality ( )

◆ AddEquality() [2/2]

*It is sometime convenient when building a model to create a bunch of *variables that will later be fixed Instead of doing operations_research::sat::CpModelBuilder::AddEquality ( var ,
* value ) const

◆ AddGreaterThan()

Constraint operations_research::sat::CpModelBuilder::AddGreaterThan ( const LinearExpr & left,
const LinearExpr & right )

Definition at line 870 of file cp_model.cc.

◆ AddImplication()

*At most one literal is true Sum literals<=1. Constraint AddAtMostOne(absl::Span< const BoolVar > literals);*Exactly one literal is true. Sum literals==1. Constraint AddExactlyOne(absl::Span< const BoolVar > literals);*Adds the constraint that all literals must be true. Constraint AddBoolAnd(absl::Span< const BoolVar > literals);*Adds the constraint that an odd number of literals is true. Constraint AddBoolXor(absl::Span< const BoolVar > literals);*Adds a=> b Constraint operations_research::sat::CpModelBuilder::AddImplication ( BoolVar a,
BoolVar b )
inline

Definition at line 810 of file cp_model.h.

◆ FalseVar()

BoolVar operations_research::sat::CpModelBuilder::FalseVar ( )

Definition at line 712 of file cp_model.cc.

◆ FixVariable()

void operations_research::sat::CpModelBuilder::FixVariable ( BoolVar var,
bool value )

Definition at line 767 of file cp_model.cc.

◆ NewBoolVar()

BoolVar operations_research::sat::CpModelBuilder::NewBoolVar ( )

Definition at line 696 of file cp_model.cc.

◆ NewFixedSizeIntervalVar()

IntervalVar operations_research::sat::CpModelBuilder::NewFixedSizeIntervalVar ( const LinearExpr & start,
int64_t size )

Definition at line 728 of file cp_model.cc.

◆ NewIntervalVar()

IntervalVar operations_research::sat::CpModelBuilder::NewIntervalVar ( const LinearExpr & start,
const LinearExpr & size,
const LinearExpr & end )

Definition at line 716 of file cp_model.cc.

◆ NewIntVar()

IntVar operations_research::sat::CpModelBuilder::NewIntVar ( const Domain & domain)

Definition at line 686 of file cp_model.cc.

◆ NewOptionalFixedSizeIntervalVar()

IntervalVar operations_research::sat::CpModelBuilder::NewOptionalFixedSizeIntervalVar ( const LinearExpr & start,
int64_t size,
BoolVar presence )

Definition at line 754 of file cp_model.cc.

◆ NewOptionalIntervalVar()

IntervalVar operations_research::sat::CpModelBuilder::NewOptionalIntervalVar ( const LinearExpr & start,
const LinearExpr & size,
const LinearExpr & end,
BoolVar presence )

Definition at line 740 of file cp_model.cc.

◆ NewVariable()

*Creates a constant variable This is a shortcut for * operations_research::sat::CpModelBuilder::NewVariable ( Domain(value) ) const

◆ SetName()

void operations_research::sat::CpModelBuilder::SetName ( absl::string_view name)

Definition at line 650 of file cp_model.cc.

◆ TrueVar()

BoolVar operations_research::sat::CpModelBuilder::TrueVar ( )

Definition at line 708 of file cp_model.cc.

Member Data Documentation

◆ implication

* Adds operations_research::sat::CpModelBuilder::implication

Definition at line 814 of file cp_model.h.

◆ left

*Adds operations_research::sat::CpModelBuilder::left
Initial value:
== right.
*It is sometime convenient when building a model to create a bunch of *variables that will later be fixed Instead of doing these functions modify directly the *underlying variable domain *note this ignore completely the original variable domain and just fix *the given variable to the given even if it was outside the given *variable domain You can still use AddEquality() if this is not what you *want. void FixVariable(IntVar var

Definition at line 820 of file cp_model.h.

◆ rhs

* Adds absl::Span<const BoolVar> operations_research::sat::CpModelBuilder::rhs
Initial value:
{
return AddBoolAnd(rhs).OnlyEnforceIf(lhs)
*Adds absl::Span< const BoolVar > rhs
Definition cp_model.h:816

Definition at line 816 of file cp_model.h.

◆ times [1/2]

* Creates an always false Boolean variable* If this is called multiple operations_research::sat::CpModelBuilder::times

Definition at line 757 of file cp_model.h.

◆ times [2/2]

* Creates an always true Boolean variable* If this is called multiple operations_research::sat::CpModelBuilder::times

Definition at line 752 of file cp_model.h.

◆ value [1/2]

*It is sometime convenient when building a model to create a bunch of *variables that will later be fixed Instead of doing these functions modify directly the *underlying variable domain *note this ignore completely the original variable domain and just fix *the given variable to the given even if it was outside the given *variable domain You can still use int64_t operations_research::sat::CpModelBuilder::value

Definition at line 788 of file cp_model.h.

◆ value [2/2]

*It is sometime convenient when building a model to create a bunch of *variables that will later be fixed Instead of doing these functions modify directly the* underlying variable domain* note this ignore completely the original variable domain and just fix* the given variable to the given operations_research::sat::CpModelBuilder::value

Definition at line 785 of file cp_model.h.


The documentation for this class was generated from the following files: