AI 24/25 Project Software
Documentation for the AI 24/25 course programming project software
Loading...
Searching...
No Matches
axioms.h
1#ifndef AXIOMS_H
2#define AXIOMS_H
3
4#include "downward/per_task_information.h"
5#include "downward/task_proxy.h"
6
7#include <memory>
8#include <vector>
9
10class AxiomEvaluator {
11 struct AxiomRule;
12 struct AxiomLiteral {
13 std::vector<AxiomRule*> condition_of;
14 };
15 struct AxiomRule {
16 int condition_count;
17 int unsatisfied_conditions;
18 int effect_var;
19 int effect_val;
20 AxiomLiteral* effect_literal;
21 AxiomRule(
22 int cond_count,
23 int eff_var,
24 int eff_val,
25 AxiomLiteral* eff_literal)
26 : condition_count(cond_count)
27 , unsatisfied_conditions(cond_count)
28 , effect_var(eff_var)
29 , effect_val(eff_val)
30 , effect_literal(eff_literal)
31 {
32 }
33 };
34 struct NegationByFailureInfo {
35 int var_no;
36 AxiomLiteral* literal;
37 NegationByFailureInfo(int var, AxiomLiteral* lit)
38 : var_no(var)
39 , literal(lit)
40 {
41 }
42 };
43
44 bool task_has_axioms;
45
46 std::vector<std::vector<AxiomLiteral>> axiom_literals;
47 std::vector<AxiomRule> rules;
48 std::vector<std::vector<NegationByFailureInfo>> nbf_info_by_layer;
49 /*
50 default_values stores the default (negation by failure) values
51 for all derived variables, i.e., the value that a derived
52 variable holds by default if no derivation rule triggers.
53
54 This is indexed by variable number and set to -1 for non-derived
55 variables, so can also be used to test if a variable is derived.
56
57 We have our own copy of the data to avoid going through the task
58 interface in the time-critical evaluate method.
59 */
60 std::vector<int> default_values;
61
62 /*
63 The queue is an instance variable rather than a local variable
64 to reduce reallocation effort. See issue420.
65 */
66 std::vector<const AxiomLiteral*> queue;
67
68 template <typename Values, typename Accessor>
69 void evaluate_aux(Values& values, const Accessor& accessor);
70
71public:
72 explicit AxiomEvaluator(const PlanningTaskProxy& task_proxy);
73
74 void evaluate(std::vector<int>& state);
75};
76
77extern PerTaskInformation<AxiomEvaluator> g_axiom_evaluators;
78
79#endif