AI 24/25 Project Software
Documentation for the AI 24/25 course programming project software
Loading...
Searching...
No Matches
constraint_generator.h
1#ifndef OPERATOR_COUNTING_CONSTRAINT_GENERATOR_H
2#define OPERATOR_COUNTING_CONSTRAINT_GENERATOR_H
3
4#include <memory>
5#include <vector>
6
7#include "downward/algorithms/named_vector.h"
8
9class AbstractTask;
10class State;
11
12namespace lp {
13class LinearProgram;
14class LPSolver;
15} // namespace lp
16
17namespace operator_counting {
18/*
19 Derive from this class to add new operator-counting constraints. We support
20 two types of constraints:
21 - *Permanent constraints* are created once for the planning task and then
22 reused for all states that are evaluated. It is possible (and usually
23 necessary) to update the bounds of the constraint for every given state,
24 but not the coefficients.
25 Example: flow constraints such as
26 move_ab + move_ac - move_ba - move_ca <= X,
27 where X depends on the value of "at_a" in the current state and goal.
28 - *Temporary constraints* are added for a given state and then removed.
29 Example: constraints from landmarks generated for a given state, e.g.
30 using the LM-Cut method.
31*/
32class ConstraintGenerator {
33public:
34 virtual ~ConstraintGenerator() = default;
35
36 /*
37 Called upon initialization for the given task. Use this to add permanent
38 constraints and perform other initialization.
39 */
40 virtual void initialize_constraints(
41 const std::shared_ptr<AbstractTask>& task,
42 lp::LinearProgram& lp);
43
44 /*
45 Called before evaluating a state. Use this to add temporary constraints
46 and to set bounds on permanent constraints for this state. All temporary
47 constraints are removed automatically after the evalution.
48
49 Returns true if a dead end was detected and false otherwise.
50 */
51 virtual bool
52 update_constraints(const State& state, lp::LPSolver& lp_solver) = 0;
53};
54} // namespace operator_counting
55
56#endif