Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
operations_research::fz::Domain Struct Reference

#include <model.h>

Public Member Functions

bool HasOneValue () const
 
bool empty () const
 
int64_t Min () const
 Returns the min of the domain.
 
int64_t Max () const
 Returns the max of the domain.
 
int64_t Value () const
 Returns the value of the domain. HasOneValue() must return true.
 
bool IsAllInt64 () const
 Returns true if the domain is [kint64min..kint64max].
 
bool Contains (int64_t value) const
 Various inclusion tests on a domain.
 
bool OverlapsIntList (const std::vector< int64_t > &vec) const
 
bool OverlapsIntInterval (int64_t lb, int64_t ub) const
 
bool OverlapsDomain (const Domain &other) const
 
bool IntersectWithSingleton (int64_t value)
 
bool IntersectWithDomain (const Domain &domain)
 
bool IntersectWithInterval (int64_t interval_min, int64_t interval_max)
 
bool IntersectWithListOfIntegers (absl::Span< const int64_t > integers)
 
bool IntersectWithFloatDomain (const Domain &domain)
 
bool RemoveValue (int64_t value)
 
bool SetEmptyFloatDomain ()
 Sets the empty float domain. Returns true.
 
std::string DebugString () const
 

Static Public Member Functions

static Domain IntegerList (std::vector< int64_t > values)
 The values will be sorted and duplicate values will be removed.
 
static Domain AllInt64 ()
 
static Domain IntegerValue (int64_t value)
 
static Domain Interval (int64_t included_min, int64_t included_max)
 
static Domain Boolean ()
 
static Domain SetOfIntegerList (std::vector< int64_t > values)
 
static Domain SetOfAllInt64 ()
 
static Domain SetOfIntegerValue (int64_t value)
 
static Domain SetOfInterval (int64_t included_min, int64_t included_max)
 
static Domain SetOfBoolean ()
 
static Domain EmptyDomain ()
 
static Domain AllFloats ()
 
static Domain FloatValue (double value)
 
static Domain FloatInterval (double lb, double ub)
 

Public Attributes

std::vector< int64_t > values
 These should never be modified from outside the class.
 
bool is_interval = false
 
bool display_as_boolean = false
 
bool is_a_set = false
 Indicates if the domain was created as a set domain.
 
bool is_float = false
 Float domain.
 
std::vector< double > float_values
 

Detailed Description

A domain represents the possible values of a variable, and its type (which carries display information, i.e. a Boolean will be displayed differently than an integer with domain {0, 1}). It can be:

  • an explicit list of all possible values, in which case is_interval is false. If the list is empty, then the domain is empty.
  • an interval, in which case is_interval is true and values.size() == 2, and the interval is [values[0], values[1]].
  • all integers, in which case values is empty, and is_interval is true.
    Note
    semi-infinite intervals aren't supported.
  • a Boolean domain({ 0, 1 } with Boolean display tag).
    Todo
    (user): Rework domains, all int64_t should be kintmin..kint64max. It is a bit tricky though as we must take care of overflows. If is_a_set is true, then this domain has a set semantics. For a set variable, any subset of the initial set of values is a valid assignment, instead of exactly one value.

Definition at line 51 of file model.h.

Member Function Documentation

◆ AllFloats()

Domain operations_research::fz::Domain::AllFloats ( )
static

Definition at line 107 of file model.cc.

◆ AllInt64()

Domain operations_research::fz::Domain::AllInt64 ( )
static

Definition at line 47 of file model.cc.

◆ Boolean()

Domain operations_research::fz::Domain::Boolean ( )
static

Definition at line 67 of file model.cc.

◆ Contains()

bool operations_research::fz::Domain::Contains ( int64_t value) const

Various inclusion tests on a domain.

Definition at line 363 of file model.cc.

◆ DebugString()

std::string operations_research::fz::Domain::DebugString ( ) const

Definition at line 468 of file model.cc.

◆ empty()

bool operations_research::fz::Domain::empty ( ) const

Definition at line 335 of file model.cc.

◆ EmptyDomain()

Domain operations_research::fz::Domain::EmptyDomain ( )
static

Definition at line 105 of file model.cc.

◆ FloatInterval()

Domain operations_research::fz::Domain::FloatInterval ( double lb,
double ub )
static

Definition at line 114 of file model.cc.

◆ FloatValue()

Domain operations_research::fz::Domain::FloatValue ( double value)
static

Definition at line 122 of file model.cc.

◆ HasOneValue()

bool operations_research::fz::Domain::HasOneValue ( ) const
Todo
(user): Do we need SetOfFloats() ?

Definition at line 331 of file model.cc.

◆ IntegerList()

Domain operations_research::fz::Domain::IntegerList ( std::vector< int64_t > values)
static

The values will be sorted and duplicate values will be removed.

--— Domain --—

Definition at line 40 of file model.cc.

◆ IntegerValue()

