-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update flaw initialization and resolver application logic
- Loading branch information
1 parent
4a30812
commit 15c23b9
Showing
9 changed files
with
50 additions
and
20 deletions.
There are no files selected for viewing
Submodule riddle
updated
5 files
+7 −1 | include/conjunction.hpp | |
+26 −26 | include/expression.hpp | |
+2 −0 | include/statement.hpp | |
+2 −0 | src/conjunction.cpp | |
+25 −25 | src/expression.cpp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,18 @@ | ||
#include <cassert> | ||
#include "disj_flaw.hpp" | ||
#include "solver.hpp" | ||
#include "graph.hpp" | ||
|
||
namespace ratio | ||
{ | ||
disj_flaw::disj_flaw(solver &s, std::vector<std::reference_wrapper<resolver>> &&causes, std::vector<utils::lit> &&lits, bool exclusive) noexcept : flaw(s, std::move(causes), exclusive), lits(lits) | ||
{ | ||
assert(!lits.empty()); | ||
} | ||
disj_flaw::disj_flaw(solver &s, std::vector<std::reference_wrapper<resolver>> &&causes, std::vector<utils::lit> &&lits, bool exclusive) noexcept : flaw(s, std::move(causes), exclusive), lits(lits) { assert(!lits.empty()); } | ||
|
||
void disj_flaw::compute_resolvers() | ||
{ | ||
throw std::runtime_error("Not implemented yet"); | ||
for (const auto &l : lits) | ||
if (get_solver().get_sat().value(l) != utils::False) | ||
get_solver().get_graph().new_resolver<choose_lit>(*this, utils::rational::one / lits.size(), l); | ||
} | ||
|
||
disj_flaw::choose_lit::choose_lit(disj_flaw &ef, const utils::rational &cost, const utils::lit &l) : resolver(ef, l, cost) {} | ||
} // namespace ratio |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,22 @@ | ||
#include <cassert> | ||
#include "disjunction_flaw.hpp" | ||
#include "solver.hpp" | ||
#include "graph.hpp" | ||
|
||
namespace ratio | ||
{ | ||
disjunction_flaw::disjunction_flaw(solver &s, std::vector<std::reference_wrapper<resolver>> &&causes, std::vector<std::unique_ptr<riddle::conjunction>> &&xprs) noexcept : flaw(s, std::move(causes)), xprs(std::move(xprs)) | ||
{ | ||
assert(!xprs.empty()); | ||
} | ||
disjunction_flaw::disjunction_flaw(solver &s, std::vector<std::reference_wrapper<resolver>> &&causes, std::vector<std::unique_ptr<riddle::conjunction>> &&conjs) noexcept : flaw(s, std::move(causes)), conjs(std::move(conjs)) { assert(!conjs.empty()); } | ||
|
||
void disjunction_flaw::compute_resolvers() | ||
{ | ||
throw std::runtime_error("Not implemented yet"); | ||
for (auto &conj : conjs) | ||
{ | ||
auto cost = conj->compute_cost(); | ||
get_solver().get_graph().new_resolver<choose_conjunction>(*this, *conj, get_solver().arithmetic_value(*cost).get_rational()); | ||
} | ||
} | ||
|
||
disjunction_flaw::choose_conjunction::choose_conjunction(disjunction_flaw &df, riddle::conjunction &conj, const utils::rational &cost) : resolver(df, cost), conj(conj) {} | ||
|
||
void disjunction_flaw::choose_conjunction::apply() { conj.execute(); } | ||
} // namespace ratio |