1#ifndef HEURISTICS_CG_CACHE_H
2#define HEURISTICS_CG_CACHE_H
4#include "downward/task_proxy.h"
8namespace domain_transition_graph {
9struct ValueTransitionLabel;
16namespace cg_heuristic {
19 std::vector<std::vector<int>> cache;
20 std::vector<std::vector<domain_transition_graph::ValueTransitionLabel*>>
21 helpful_transition_cache;
22 std::vector<std::vector<int>> depends_on;
24 int get_index(
int var,
const State& state,
int from_val,
int to_val)
const;
25 int compute_required_cache_size(
27 const std::vector<int>& depends_on,
28 int max_cache_size)
const;
31 static const int NOT_COMPUTED = -2;
34 const TaskProxy& task_proxy,
36 utils::LogProxy& log);
38 bool is_cached(
int var)
const {
return !cache[var].empty(); }
40 int lookup(
int var,
const State& state,
int from_val,
int to_val)
const
42 return cache[var][get_index(var, state, from_val, to_val)];
45 void store(
int var,
const State& state,
int from_val,
int to_val,
int cost)
47 cache[var][get_index(var, state, from_val, to_val)] = cost;
50 domain_transition_graph::ValueTransitionLabel* lookup_helpful_transition(
56 int index = get_index(var, state, from_val, to_val);
57 return helpful_transition_cache[var][index];
60 void store_helpful_transition(
65 domain_transition_graph::ValueTransitionLabel* helpful_transition)
67 int index = get_index(var, state, from_val, to_val);
68 helpful_transition_cache[var][index] = helpful_transition;