Storm
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
storm::models::sparse::ItemLabeling Class Reference

A base class managing the labeling of items with a number of (atomic) labels. More...

#include <ItemLabeling.h>

Inheritance diagram for storm::models::sparse::ItemLabeling:

Public Member Functions

 ItemLabeling (uint64_t itemCount=0)
 Constructs an empty labeling for the given number of items.
 
 ItemLabeling (ItemLabeling const &other)=default
 
ItemLabelingoperator= (ItemLabeling const &other)=default
 
virtual ~ItemLabeling ()=default
 
virtual bool isStateLabeling () const
 
virtual bool isChoiceLabeling () const
 
StateLabeling const & asStateLabeling () const
 
StateLabelingasStateLabeling ()
 
ChoiceLabeling const & asChoiceLabeling () const
 
ChoiceLabelingasChoiceLabeling ()
 
bool operator== (ItemLabeling const &other) const
 Checks whether the two labelings are equal.
 
void addLabel (std::string const &label)
 Adds a new label to the labelings.
 
void removeLabel (std::string const &label)
 Removes a label from the labelings.
 
std::set< std::string > getLabels () const
 Retrieves the set of labels contained in this labeling.
 
void addLabel (std::string const &label, storage::BitVector const &labeling)
 Creates a new label and attaches it to the given items.
 
void addLabel (std::string const &label, storage::BitVector &&labeling)
 Creates a new label and attaches it to the given items.
 
std::string addUniqueLabel (std::string const &prefix, storage::BitVector const &labeling)
 Creates a new label with a unique name, derived from the prefix, and attaches it to the given items.
 
std::string addUniqueLabel (std::string const &prefix, storage::BitVector const &&labeling)
 Creates a new label with a unique name, derived from the prefix, and attaches it to the given items.
 
void join (ItemLabeling const &other)
 Adds all labels from the other labeling to this labeling.
 
bool containsLabel (std::string const &label) const
 Checks whether a label is registered within this labeling.
 
std::size_t getNumberOfLabels () const
 Returns the number of labels managed by this object.
 
std::size_t getNumberOfItems () const
 Returns the number of items managed by this object.
 
void permuteItems (std::vector< uint64_t > const &inversePermutation)
 
virtual std::size_t hash () const
 
void printLabelingInformationToStream (std::ostream &out=std::cout) const
 Prints information about the labeling to the specified stream.
 
void printCompleteLabelingInformationToStream (std::ostream &out=std::cout) const
 Prints the complete labeling to the specified stream.
 

Protected Member Functions

ItemLabeling getSubLabeling (storm::storage::BitVector const &items) const
 Retrieves the sub labeling that represents the same labeling as the current one for all selected items.
 
virtual std::set< std::string > getLabelsOfItem (uint64_t item) const
 Retrieves the set of labels attached to the given item.
 
virtual bool getItemHasLabel (std::string const &label, uint64_t item) const
 Checks whether a given item is labeled with the given label.
 
virtual storm::storage::BitVector const & getItems (std::string const &label) const
 Returns the labeling of items associated with the given label.
 
virtual void setItems (std::string const &label, storage::BitVector const &labeling)
 Sets the labeling of items associated with the given label.
 
virtual void setItems (std::string const &label, storage::BitVector &&labeling)
 Sets the labeling of items associated with the given label.
 
virtual void addLabelToItem (std::string const &label, uint64_t item)
 Adds a label to a given item.
 
virtual void removeLabelFromItem (std::string const &label, uint64_t item)
 Removes a label from a given item.
 
std::string generateUniqueLabel (const std::string &prefix) const
 Generate a unique, previously unused label from the given prefix string.
 

Protected Attributes

uint64_t itemCount
 
std::unordered_map< std::string, uint64_t > nameToLabelingIndexMap
 
std::vector< storm::storage::BitVectorlabelings
 

Friends

std::ostream & operator<< (std::ostream &out, ItemLabeling const &labeling)
 

Detailed Description

A base class managing the labeling of items with a number of (atomic) labels.

Definition at line 21 of file ItemLabeling.h.

Constructor & Destructor Documentation

◆ ItemLabeling() [1/2]

storm::models::sparse::ItemLabeling::ItemLabeling ( uint64_t  itemCount = 0)
explicit

Constructs an empty labeling for the given number of items.

Parameters
itemCountThe number of items for which this labeling can hold the labels.

◆ ItemLabeling() [2/2]

storm::models::sparse::ItemLabeling::ItemLabeling ( ItemLabeling const &  other)
default

◆ ~ItemLabeling()

virtual storm::models::sparse::ItemLabeling::~ItemLabeling ( )
virtualdefault

Member Function Documentation

◆ addLabel() [1/3]

void storm::models::sparse::ItemLabeling::addLabel ( std::string const &  label)

Adds a new label to the labelings.

Initially, no item is labeled with this label.

Parameters
labelThe name of the new label.

Definition at line 63 of file ItemLabeling.cpp.

◆ addLabel() [2/3]

