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 <boost/unordered_map.hpp>
41 #include <string>
42 
43 namespace ompl
44 {
45  namespace control
46  {
51  class World
52  {
53  public:
55  World(unsigned int numProps);
56 
59  bool operator[](unsigned int i) const;
60 
63  bool& operator[](unsigned int i);
64 
67  unsigned int numProps(void) const;
68 
72  bool satisfies(const World& w) const;
73 
76  std::string formula(void) const;
77 
80  const boost::unordered_map<unsigned int, bool>& props(void) const;
81 
84  bool operator==(const World& w) const;
85 
87  void clear(void);
88 
90 
91  friend std::size_t hash_value(const World& w);
93 
94  protected:
95  unsigned int numProps_;
96  boost::unordered_map<unsigned int, bool> props_;
97  };
98  }
99 }
100 #endif
World(unsigned int numProps)
Initializes a world with a given number of propositions.
Definition: World.cpp:8
A class to represent an assignment of boolean values to propositions. A World can be partially restri...
Definition: World.h:51
void clear(void)
Clears this world&#39;s truth assignment.
Definition: World.cpp:64
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:59
Main namespace. Contains everything in this library.
Definition: Cost.h:42
const boost::unordered_map< unsigned int, bool > & props(void) const
Returns this World&#39;s underlying proposition-to-boolean assignment map.
Definition: World.cpp:54
bool satisfies(const World &w) const
Returns whether this World propositionally satisfies a given World w. Specifically, returns true iff for every proposition p assigned in w, p is assigned in this World and this[p] == w[p].
Definition: World.cpp:30
unsigned int numProps(void) const
Returns the number of propositions declared for this World. Not all of the propositions have necessar...
Definition: World.cpp:25
std::string formula(void) const
Returns a formatted string representation of this World, as a conjunction of literals.
Definition: World.cpp:42
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:12