Domain operations_research::fz::Domain::IntegerValue ( int64_t value)
static

Definition at line 53 of file model.cc.

◆ IntersectWithDomain()

bool operations_research::fz::Domain::IntersectWithDomain ( const Domain & domain)

now deal with the intersection of two lists of values

Definition at line 129 of file model.cc.

◆ IntersectWithFloatDomain()

bool operations_research::fz::Domain::IntersectWithFloatDomain ( const Domain & domain)

Empty domain. Nothing to do.

domain is all floats. Nothing to do.

Copy the domain.

this is a double interval.

this is a single double.

value is compatible with domain.

Same value;

Definition at line 254 of file model.cc.

◆ IntersectWithInterval()

bool operations_research::fz::Domain::IntersectWithInterval ( int64_t interval_min,
int64_t interval_max )

Definition at line 159 of file model.cc.

◆ IntersectWithListOfIntegers()

bool operations_research::fz::Domain::IntersectWithListOfIntegers ( absl::Span< const int64_t > integers)

Contiguous case.

This also covers and invalid (empty) domain.

Todo
(user): Investigate faster code for small arrays.

Definition at line 207 of file model.cc.

◆ IntersectWithSingleton()

bool operations_research::fz::Domain::IntersectWithSingleton ( int64_t value)

All the following modifiers change the internal representation list to interval or interval to list.

Definition at line 155 of file model.cc.

◆ Interval()

Domain operations_research::fz::Domain::Interval ( int64_t included_min,
int64_t included_max )
static

Definition at line 59 of file model.cc.

◆ IsAllInt64()

bool operations_research::fz::Domain::IsAllInt64 ( ) const

Returns true if the domain is [kint64min..kint64max].

Definition at line 357 of file model.cc.

◆ Max()

int64_t operations_research::fz::Domain::Max ( ) const

Returns the max of the domain.

Definition at line 346 of file model.cc.

◆ Min()

int64_t operations_research::fz::Domain::Min ( ) const

Returns the min of the domain.

Definition at line 340 of file model.cc.

◆ OverlapsDomain()

bool operations_research::fz::Domain::OverlapsDomain ( const Domain & other) const

Definition at line 425 of file model.cc.

◆ OverlapsIntInterval()

bool operations_research::fz::Domain::OverlapsIntInterval ( int64_t lb,
int64_t ub ) const

Definition at line 411 of file model.cc.

◆ OverlapsIntList()

bool operations_research::fz::Domain::OverlapsIntList ( const std::vector< int64_t > & vec) const
Todo
(user): Better algorithm, sort and compare increasingly.

Definition at line 387 of file model.cc.

◆ RemoveValue()

bool operations_research::fz::Domain::RemoveValue ( int64_t value)

Returns true iff the value did belong to the domain, and was removed. Try to remove the value. It returns true if it was actually removed. If the value is inside a large interval, then it will not be removed.

Definition at line 437 of file model.cc.

◆ SetEmptyFloatDomain()

bool operations_research::fz::Domain::SetEmptyFloatDomain ( )

Sets the empty float domain. Returns true.

Definition at line 324 of file model.cc.

◆ SetOfAllInt64()

Domain operations_research::fz::Domain::SetOfAllInt64 ( )
static

Definition at line 81 of file model.cc.

◆ SetOfBoolean()

Domain operations_research::fz::Domain::SetOfBoolean ( )
static

Definition at line 99 of file model.cc.

◆ SetOfIntegerList()

Domain operations_research::fz::Domain::SetOfIntegerList ( std::vector< int64_t > values)
static

Definition at line 75 of file model.cc.

◆ SetOfIntegerValue()

Domain operations_research::fz::Domain::SetOfIntegerValue ( int64_t value)
static

Definition at line 87 of file model.cc.

◆ SetOfInterval()

Domain operations_research::fz::Domain::SetOfInterval ( int64_t included_min,
int64_t included_max )
static

Definition at line 93 of file model.cc.

◆ Value()

int64_t operations_research::fz::Domain::Value ( ) const

Returns the value of the domain. HasOneValue() must return true.

Definition at line 352 of file model.cc.

Member Data Documentation

◆ display_as_boolean

bool operations_research::fz::Domain::display_as_boolean = false

Definition at line 109 of file model.h.

◆ float_values

std::vector<double> operations_research::fz::Domain::float_values

Definition at line 114 of file model.h.

◆ is_a_set

bool operations_research::fz::Domain::is_a_set = false

Indicates if the domain was created as a set domain.

Definition at line 111 of file model.h.

◆ is_float

bool operations_research::fz::Domain::is_float = false

Float domain.

Definition at line 113 of file model.h.

◆ is_interval

bool operations_research::fz::Domain::is_interval = false

Definition at line 108 of file model.h.

◆ values

std::vector<int64_t> operations_research::fz::Domain::values

These should never be modified from outside the class.

Definition at line 107 of file model.h.


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