OpenCog Framework  Branch: master, revision 6f0b7fc776b08468cf1b74aa9db028f387b4f0c0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
UREConfigReader.h
Go to the documentation of this file.
1 /*
2  * UREConfigReader.h
3  *
4  * Copyright (C) 2015 OpenCog Foundation
5  *
6  * Author: Nil Geisweiller <ngeiswei@gmail.com>
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU Affero General Public License v3 as
10  * published by the Free Software Foundation and including the exceptions
11  * at http://opencog.org/wiki/Licenses
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU Affero General Public License
19  * along with this program; if not, write to:
20  * Free Software Foundation, Inc.,
21  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22  */
23 
24 #ifndef _URE_CONFIG_READER_H
25 #define _URE_CONFIG_READER_H
26 
27 #include "Rule.h"
28 
30 
31 namespace opencog {
32 
45 {
46 public:
47  // Ctor
48 
49  // rbs is a Handle pointing to a rule-based system is as
51 
52  // Access methods, return parameters given a rule-based system
53  const std::vector<Rule>& get_rules() const;
54  std::vector<Rule>& get_rules();
55  bool get_attention_allocation() const;
56  int get_maximum_iterations() const;
57 
58  // Modifiers. WARNING: Those changes are not reflected in the
59  // AtomSpace, only in the UREConfigReader object.
60  void set_attention_allocation(bool);
61  void set_maximum_iterations(int);
62 
63  // Name of the top rule base from which all rule-based systems
64  // inherit. It should corresponds to a ConceptNode in the
65  // AtomSpace.
66  static const std::string top_rbs_name;
67 
68  // Name of the PredicateNode outputing whether attention
69  // allocation is enabled or not
70  static const std::string attention_alloc_name;
71 
72  // Name of the SchemaNode outputing the maximum iterations
73  // parameter
74  static const std::string max_iter_name;
75 private:
76 
77  // Fetch from the AtomSpace all rules of a given rube-based
78  // system. Specifically fetches patterns
79  //
80  // MemberLink <TV>
81  // <rule name>
82  // <rbs>
84 
86 
88  public:
89  std::vector<Rule> rules;
91  int max_iter;
92  };
94 
95  // Given <schema>, an <input> and optionally an output <type> (or
96  // subtype), return the <output>s in
97  //
98  // ExecutionLink
99  // <schema>
100  // <input>
101  // <output>
102  //
103  // inheriting <type>.
104  //
105  // The type (or subtype) can be used to avoid fetching patterns
106  // (if <type> is choosen not to have VARIABLE_NODE inherit from
107  // it).
109  Type type = ATOM);
110 
111  // Similar to above but takes instead the schema name instead of
112  // the schema Handle, assumes that output value is a NumberNode,
113  // and return directly that number.
114  //
115  // That is, given <schema_name> and <input> in
116  //
117  // ExecutionLink
118  // SchemaNode <schema_name>
119  // <input>
120  // NumberNode <num>
121  //
122  // Return the number associated to <num>
123  double fetch_num_param(const std::string& schema_name, Handle input);
124 
125  // Given <pred_name> and <input> in
126  //
127  // EvaluationLink TV
128  // PredicateNode <pred_name>
129  // <input>
130  //
131  // Return TV.mean > 0.5
132  bool fetch_bool_param(const std::string& pred_name, Handle input);
133 };
134 
135 } // ~namespace opencog
136 
137 
138 #endif /* _URE_CONFIG_READER_H_ */
RuleBaseParameters _rbparams
std::vector< Handle > HandleSeq
a list of handles
Definition: Handle.h:246
static const std::string max_iter_name
HandleSeq fetch_rules(Handle rbs)
int get_maximum_iterations() const
static const std::string top_rbs_name
static const std::string attention_alloc_name
const std::vector< Rule > & get_rules() const
UREConfigReader(AtomSpace &as, Handle rbs)
bool fetch_bool_param(const std::string &pred_name, Handle input)
HandleSeq fetch_execution_outputs(Handle schema, Handle input, Type type=ATOM)
bool get_attention_allocation() const
unsigned short Type
type of Atoms, represented as short integer (16 bits)
Definition: types.h:40
double fetch_num_param(const std::string &schema_name, Handle input)