Class sdm::DiscreteSpace
Class List > sdm > DiscreteSpace
The discrete space class give a way to keep all possible values of a finite space. More...
#include <discrete_space.hpp>
Inherits the following classes: sdm::Space
Inherited by the following classes: sdm::FunctionSpace, sdm::MultiDiscreteSpace
Public Types
Type | Name |
---|---|
typedef Space::iterator_type | iterator_type |
typedef std::shared_ptr< Item > | value_type |
Public Types inherited from sdm::Space
See sdm::Space
Type | Name |
---|---|
typedef std::shared_ptr< ItemIterator > | iterator_type |
Public Functions
Type | Name |
---|---|
DiscreteSpace () Construct a new Discrete Space object (default) | |
DiscreteSpace (const std::vector< std::shared_ptr< Item >> & items) Construct a new Discrete Space object. | |
DiscreteSpace (const std::vector< T > & items) | |
DiscreteSpace (std::initializer_list< std::shared_ptr< Item >> vals) Construct a new Discrete Space object from a list initializer. | |
DiscreteSpace (const DiscreteSpace & copy) Copy constructor. | |
virtual iterator_type | begin () |
bool | contains (const std::shared_ptr< Item > &) const Verify is the discrete space contains the std::shared_ptr<Item>;. |
virtual iterator_type | end () |
int | find (const std::shared_ptr< Item > & item) const |
std::vector< std::shared_ptr< Item > > | getAll () Get all possible items in the space. |
virtual std::vector< number > | getDim () const Get the dimension. |
std::shared_ptr< Item > | getItem (number index) const Get the item at a specific index. |
std::shared_ptr< Item > | getItemAddress (const T & item_value) Get the item at a specific index. |
number | getItemIndex (const std::shared_ptr< Item > & item) const Get the index of an item. |
number | getNumItems () const Get the number of items in the space. |
virtual bool | isDiscrete () const Return true because this is a discrete space. |
bool | isStoringItems () const |
bool | operator!= (const DiscreteSpace & sp) const |
bool | operator== (const DiscreteSpace & sp) const |
virtual std::shared_ptr< Item > | sample () const Sample a random item from the space. |
std::string | short_str () const |
void | storeItems (bool store_items) |
virtual std::string | str () const Space as a string. |
Public Functions inherited from sdm::Space
See sdm::Space
Type | Name |
---|---|
virtual iterator_type | begin () = 0 |
virtual iterator_type | end () = 0 |
virtual std::vector< number > | getDim () const = 0 Get the dimension of the space. |
bool | isContinuous () const Check if the space is continous. |
virtual bool | isDiscrete () const = 0 Check if the space is discrete. |
bool | operator!= (const Space & sp) const |
bool | operator== (const Space & sp) const |
virtual std::shared_ptr< Item > | sample () const Sample a random item from the space. |
virtual std::string | str () const = 0 Space as a string. |
std::shared_ptr< DiscreteSpace > | toDiscreteSpace () |
std::shared_ptr< MultiDiscreteSpace > | toMultiDiscreteSpace () |
virtual | ~Space () |
Protected Types
Type | Name |
---|---|
typedef boost::bimaps::bimap< number, std::shared_ptr< Item > > | items_bimap |
typedef items_bimap::value_type | items_bimap_value |
Protected Attributes
Type | Name |
---|---|
items_bimap | all_items_ the list of possible items in the space with their index |
std::vector< std::shared_ptr< Item > > | list_items_ the list of possible items without their index |
number | num_items_ number of possible items in the space (ex: [5, 12] > 8 items) |
bool | store_items_ = = true |
Protected Functions
Type | Name |
---|---|
void | generateItems () Generates all joint items and maintains a bimap of indexes and corresponding pointers of joint items. |
bool | isGenerated () |
Detailed Description
In order to instantiate an object of this class, you must provide the constructor method a the list of all available values.
Template parameters:
std::shared_ptr<Item>
The type of each element in the space.
Public Types Documentation
typedef iterator_type
using sdm::DiscreteSpace::iterator_type = Space::iterator_type;
typedef value_type
using sdm::DiscreteSpace::value_type = std::shared_ptr<Item>;
Public Functions Documentation
function DiscreteSpace [1/5]
sdm::DiscreteSpace::DiscreteSpace ()
function DiscreteSpace [2/5]
sdm::DiscreteSpace::DiscreteSpace (
const std::vector< std::shared_ptr< Item >> & items
)
Parameters:
items
a list of possible items in the space
function DiscreteSpace [3/5]
template<typename T typename T>
inline sdm::DiscreteSpace::DiscreteSpace (
const std::vector< T > & items
)
function DiscreteSpace [4/5]
sdm::DiscreteSpace::DiscreteSpace (
std::initializer_list< std::shared_ptr< Item >> vals
)
function DiscreteSpace [5/5]
sdm::DiscreteSpace::DiscreteSpace (
const DiscreteSpace & copy
)
function begin
virtual iterator_type sdm::DiscreteSpace::begin ()
Implements sdm::Space::begin
function contains
bool sdm::DiscreteSpace::contains (
const std::shared_ptr< Item > &
) const
Returns:
true
Returns:
false
function end
virtual iterator_type sdm::DiscreteSpace::end ()
Implements sdm::Space::end
function find
int sdm::DiscreteSpace::find (
const std::shared_ptr< Item > & item
) const
function getAll
std::vector< std::shared_ptr< Item > > sdm::DiscreteSpace::getAll ()
function getDim
virtual std::vector< number > sdm::DiscreteSpace::getDim () const
Implements sdm::Space::getDim
function getItem
std::shared_ptr< Item > sdm::DiscreteSpace::getItem (
number index
) const
function getItemAddress
template<typename T typename T>
inline std::shared_ptr< Item > sdm::DiscreteSpace::getItemAddress (
const T & item_value
)
function getItemIndex
number sdm::DiscreteSpace::getItemIndex (
const std::shared_ptr< Item > & item
) const
function getNumItems
number sdm::DiscreteSpace::getNumItems () const
function isDiscrete
virtual bool sdm::DiscreteSpace::isDiscrete () const
Implements sdm::Space::isDiscrete
function isStoringItems
bool sdm::DiscreteSpace::isStoringItems () const
function operator!=
bool sdm::DiscreteSpace::operator!= (
const DiscreteSpace & sp
) const
function operator==
bool sdm::DiscreteSpace::operator== (
const DiscreteSpace & sp
) const
function sample
virtual std::shared_ptr< Item > sdm::DiscreteSpace::sample () const
Implements sdm::Space::sample
function short_str
std::string sdm::DiscreteSpace::short_str () const
function storeItems
void sdm::DiscreteSpace::storeItems (
bool store_items
)
function str
virtual std::string sdm::DiscreteSpace::str () const
Implements sdm::Space::str
Protected Types Documentation
typedef items_bimap
using sdm::DiscreteSpace::items_bimap = boost::bimaps::bimap<number, std::shared_ptr<Item> >;
typedef items_bimap_value
using sdm::DiscreteSpace::items_bimap_value = items_bimap::value_type;
Protected Attributes Documentation
variable all_items_
items_bimap sdm::DiscreteSpace::all_items_;
variable list_items_
std::vector<std::shared_ptr<Item> > sdm::DiscreteSpace::list_items_;
variable num_items_
number sdm::DiscreteSpace::num_items_;
variable store_items_
bool sdm::DiscreteSpace::store_items_;
Protected Functions Documentation
function generateItems
void sdm::DiscreteSpace::generateItems ()
function isGenerated
bool sdm::DiscreteSpace::isGenerated ()
Friends Documentation
friend operator<<
inline friend std::ostream & sdm::DiscreteSpace::operator<< (
std::ostream & os,
const DiscreteSpace & sp
)
The documentation for this class was generated from the following file src/sdm/core/space/discrete_space.hpp