Fawkes API Fawkes Development Version
stn_action.h
1
2/***************************************************************************
3 * stn_action.h - stn-generator
4 *
5 * Created: Sat May 6 20:16:21 2017
6 * Copyright 2017 Matthias Loebach
7 ****************************************************************************/
8
9/* This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU Library General Public License for more details.
18 *
19 * Read the full text in the LICENSE.GPL file in the doc directory.
20 */
21
22#ifndef PLUGINS_STN_ACTION_H_
23#define PLUGINS_STN_ACTION_H_
24
25#include "predicate.h"
26
27#include <algorithm>
28#include <atomic>
29#include <iostream>
30#include <iterator>
31#include <map>
32#include <string>
33#include <vector>
34
35namespace fawkes {
36namespace stn {
37
38enum EdgeType { CONDITIONAL, TEMPORAL };
39
41{
42public:
43 StnAction(const std::string & name,
44 const std::vector<Predicate> & preconds,
45 const std::vector<Predicate> & effects,
46 const std::string & opts,
47 size_t duration = 0,
48 const std::vector<std::string> &cond_breakups = {},
49 const std::vector<std::string> &temp_breakups = {});
50 StnAction(){};
51 virtual ~StnAction(){};
52
53 bool operator==(const StnAction &o);
54 bool operator!=(const StnAction &o);
55
56 size_t id() const;
57 bool checkForBreakup(EdgeType t, const Predicate &p) const;
58 std::vector<size_t> condActionIds() const;
59 std::string genGraphNodeName() const;
60 std::string genConditionEdgeLabel(size_t cond_action) const;
61 std::string genTemporalEdgeLabel() const;
62 void genConditionalActions(std::vector<StnAction> candidate_actions);
63 const std::vector<Predicate> &effects() const;
64 std::string name() const;
65 size_t duration() const;
66 std::string opts() const;
67
68private:
69 friend std::ostream & operator<<(std::ostream &, const StnAction &);
70 size_t id_;
71 std::string name_;
72 std::vector<Predicate> preconds_;
73 std::vector<Predicate> effects_;
74 std::string opts_;
75 size_t duration_;
76 std::vector<std::string> cond_breakups_;
77 std::vector<std::string> temp_breakups_;
78 std::map<size_t, std::pair<std::string, std::vector<Predicate>>> cond_actions_;
79 static size_t count;
80};
81} // namespace stn
82} // namespace fawkes
83#endif
A representation of a Predicate in the STN.
Definition: predicate.h:33
An action representation within an STN.
Definition: stn_action.h:41
bool checkForBreakup(EdgeType t, const Predicate &p) const
Check if the given predicate is a breakup.
Definition: stn_action.cpp:150
std::vector< size_t > condActionIds() const
Get all IDs of this StnAction's conditional actions.
Definition: stn_action.cpp:135
friend std::ostream & operator<<(std::ostream &, const StnAction &)
Print relevant information about the StnAction.
Definition: stn_action.cpp:67
std::string name() const
Get the name of the StnAction.
Definition: stn_action.cpp:277
std::string genTemporalEdgeLabel() const
Generate a temporal edge for the graph representation.
Definition: stn_action.cpp:212
void genConditionalActions(std::vector< StnAction > candidate_actions)
Generate the conditional actions of this StnAction.
Definition: stn_action.cpp:224
size_t id() const
Get the ID of the action.
Definition: stn_action.cpp:126
bool operator!=(const StnAction &o)
Compare two StnActions.
Definition: stn_action.cpp:117
const std::vector< Predicate > & effects() const
Get the effects of the StnAction.
Definition: stn_action.cpp:268
std::string opts() const
Get the action parameters.
Definition: stn_action.cpp:295
std::string genGraphNodeName() const
Get a string representation of the StnAction for the graph representation.
Definition: stn_action.cpp:176
std::string genConditionEdgeLabel(size_t cond_action) const
Generate an edge label for the graph representation.
Definition: stn_action.cpp:186
size_t duration() const
Get the duration of the StnAction.
Definition: stn_action.cpp:286
bool operator==(const StnAction &o)
Compare two StnActions.
Definition: stn_action.cpp:107
Fawkes library namespace.