@@ -8,17 +8,24 @@ namespace ratio
88 class ls_flaw : public riddle ::flaw
99 {
1010 public:
11- ls_flaw (solver &cr, std::vector<std::shared_ptr<riddle::resolver>> &&causes, const utils::lit &phi );
11+ ls_flaw (solver &cr, std::vector<std::shared_ptr<riddle::resolver>> &&causes);
1212
1313 const utils::lit &get_phi () const noexcept { return phi; }
1414
15+ utils::rational get_estimated_cost () const noexcept override ;
16+
17+ private:
18+ utils::lit get_phi (const std::vector<std::shared_ptr<riddle::resolver>> &causes) const noexcept ;
19+
1520 private:
1621 const utils::lit phi;
22+ utils::rational est_cost = utils::rational::positive_infinite; // the estimated cost of this flaw..
1723 };
1824
1925 class ls_resolver : public resolver
2026 {
2127 public:
28+ ls_resolver (ls_flaw &flw, utils::rational &&intrinsic_cost);
2229 ls_resolver (ls_flaw &flw, utils::rational &&intrinsic_cost, const utils::lit &rho);
2330
2431 const utils::lit &get_rho () const noexcept { return rho; }
@@ -30,9 +37,7 @@ namespace ratio
3037 class enum_flaw final : public ls_flaw
3138 {
3239 public:
33- enum_flaw (solver &slv, std::vector<std::shared_ptr<riddle::resolver>> &&causes, const utils::lit &phi, riddle::component_type &tp, std::vector<riddle::expr> &&values, utils::var ev) noexcept ;
34-
35- utils::rational get_estimated_cost () const noexcept override ;
40+ enum_flaw (solver &slv, std::vector<std::shared_ptr<riddle::resolver>> &&causes, riddle::component_type &tp, std::vector<riddle::expr> &&values, utils::var ev) noexcept ;
3641
3742 [[nodiscard]] const riddle::enum_expr &get_var () const noexcept { return var; }
3843
@@ -57,9 +62,7 @@ namespace ratio
5762 class clause_flaw final : public ls_flaw
5863 {
5964 public:
60- clause_flaw (solver &slv, std::vector<std::shared_ptr<riddle::resolver>> &&causes, const utils::lit &phi, std::vector<riddle::bool_expr> &&clause) noexcept ;
61-
62- utils::rational get_estimated_cost () const noexcept override ;
65+ clause_flaw (solver &slv, std::vector<std::shared_ptr<riddle::resolver>> &&causes, std::vector<riddle::bool_expr> &&clause) noexcept ;
6366
6467 [[nodiscard]] const std::vector<riddle::bool_expr> &get_clause () const noexcept { return clause; }
6568
@@ -72,12 +75,24 @@ namespace ratio
7275 std::vector<riddle::bool_expr> clause;
7376 };
7477
75- class disjunction_flaw final : public ls_flaw
78+ class choose_lit final : public ls_resolver
7679 {
7780 public:
78- disjunction_flaw (solver &slv, std::vector<std::shared_ptr< riddle::resolver>> &&causes, const utils:: lit &phi, std::vector<std::unique_ptr<riddle::conjunction>> &&disjuncts ) noexcept ;
81+ choose_lit (clause_flaw &f, riddle::bool_expr lit) noexcept ;
7982
80- utils::rational get_estimated_cost () const noexcept override ;
83+ private:
84+ bool apply () noexcept override ;
85+
86+ [[nodiscard]] json::json to_json () const override ;
87+
88+ private:
89+ riddle::bool_expr lit; // the literal to choose..
90+ };
91+
92+ class disjunction_flaw final : public ls_flaw
93+ {
94+ public:
95+ disjunction_flaw (solver &slv, std::vector<std::shared_ptr<riddle::resolver>> &&causes, std::vector<std::unique_ptr<riddle::conjunction>> &&disjuncts) noexcept ;
8196
8297 [[nodiscard]] const std::vector<std::unique_ptr<riddle::conjunction>> &get_disjuncts () const noexcept { return disjuncts; }
8398
@@ -89,4 +104,133 @@ namespace ratio
89104 private:
90105 std::vector<std::unique_ptr<riddle::conjunction>> disjuncts;
91106 };
107+
108+ class choose_conjunction final : public ls_resolver
109+ {
110+ public:
111+ choose_conjunction (disjunction_flaw &f, riddle::conjunction &conj) noexcept ;
112+
113+ private:
114+ bool apply () noexcept override ;
115+
116+ [[nodiscard]] json::json to_json () const override ;
117+
118+ private:
119+ riddle::conjunction &conj;
120+ };
121+
122+ class atom_flaw final : public ls_flaw
123+ {
124+ public:
125+ atom_flaw (solver &slv, std::vector<std::shared_ptr<riddle::resolver>> &&causes, bool is_fact, riddle::predicate &pred, std::map<std::string, riddle::expr, std::less<>> &&args, riddle::bool_expr &&sigma) noexcept ;
126+
127+ [[nodiscard]] const riddle::atom_expr &get_atom () const noexcept { return atm; }
128+
129+ private:
130+ void compute_resolvers () override ;
131+
132+ [[nodiscard]] json::json to_json () const override ;
133+
134+ private:
135+ riddle::atom_expr atm;
136+ };
137+
138+ class activate_fact final : public ls_resolver
139+ {
140+ public:
141+ activate_fact (atom_flaw &f) noexcept ;
142+
143+ private:
144+ bool apply () noexcept override ;
145+
146+ json::json to_json () const override ;
147+ };
148+
149+ class activate_goal final : public ls_resolver
150+ {
151+ public:
152+ activate_goal (atom_flaw &f) noexcept ;
153+
154+ private:
155+ bool apply () noexcept override ;
156+
157+ json::json to_json () const override ;
158+ };
159+
160+ class unify_atom final : public ls_resolver
161+ {
162+ public:
163+ unify_atom (atom_flaw &f, riddle::atom_expr atm) noexcept ;
164+
165+ private:
166+ bool apply () noexcept override ;
167+
168+ json::json to_json () const override ;
169+
170+ private:
171+ riddle::atom_expr atm; // the atom to unify with..
172+ };
173+
174+ class sv_peak final : public ls_flaw
175+ {
176+ public:
177+ sv_peak (solver &slv, std::vector<riddle::atom_expr> &&atms) noexcept ;
178+
179+ private:
180+ void compute_resolvers () noexcept override ;
181+
182+ private:
183+ std::vector<riddle::atom_expr> atms;
184+ };
185+
186+ class rr_peak final : public ls_flaw
187+ {
188+ public:
189+ rr_peak (solver &slv, std::vector<riddle::atom_expr> &&atms) noexcept ;
190+
191+ private:
192+ void compute_resolvers () noexcept override ;
193+
194+ private:
195+ std::vector<riddle::atom_expr> atms;
196+ };
197+
198+ class cr_overproduction final : public ls_flaw
199+ {
200+ public:
201+ cr_overproduction (solver &slv, std::vector<riddle::atom_expr> &&prod_atms, std::vector<riddle::atom_expr> &&cons_atms) noexcept ;
202+
203+ private:
204+ void compute_resolvers () noexcept override ;
205+
206+ private:
207+ std::vector<riddle::atom_expr> prod_atms;
208+ std::vector<riddle::atom_expr> cons_atms;
209+ };
210+
211+ class cr_overconsumption final : public ls_flaw
212+ {
213+ public:
214+ cr_overconsumption (solver &slv, std::vector<riddle::atom_expr> &&cons_atms, std::vector<riddle::atom_expr> &&prod_atms) noexcept ;
215+
216+ private:
217+ void compute_resolvers () noexcept override ;
218+
219+ private:
220+ std::vector<riddle::atom_expr> cons_atms;
221+ std::vector<riddle::atom_expr> prod_atms;
222+ };
223+
224+ class ordering final : public ls_resolver
225+ {
226+ public:
227+ ordering (ls_flaw &flw, riddle::atom_expr before, riddle::atom_expr after) noexcept ;
228+
229+ private:
230+ bool apply () noexcept override ;
231+
232+ private:
233+ riddle::atom_expr before;
234+ riddle::atom_expr after;
235+ };
92236} // namespace ratio
0 commit comments