C++ Reference

C++ Reference: CP-SAT

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 74 of file cp_model.h.

Public Member Functions

 BoolVar ()=default
 A default constructed BoolVar can be used to mean not defined yet. More...
 
BoolVar WithName (const std::string &name)
 Sets the name of the variable. More...
 
std::string Name () const
 Returns the name of the variable. More...
 
BoolVar Not () const
 Returns the logical negation of the current Boolean variable. More...
 
bool operator== (const BoolVar &other) const
 
bool operator!= (const BoolVar &other) const
 
std::string DebugString () const
 
int index () const
 Returns the index of the variable in the model. More...
 

Constructor & Destructor Documentation

◆ 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 DebugString ( ) const

◆ index()

int 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 108 of file cp_model.h.

◆ Name()

std::string Name ( ) const

Returns the name of the variable.

◆ Not()

BoolVar Not ( ) const
inline

Returns the logical negation of the current Boolean variable.

Definition at line 90 of file cp_model.h.

◆ operator!=()

bool operator!= ( const BoolVar other) const
inline

Definition at line 96 of file cp_model.h.

◆ operator==()

bool operator== ( const BoolVar other) const
inline

Definition at line 92 of file cp_model.h.

◆ WithName()

BoolVar WithName ( const std::string &  name)

Sets the name of the variable.

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


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