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

#include <constraint_violation.h>

Inheritance diagram for operations_research::sat::NoOverlapBetweenTwoIntervals:
operations_research::sat::CompiledConstraint

Public Member Functions

 NoOverlapBetweenTwoIntervals (int interval_0, int interval_1, const CpModelProto &cp_model)
 --— NoOverlapBetweenTwoIntervals --—
 
 ~NoOverlapBetweenTwoIntervals () override=default
 
int64_t ComputeViolation (absl::Span< const int64_t > solution) final
 
int64_t ViolationDelta (int, int64_t, absl::Span< const int64_t > solution_with_new_value) final
 
std::vector< int > UsedVariables (const CpModelProto &model_proto) const final
 
- Public Member Functions inherited from operations_research::sat::CompiledConstraint
 CompiledConstraint ()=default
 
virtual ~CompiledConstraint ()=default
 
void InitializeViolation (absl::Span< const int64_t > solution)
 Recomputes the violation of the constraint from scratch.
 
virtual void PerformMove (int var, int64_t old_value, absl::Span< const int64_t > solution_with_new_value)
 Updates the violation with the new value.
 
int64_t violation () const
 The cached violation of this constraint.
 

Additional Inherited Members

- Protected Member Functions inherited from operations_research::sat::CompiledConstraint
- Protected Attributes inherited from operations_research::sat::CompiledConstraint
int64_t violation_
 

Detailed Description

Special constraint for no overlap between two intervals. We usually expand small no-overlap in n^2 such constraint, so we want to be compact and efficient here.

Definition at line 542 of file constraint_violation.h.

Constructor & Destructor Documentation

◆ NoOverlapBetweenTwoIntervals()

operations_research::sat::NoOverlapBetweenTwoIntervals::NoOverlapBetweenTwoIntervals ( int interval_0,
int interval_1,
const CpModelProto & cp_model )

--— NoOverlapBetweenTwoIntervals --—

The more compact the better, hence the size + int[].

We prefer to use start + size instead of end so that moving "start" moves the whole interval around (for the non-fixed duration case).

Definition at line 1132 of file constraint_violation.cc.

◆ ~NoOverlapBetweenTwoIntervals()

operations_research::sat::NoOverlapBetweenTwoIntervals::~NoOverlapBetweenTwoIntervals ( )
overridedefault

Member Function Documentation

◆ ComputeViolation()

int64_t operations_research::sat::NoOverlapBetweenTwoIntervals::ComputeViolation ( absl::Span< const int64_t > solution)
inlinefinalvirtual

Computes the violation of a constraint.

This is called by InitializeViolation() and also the default implementation of ViolationDelta().

Implements operations_research::sat::CompiledConstraint.

Definition at line 548 of file constraint_violation.h.

◆ UsedVariables()

std::vector< int > operations_research::sat::NoOverlapBetweenTwoIntervals::UsedVariables ( const CpModelProto & model_proto) const
finalvirtual

Returns the sorted vector of variables used by this constraint. This is used to known when a violation might change, and is only called once during initialization, so speed is not to much of a concern here.

The global proto is needed to resolve interval variables reference.

Implements operations_research::sat::CompiledConstraint.

Definition at line 1168 of file constraint_violation.cc.

◆ ViolationDelta()

int64_t operations_research::sat::NoOverlapBetweenTwoIntervals::ViolationDelta ( int ,
int64_t ,
absl::Span< const int64_t > solution_with_new_value )
inlinefinalvirtual

Note(user): this is the same implementation as the base one, but it avoid one virtual call !

Reimplemented from operations_research::sat::CompiledConstraint.

Definition at line 554 of file constraint_violation.h.


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