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

#include <cp_model.h>

Inheritance diagram for operations_research::sat::Constraint:
operations_research::sat::AutomatonConstraint operations_research::sat::CircuitConstraint operations_research::sat::CumulativeConstraint operations_research::sat::MultipleCircuitConstraint operations_research::sat::NoOverlap2DConstraint operations_research::sat::ReservoirConstraint operations_research::sat::TableConstraint

Public Member Functions

Constraint OnlyEnforceIf (absl::Span< const BoolVar > literals)
 
Constraint OnlyEnforceIf (BoolVar literal)
 See OnlyEnforceIf(absl::Span<const BoolVar> literals).
 
Constraint WithName (absl::string_view name)
 Sets the name of the constraint.
 
absl::string_view Name () const
 Returns the name of the constraint (or the empty string if not set).
 
const ConstraintProto & Proto () const
 Returns the underlying protobuf object (useful for testing).
 
ConstraintProto * MutableProto () const
 Returns the mutable underlying protobuf object (useful for model edition).
 

Protected Member Functions

 Constraint (ConstraintProto *proto)
 

Protected Attributes

ConstraintProto * proto_ = nullptr
 

Friends

class CpModelBuilder
 

Detailed Description

A constraint.

This class enables you to modify the constraint that was previously added to the model.

The constraint must be built using the different CpModelBuilder::AddXXX methods.

Definition at line 533 of file cp_model.h.

Constructor & Destructor Documentation

◆ Constraint()

operations_research::sat::Constraint::Constraint ( ConstraintProto * proto)
explicitprotected

Definition at line 493 of file cp_model.cc.

Member Function Documentation

◆ MutableProto()

ConstraintProto * operations_research::sat::Constraint::MutableProto ( ) const
inline

Returns the mutable underlying protobuf object (useful for model edition).

Definition at line 567 of file cp_model.h.

◆ Name()

absl::string_view operations_research::sat::Constraint::Name ( ) const

Returns the name of the constraint (or the empty string if not set).

Definition at line 500 of file cp_model.cc.

◆ OnlyEnforceIf() [1/2]

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

The constraint will be enforced iff all literals listed here are true.

If this is empty, then the constraint will always be enforced. An enforced constraint must be satisfied, and an un-enforced one will simply be ignored.

This is also called half-reification. To have an equivalence between a literal and a constraint (full reification), one must add both a constraint (controlled by a literal l) and its negation (controlled by the negation of l).

[Important] currently, only a few constraints support enforcement:

  • bool_or, bool_and, linear: fully supported.
  • interval: only support a single enforcement literal.
  • other: no support (but can be added on a per-demand basis).

Definition at line 502 of file cp_model.cc.

◆ OnlyEnforceIf() [2/2]

Constraint operations_research::sat::Constraint::OnlyEnforceIf ( BoolVar literal)

◆ Proto()

const ConstraintProto & operations_research::sat::Constraint::Proto ( ) const
inline

Returns the underlying protobuf object (useful for testing).

Definition at line 564 of file cp_model.h.

◆ WithName()

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

Sets the name of the constraint.

Definition at line 495 of file cp_model.cc.

Friends And Related Symbol Documentation

◆ CpModelBuilder

friend class CpModelBuilder
friend

Definition at line 570 of file cp_model.h.

Member Data Documentation

◆ proto_

ConstraintProto* operations_research::sat::Constraint::proto_ = nullptr
protected

Definition at line 574 of file cp_model.h.


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