void storm::models::sparse::ItemLabeling::addLabel ( std::string const &  label,
storage::BitVector &&  labeling 
)

Creates a new label and attaches it to the given items.

Note that the dimension of given labeling must match the number of items for which this item labeling is valid.

Parameters
labelThe new label.
labelingA bit vector that indicates whether or not the new label is attached to a item.

Definition at line 134 of file ItemLabeling.cpp.

◆ addLabel() [3/3]

void storm::models::sparse::ItemLabeling::addLabel ( std::string const &  label,
storage::BitVector const &  labeling 
)

Creates a new label and attaches it to the given items.

Note that the dimension of given labeling must match the number of items for which this item labeling is valid.

Parameters
labelThe new label.
labelingA bit vector that indicates whether or not the new label is attached to a item.

Definition at line 126 of file ItemLabeling.cpp.

◆ addLabelToItem()

void storm::models::sparse::ItemLabeling::addLabelToItem ( std::string const &  label,
uint64_t  item 
)
protectedvirtual

Adds a label to a given item.

Parameters
labelThe name of the label to add.
itemThe index of the item to label.

Definition at line 158 of file ItemLabeling.cpp.

◆ addUniqueLabel() [1/2]

std::string storm::models::sparse::ItemLabeling::addUniqueLabel ( std::string const &  prefix,
storage::BitVector const &&  labeling 
)

Creates a new label with a unique name, derived from the prefix, and attaches it to the given items.

Note that the dimension of given labeling must match the number of items for which this item labeling is valid.

Parameters
prefixA prefix to use for the new label.
labelingA bit vector that indicates whether or not the new label is attached to a item.
Returns
the new label

Definition at line 148 of file ItemLabeling.cpp.

◆ addUniqueLabel() [2/2]

std::string storm::models::sparse::ItemLabeling::addUniqueLabel ( std::string const &  prefix,
storage::BitVector const &  labeling 
)

Creates a new label with a unique name, derived from the prefix, and attaches it to the given items.

Note that the dimension of given labeling must match the number of items for which this item labeling is valid.

Parameters
prefixA prefix to use for the new label.
labelingA bit vector that indicates whether or not the new label is attached to a item.
Returns
the new label

Definition at line 142 of file ItemLabeling.cpp.

◆ asChoiceLabeling() [1/2]

ChoiceLabeling & storm::models::sparse::ItemLabeling::asChoiceLabeling ( )

Definition at line 33 of file ItemLabeling.cpp.

◆ asChoiceLabeling() [2/2]

ChoiceLabeling const & storm::models::sparse::ItemLabeling::asChoiceLabeling ( ) const

Definition at line 30 of file ItemLabeling.cpp.

◆ asStateLabeling() [1/2]

StateLabeling & storm::models::sparse::ItemLabeling::asStateLabeling ( )

Definition at line 27 of file ItemLabeling.cpp.

◆ asStateLabeling() [2/2]

StateLabeling const & storm::models::sparse::ItemLabeling::asStateLabeling ( ) const

Definition at line 24 of file ItemLabeling.cpp.

◆ containsLabel()

bool storm::models::sparse::ItemLabeling::containsLabel ( std::string const &  label) const

Checks whether a label is registered within this labeling.

Returns
True if the label is known, false otherwise.

Definition at line 154 of file ItemLabeling.cpp.

◆ generateUniqueLabel()

std::string storm::models::sparse::ItemLabeling::generateUniqueLabel ( const std::string &  prefix) const
protected

Generate a unique, previously unused label from the given prefix string.

Definition at line 232 of file ItemLabeling.cpp.

◆ getItemHasLabel()

bool storm::models::sparse::ItemLabeling::getItemHasLabel ( std::string const &  label,
uint64_t  item 
) const
protectedvirtual

Checks whether a given item is labeled with the given label.

Parameters
labelThe name of the label.
itemThe index of the item to check.
Returns
True if the node is labeled with the label, false otherwise.

Definition at line 171 of file ItemLabeling.cpp.

◆ getItems()

storm::storage::BitVector const & storm::models::sparse::ItemLabeling::getItems ( std::string const &  label) const
protectedvirtual

Returns the labeling of items associated with the given label.

Parameters
labelThe name of the label.
Returns
A bit vector that represents the labeling of the items with the given label.

Definition at line 185 of file ItemLabeling.cpp.

◆ getLabels()

std::set< std::string > storm::models::sparse::ItemLabeling::getLabels ( ) const

Retrieves the set of labels contained in this labeling.

Returns
The set of known labels.

Definition at line 98 of file ItemLabeling.cpp.

◆ getLabelsOfItem()

std::set< std::string > storm::models::sparse::ItemLabeling::getLabelsOfItem ( uint64_t  item) const
protectedvirtual

Retrieves the set of labels attached to the given item.

Parameters
itemThe item for which to retrieve the labels.
Returns
The labels attached to the given item.

Definition at line 106 of file ItemLabeling.cpp.

◆ getNumberOfItems()

std::size_t storm::models::sparse::ItemLabeling::getNumberOfItems ( ) const

Returns the number of items managed by this object.

