2
* To change this license header, choose License Headers in Project Properties.
3
* To change this template file, choose Tools | Templates
4
* and open the template in the editor.
9
* Author: Peter G. Jensen
11
* Created on 30 March 2016, 21:12
21
#include "../PQL/PQL.h"
24
namespace PetriEngine {
25
namespace Structures {
28
Queue(StateSetInterface* states);
30
virtual bool pop(Structures::State& state) = 0;
31
virtual void push(size_t id, PQL::DistanceContext&,
32
std::shared_ptr<PQL::Condition>& query) = 0;
38
StateSetInterface* _states;
42
class BFSQueue : public Queue {
44
BFSQueue(StateSetInterface* states);
47
virtual bool pop(Structures::State& state);
48
virtual void push(size_t id, PQL::DistanceContext&,
49
std::shared_ptr<PQL::Condition>& query);
55
class DFSQueue : public Queue {
57
DFSQueue(StateSetInterface* states);
60
virtual bool pop(Structures::State& state);
61
virtual void push(size_t id, PQL::DistanceContext&,
62
std::shared_ptr<PQL::Condition>& query);
64
std::stack<uint32_t> _stack;
67
class RDFSQueue : public Queue {
69
RDFSQueue(StateSetInterface* states);
72
virtual bool pop(Structures::State& state);
73
virtual void push(size_t id, PQL::DistanceContext&,
74
std::shared_ptr<PQL::Condition>& query);
76
std::stack<uint32_t> _stack;
77
std::vector<uint32_t> _cache;
80
class HeuristicQueue : public Queue {
85
weighted_t(uint32_t w, uint32_t i) : weight(w), item(i) {};
86
bool operator <(const weighted_t& y) const {
87
if(weight == y.weight) return item < y.item;// do dfs if they match
88
// if(weight == y.weight) return item > y.item;// do bfs if they match
89
return weight > y.weight;
93
HeuristicQueue(StateSetInterface* states);
94
virtual ~HeuristicQueue();
96
virtual bool pop(Structures::State& state);
97
virtual void push(size_t id, PQL::DistanceContext&,
98
std::shared_ptr<PQL::Condition>& query);
100
std::priority_queue<weighted_t> _queue;