PropositionalDecomposition.cpp
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 #include "ompl/control/planners/ltl/PropositionalDecomposition.h"
38 #include "ompl/base/State.h"
39 #include "ompl/control/planners/syclop/Decomposition.h"
40 #include "ompl/control/planners/ltl/World.h"
41 #include "ompl/util/ClassForward.h"
42 #include "ompl/util/RandomNumbers.h"
43 #include "ompl/base/StateSampler.h"
44 #include <vector>
45 
47  Decomposition(decomp->getDimension(), decomp->getBounds()),
48  decomp_(decomp)
49 {
50 }
51 
53 {
54 }
55 
57 {
58  return decomp_->getNumRegions();
59 }
60 
62 {
63  return decomp_->getRegionVolume(rid);
64 }
65 
67 {
68  return decomp_->locateRegion(s);
69 }
70 
71 void ompl::control::PropositionalDecomposition::project(const base::State* s, std::vector<double>& coord) const
72 {
73  return decomp_->project(s, coord);
74 }
75 
76 void ompl::control::PropositionalDecomposition::getNeighbors(int rid, std::vector<int>& neighbors) const
77 {
78  decomp_->getNeighbors(rid, neighbors);
79 }
80 
81 void ompl::control::PropositionalDecomposition::sampleFromRegion(int rid, RNG& rng, std::vector<double>& coord) const
82 {
83  decomp_->sampleFromRegion(rid, rng, coord);
84 }
85 
87  const base::StateSamplerPtr& sampler,
88  const std::vector<double>& coord,
89  base::State* s) const
90 {
91  decomp_->sampleFullState(sampler, coord, s);
92 }
virtual void getNeighbors(int rid, std::vector< int > &neighbors) const
Stores a given region's neighbors into a given vector.
A shared pointer wrapper for ompl::base::StateSampler.
virtual int locateRegion(const base::State *s) const
Returns the region of the underlying decomposition that contains a given State.
A Decomposition is a partition of a bounded Euclidean space into a fixed number of regions which are ...
Definition: Decomposition.h:62
virtual ~PropositionalDecomposition(void)
Clears all memory belonging to this propositional decomposition.
virtual void sampleFromRegion(int rid, RNG &rng, std::vector< double > &coord) const
Samples a projected coordinate from a given region.
virtual void sampleFullState(const base::StateSamplerPtr &sampler, const std::vector< double > &coord, base::State *s) const
Samples a State using a projected coordinate and a StateSampler.
Random number generation. An instance of this class cannot be used by multiple threads at once (membe...
Definition: RandomNumbers.h:58
virtual double getRegionVolume(int rid)
Returns the volume of a given region.
virtual int getNumRegions(void) const
Returns the number of regions in this propositional decomposition's underlying decomposition.
virtual void project(const base::State *s, std::vector< double > &coord) const
Project a given State to a set of coordinates in R^k, where k is the dimension of this Decomposition...
Definition of an abstract state.
Definition: State.h:50
PropositionalDecomposition(const DecompositionPtr &decomp)
Creates a propositional decomposition wrapped around a given decomposition with a given number of pro...
A shared pointer wrapper for ompl::control::Decomposition.