Returns
The number of labels.

Definition at line 181 of file ItemLabeling.cpp.

◆ getNumberOfLabels()

std::size_t storm::models::sparse::ItemLabeling::getNumberOfLabels ( ) const

Returns the number of labels managed by this object.

Returns
The number of labels.

Definition at line 177 of file ItemLabeling.cpp.

◆ getSubLabeling()

ItemLabeling storm::models::sparse::ItemLabeling::getSubLabeling ( storm::storage::BitVector const &  items) const
protected

Retrieves the sub labeling that represents the same labeling as the current one for all selected items.

Parameters
itemsThe selected set of items.

Definition at line 55 of file ItemLabeling.cpp.

◆ hash()

std::size_t storm::models::sparse::ItemLabeling::hash ( ) const
virtual

Definition at line 223 of file ItemLabeling.cpp.

◆ isChoiceLabeling()

bool storm::models::sparse::ItemLabeling::isChoiceLabeling ( ) const
virtual

Reimplemented in storm::models::sparse::ChoiceLabeling.

Definition at line 20 of file ItemLabeling.cpp.

◆ isStateLabeling()

bool storm::models::sparse::ItemLabeling::isStateLabeling ( ) const
virtual

Reimplemented in storm::models::sparse::StateLabeling.

Definition at line 17 of file ItemLabeling.cpp.

◆ join()

void storm::models::sparse::ItemLabeling::join ( ItemLabeling const &  other)

Adds all labels from the other labeling to this labeling.

It is assumed that both labelings have the same itemcount. If a label is present in both labellings, we take the union of the corresponding item sets.

Definition at line 86 of file ItemLabeling.cpp.

◆ operator=()

ItemLabeling & storm::models::sparse::ItemLabeling::operator= ( ItemLabeling const &  other)
default

◆ operator==()

bool storm::models::sparse::ItemLabeling::operator== ( ItemLabeling const &  other) const

Checks whether the two labelings are equal.

Parameters
otherThe labeling with which the current one is compared.
Returns
True iff the labelings are equal.

Definition at line 37 of file ItemLabeling.cpp.

◆ permuteItems()

void storm::models::sparse::ItemLabeling::permuteItems ( std::vector< uint64_t > const &  inversePermutation)

Definition at line 116 of file ItemLabeling.cpp.

◆ printCompleteLabelingInformationToStream()

void storm::models::sparse::ItemLabeling::printCompleteLabelingInformationToStream ( std::ostream &  out = std::cout) const

Prints the complete labeling to the specified stream.

Parameters
outThe stream the information is to be printed to.

Definition at line 212 of file ItemLabeling.cpp.

◆ printLabelingInformationToStream()

void storm::models::sparse::ItemLabeling::printLabelingInformationToStream ( std::ostream &  out = std::cout) const

Prints information about the labeling to the specified stream.

Parameters
outThe stream the information is to be printed to.

Definition at line 205 of file ItemLabeling.cpp.

◆ removeLabel()

void storm::models::sparse::ItemLabeling::removeLabel ( std::string const &  label)

Removes a label from the labelings.

Parameters
labelThe name of the label to remove.

Definition at line 67 of file ItemLabeling.cpp.

◆ removeLabelFromItem()

void storm::models::sparse::ItemLabeling::removeLabelFromItem ( std::string const &  label,
uint64_t  item 
)
protectedvirtual

Removes a label from a given item.

Parameters
labelThe name of the label to remove.
itemThe index of the item.

Definition at line 164 of file ItemLabeling.cpp.

◆ setItems() [1/2]

void storm::models::sparse::ItemLabeling::setItems ( std::string const &  label,
storage::BitVector &&  labeling 
)
protectedvirtual

Sets the labeling of items associated with the given label.

Parameters
labelThe name of the label.
labelingA bit vector that represents the set of items that will get this label.

Definition at line 198 of file ItemLabeling.cpp.

◆ setItems() [2/2]

void storm::models::sparse::ItemLabeling::setItems ( std::string const &  label,
storage::BitVector const &  labeling 
)
protectedvirtual

Sets the labeling of items associated with the given label.

Parameters
labelThe name of the label.
labelingA bit vector that represents the set of items that will get this label.

Definition at line 191 of file ItemLabeling.cpp.

Friends And Related Symbol Documentation

◆ operator<<

std::ostream & operator<< ( std::ostream &  out,
ItemLabeling const &  labeling 
)
friend

Definition at line 227 of file ItemLabeling.cpp.

Member Data Documentation

◆ itemCount

uint64_t storm::models::sparse::ItemLabeling::itemCount
protected

Definition at line 226 of file ItemLabeling.h.

◆ labelings

std::vector<storm::storage::BitVector> storm::models::sparse::ItemLabeling::labelings
protected

Definition at line 232 of file ItemLabeling.h.

◆ nameToLabelingIndexMap

std::unordered_map<std::string, uint64_t> storm::models::sparse::ItemLabeling::nameToLabelingIndexMap
protected

Definition at line 229 of file ItemLabeling.h.


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