AI 24/25 Project Software
Documentation for the AI 24/25 course programming project software
Loading...
Searching...
No Matches
delete_relaxation_if_constraints.h
1#ifndef OPERATOR_COUNTING_DELETE_RELAXATION_IF_CONSTRAINTS_H
2#define OPERATOR_COUNTING_DELETE_RELAXATION_IF_CONSTRAINTS_H
3
4#include "downward/operator_counting/constraint_generator.h"
5
6#include "downward/task_proxy.h"
7
8#include <memory>
9
10namespace lp {
11class LPConstraint;
12struct LPVariable;
13} // namespace lp
14
15namespace operator_counting {
16using LPConstraints = named_vector::NamedVector<lp::LPConstraint>;
17using LPVariables = named_vector::NamedVector<lp::LPVariable>;
18
19class DeleteRelaxationIFConstraints : public ConstraintGenerator {
20 bool use_time_vars;
21 bool use_integer_vars;
22
23 /* [U_o] Is op part of the relaxed plan?
24 Binary, indexed with op.id */
25 std::vector<int> lp_var_id_op_used;
26
27 /* [R_f] Is fact <V,v> reached by the relaxed plan?
28 Binary, indexed with var.id, value */
29 std::vector<std::vector<int>> lp_var_id_fact_reached;
30
31 /* [F_{o,f}] Is o the first achiever of fact <V,v> in the relaxed plan?
32 Binary, indexed with op.id, var.id, value */
33 std::vector<std::vector<std::vector<int>>> lp_var_id_first_achiever;
34
35 /* [T_o] At what time is o used first?
36 {0, ..., |O|}, indexed with op.id */
37 std::vector<int> lp_var_id_op_time;
38
39 /* [T_f] At what time is <V,v> first achieved?
40 {0, ..., |O|}, indexed with var.id, value */
41 std::vector<std::vector<int>> lp_var_id_fact_time;
42
43 /* Indices of constraints that change in every state
44 Indexed with var.id, value */
45 std::vector<std::vector<int>> constraint_ids;
46
47 /* The state that is currently used for setting the bounds. Remembering
48 this makes it faster to unset the bounds when the state changes. */
49 std::vector<FactPair> last_state;
50
51 int get_var_op_used(const OperatorProxy& op);
52 int get_var_fact_reached(FactPair f);
53 int get_var_first_achiever(const OperatorProxy& op, FactPair f);
54 int get_var_op_time(const OperatorProxy& op);
55 int get_var_fact_time(FactPair f);
56 int get_constraint_id(FactPair f);
57
58 void create_auxiliary_variables(
59 const TaskProxy& task_proxy,
60 LPVariables& variables);
61 void create_constraints(const TaskProxy& task_proxy, lp::LinearProgram& lp);
62
63public:
64 explicit DeleteRelaxationIFConstraints(
65 bool use_time_vars,
66 bool use_integer_vars);
67
68 virtual void initialize_constraints(
69 const std::shared_ptr<AbstractTask>& task,
70 lp::LinearProgram& lp) override;
71 virtual bool
72 update_constraints(const State& state, lp::LPSolver& lp_solver) override;
73};
74} // namespace operator_counting
75
76#endif