Fawkes API Fawkes Development Version
stn.h
1
2/***************************************************************************
3 * stn.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_H_
23#define PLUGINS_STN_H_
24
25#include "domain_action.h"
26#include "stn_action.h"
27
28#include <aspect/logging.h>
29#include <graphviz/gvc.h>
30#include <pddl_parser/pddl_ast.h>
31
32#include <algorithm>
33#include <bsoncxx/document/value.hpp>
34#include <iterator>
35#include <mongocxx/client.hpp>
36#include <string>
37#include <vector>
38
39namespace fawkes {
40namespace stn {
41
42class Stn
43{
44public:
45 Stn(fawkes::Logger *logger);
46 Stn(fawkes::Logger *logger, const std::string &classic_dom_path);
47 virtual ~Stn();
48
49 void add_plan_action(const std::string &name, const std::string &params);
50 void set_initial_state(const StnAction &action);
51 void read_initial_state(const std::string &pddl_problem_string);
52 void set_pddl_domain(const std::string &pddl_domain_string);
53 void generate();
54 void drawGraph();
55 std::vector<bsoncxx::document::value> get_bson();
56
57private:
58 struct plan_action
59 {
60 std::string name;
61 std::string params;
62 };
63
64 fawkes::Logger *logger_;
65 bool gen_classic_dom_ = false;
66 std::string classic_dom_path_;
67 StnAction initial_state_;
68
69 std::vector<DomainAction> domain_actions_;
70 std::vector<plan_action> plan_actions_;
71 std::vector<StnAction> stn_actions_;
72
73 std::vector<std::pair<StnAction, StnAction>> cond_edges_;
74 std::vector<std::pair<StnAction, StnAction>> temp_edges_;
75
76 enum LogLevel { WARN, INFO, DEBUG };
77 void log_warn(const std::string &s);
78 void log_info(const std::string &s);
79 void log_debug(const std::string &s);
80 void log(const std::string &s, Stn::LogLevel log_leve);
81 StnAction findActionById(size_t id);
82 void add_domain_action(const DomainAction &action);
83 void build_pred_list(pddl_parser::Expression e, std::vector<Predicate> *preconds, bool condition);
84 void build_breakup_list(pddl_parser::Expression e, std::vector<std::string> *breakups);
85 void generate_classic_pddl_domain(pddl_parser::Domain *dom, const std::string &classic_dom_path);
86 void output_pred_list(pddl_parser::Expression e, std::ofstream &out);
87};
88
89} // namespace stn
90} // namespace fawkes
91
92#endif
Interface for logging.
Definition: logger.h:42
A representation of an action used by the STN generator.
Definition: domain_action.h:40
An action representation within an STN.
Definition: stn_action.h:41
A Simple Temporal Network.
Definition: stn.h:43
Stn(fawkes::Logger *logger)
Constructor.
Definition: stn.cpp:41
void add_plan_action(const std::string &name, const std::string &params)
Add a (grounded action).
Definition: stn.cpp:74
virtual ~Stn()
Destructor.
Definition: stn.cpp:56
void set_pddl_domain(const std::string &pddl_domain_string)
Set the domain of the STN to the given PDDL domain.
Definition: stn.cpp:130
std::vector< bsoncxx::document::value > get_bson()
Get a BSON representation of the STN.
Definition: stn.cpp:364
void read_initial_state(const std::string &pddl_problem_string)
Read the initial state from the given PDDL problem.
Definition: stn.cpp:94
void generate()
Regenerate the STN.
Definition: stn.cpp:212
void set_initial_state(const StnAction &action)
Set the initial state.
Definition: stn.cpp:85
void drawGraph()
Render a graph representation of the STN.
Definition: stn.cpp:306
Fawkes library namespace.
A structured representation of a PDDL domain.
Definition: pddl_ast.h:157
A PDDL Expression.
Definition: pddl_ast.h:78