Loading...
Searching...
No Matches
World.h
1/*********************************************************************
2* Software License Agreement (BSD License)
3*
4* Copyright (c) 2012, Rice University
5* All rights reserved.
6*
7* Redistribution and use in source and binary forms, with or without
8* modification, are permitted provided that the following conditions
9* are met:
10*
11* * Redistributions of source code must retain the above copyright
12* notice, this list of conditions and the following disclaimer.
13* * Redistributions in binary form must reproduce the above
14* copyright notice, this list of conditions and the following
15* disclaimer in the documentation and/or other materials provided
16* with the distribution.
17* * Neither the name of the Rice University nor the names of its
18* contributors may be used to endorse or promote products derived
19* from this software without specific prior written permission.
20*
21* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32* POSSIBILITY OF SUCH DAMAGE.
33*********************************************************************/
34
35/* Author: Matt Maly */
36
37#ifndef OMPL_CONTROL_PLANNERS_LTL_WORLD_
38#define OMPL_CONTROL_PLANNERS_LTL_WORLD_
39
40#include <unordered_map>
41#include <string>
42
43namespace ompl
44{
45 namespace control
46 {
47 class World;
48 }
49}
50
52
53namespace std
54{
55 template <>
56 struct hash<ompl::control::World>
57 {
58 size_t operator()(const ompl::control::World &w) const;
59 };
60}
62
63namespace ompl
64{
65 namespace control
66 {
71 class World
72 {
73 public:
75 World(unsigned int numProps);
76
79 bool operator[](unsigned int i) const;
80
83 bool &operator[](unsigned int i);
84
87 unsigned int numProps() const;
88
92 bool satisfies(const World &w) const;
93
96 std::string formula() const;
97
100 const std::unordered_map<unsigned int, bool> &props() const;
101
104 bool operator==(const World &w) const;
105
107 void clear();
108
109 friend struct std::hash<World>;
110
111 protected:
112 unsigned int numProps_;
113 std::unordered_map<unsigned int, bool> props_;
114 };
115 }
116}
117#endif
A class to represent an assignment of boolean values to propositions. A World can be partially restri...
Definition World.h:72
bool satisfies(const World &w) const
Returns whether this World propositionally satisfies a given World w. Specifically,...
Definition World.cpp:65
unsigned int numProps() const
Returns the number of propositions declared for this World. Not all of the propositions have necessar...
Definition World.cpp:60
bool operator==(const World &w) const
Returns whether this World is equivalent to a given World, by comparing their truth assignment maps.
Definition World.cpp:94
bool operator[](unsigned int i) const
Returns the boolean value of a given proposition in this World. Reports an error if the proposition h...
Definition World.cpp:47
std::string formula() const
Returns a formatted string representation of this World, as a conjunction of literals.
Definition World.cpp:77
const std::unordered_map< unsigned int, bool > & props() const
Returns this World's underlying proposition-to-boolean assignment map.
Definition World.cpp:89
void clear()
Clears this world's truth assignment.
Definition World.cpp:99
Main namespace. Contains everything in this library.
STL namespace.