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

#include <cp_model.h>

Public Member Functions

 BoolVar ()=default
 
BoolVar WithName (absl::string_view name)
 
std::string Name () const
 Returns the name of the variable.
 
BoolVar Not () const
 Returns the logical negation of the current Boolean variable.
 
bool operator== (const BoolVar &other) const
 
bool operator!= (const BoolVar &other) const
 
BoolVar operator~ () const
 
std::string DebugString () const
 
int index () const
 

Friends

class CircuitConstraint
 
class Constraint
 
class CpModelBuilder
 
class DoubleLinearExpr
 
class IntVar
 
class IntervalVar
 
class MultipleCircuitConstraint
 
class LinearExpr
 
class ReservoirConstraint
 
bool SolutionBooleanValue (const CpSolverResponse &r, BoolVar x)
 Evaluates the value of a Boolean literal in a solver response.
 

Detailed Description

A Boolean variable.

This class refer to an IntegerVariableProto with domain [0, 1] or to its logical negation (Not). This is called a Boolean Literal in other context.

This can only be constructed via CpModelBuilder.NewBoolVar().

Definition at line 75 of file cp_model.h.

Constructor & Destructor Documentation

◆ BoolVar()

operations_research::sat::BoolVar::BoolVar ( )
default

A default constructed BoolVar can be used to mean not defined yet. However, it shouldn't be passed to any of the functions in this file. Doing so will crash in debug mode and will result in an invalid model in opt mode.

Member Function Documentation

◆ DebugString()

std::string operations_research::sat::BoolVar::DebugString ( ) const

Special case for constant variables without names.

Definition at line 59 of file cp_model.cc.

◆ index()

int operations_research::sat::BoolVar::index ( ) const
inline

Returns the index of the variable in the model.

Warning: If the variable is the negation of another variable v, its index is -v.index() - 1. So this can be negative.

Definition at line 111 of file cp_model.h.

◆ Name()

std::string operations_research::sat::BoolVar::Name ( ) const

Returns the name of the variable.

Definition at line 48 of file cp_model.cc.

◆ Not()

BoolVar operations_research::sat::BoolVar::Not ( ) const
inline

Returns the logical negation of the current Boolean variable.

Definition at line 91 of file cp_model.h.

◆ operator!=()

bool operations_research::sat::BoolVar::operator!= ( const BoolVar & other) const
inline

Definition at line 97 of file cp_model.h.

◆ operator==()

bool operations_research::sat::BoolVar::operator== ( const BoolVar & other) const
inline

Definition at line 93 of file cp_model.h.

◆ operator~()

BoolVar operations_research::sat::BoolVar::operator~ ( ) const
inline

Definition at line 101 of file cp_model.h.

◆ WithName()

BoolVar operations_research::sat::BoolVar::WithName ( absl::string_view name)

Sets the name of the variable.

Note
this will always set the "positive" version of this Boolean.

Definition at line 39 of file cp_model.cc.

Friends And Related Symbol Documentation

◆ CircuitConstraint

friend class CircuitConstraint
friend

Definition at line 114 of file cp_model.h.

◆ Constraint

friend class Constraint
friend

Definition at line 115 of file cp_model.h.

◆ CpModelBuilder

friend class CpModelBuilder
friend

Definition at line 116 of file cp_model.h.

◆ DoubleLinearExpr

friend class DoubleLinearExpr
friend

Definition at line 117 of file cp_model.h.

◆ IntervalVar

friend class IntervalVar
friend

Definition at line 119 of file cp_model.h.

◆ IntVar

friend class IntVar
friend

Definition at line 118 of file cp_model.h.

◆ LinearExpr

friend class LinearExpr
friend

Definition at line 121 of file cp_model.h.

◆ MultipleCircuitConstraint

friend class MultipleCircuitConstraint
friend

Definition at line 120 of file cp_model.h.

◆ ReservoirConstraint

friend class ReservoirConstraint
friend

Definition at line 122 of file cp_model.h.

◆ SolutionBooleanValue

bool SolutionBooleanValue ( const CpSolverResponse & r,
BoolVar x )
friend

Evaluates the value of a Boolean literal in a solver response.

Definition at line 1403 of file cp_model.cc.


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