Skip to content

Commit

Permalink
Update subproject references and change on_sat_value_changed paramete…
Browse files Browse the repository at this point in the history
…r type from std::size_t to utils::var in resolver and flaw classes
  • Loading branch information
riccardodebenedictis committed Nov 11, 2024
1 parent 3e0e7f0 commit 3d3df76
Show file tree
Hide file tree
Showing 12 changed files with 39 additions and 39 deletions.
2 changes: 1 addition & 1 deletion extern/riddle
10 changes: 5 additions & 5 deletions include/flaw.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ namespace ratio
/**
* @brief Get the position variable associated to this flaw.
*
* @return std::size_t the position variable associated to this flaw.
* @return utils::var the position variable associated to this flaw.
*/
std::size_t get_position() const noexcept { return position; }
utils::var get_position() const noexcept { return position; }

/**
* @brief Check whether this flaw has been expanded.
Expand Down Expand Up @@ -130,9 +130,9 @@ namespace ratio
virtual void compute_resolvers() = 0;

#ifdef ENABLE_API
void on_sat_value_changed(std::size_t v) override;
void on_sat_value_changed(utils::var v) override;

void on_idl_value_changed(std::size_t v) override;
void on_idl_value_changed(utils::var v) override;

/**
* @brief Get a JSON representation of the data of the flaw.
Expand All @@ -151,7 +151,7 @@ namespace ratio
const bool enqueue; // whether this flaw must be enqueued or can be expanded..
utils::lit phi; // the literal indicating whether the flaw is active or not (this literal is initialized by the `init` procedure)..
utils::rational est_cost = utils::rational::positive_infinite; // the current estimated cost of the flaw..
std::size_t position; // the position variable (i.e., an integer time-point) associated to this flaw..
utils::var position; // the position variable (i.e., an integer time-point) associated to this flaw..
bool expanded = false; // whether this flaw has been expanded or not..
std::vector<std::reference_wrapper<resolver>> resolvers; // the resolvers for this flaw..
std::vector<std::reference_wrapper<resolver>> supports; // the resolvers supported by this flaw (used for propagating cost estimates)..
Expand Down
24 changes: 12 additions & 12 deletions include/graph.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -276,18 +276,18 @@ namespace ratio
void pop() noexcept override;

private:
solver &slv; // the solver this graph belongs to..
std::unordered_map<std::size_t, std::vector<std::unique_ptr<flaw>>> phis; // the phi variables (propositional variable to flaws) of the flaws..
std::vector<std::unique_ptr<flaw>> pending_flaws; // pending flaws, waiting for root-level to be initialized..
std::unordered_map<std::size_t, std::vector<std::unique_ptr<resolver>>> rhos; // the rho variables (propositional variable to resolver) of the resolvers..
std::optional<std::reference_wrapper<flaw>> c_flaw; // the current flaw..
std::optional<std::reference_wrapper<resolver>> c_res; // the current resolver..
utils::lit tmp_ni; // the temporary controlling literal, used for restoring the controlling literal..
utils::lit ni{utils::TRUE_lit}; // the current controlling literal..
std::deque<std::reference_wrapper<flaw>> flaw_q; // the flaw queue (for the graph building procedure)..
std::unordered_set<flaw *> visited; // the visited flaws, for graph cost propagation (and deferrable flaws check)..
std::unordered_set<flaw *> active_flaws; // the currently active flaws..
std::size_t gamma; // the variable representing the validity of this graph..
solver &slv; // the solver this graph belongs to..
std::unordered_map<utils::var, std::vector<std::unique_ptr<flaw>>> phis; // the phi variables (propositional variable to flaws) of the flaws..
std::vector<std::unique_ptr<flaw>> pending_flaws; // pending flaws, waiting for root-level to be initialized..
std::unordered_map<utils::var, std::vector<std::unique_ptr<resolver>>> rhos; // the rho variables (propositional variable to resolver) of the resolvers..
std::optional<std::reference_wrapper<flaw>> c_flaw; // the current flaw..
std::optional<std::reference_wrapper<resolver>> c_res; // the current resolver..
utils::lit tmp_ni; // the temporary controlling literal, used for restoring the controlling literal..
utils::lit ni{utils::TRUE_lit}; // the current controlling literal..
std::deque<std::reference_wrapper<flaw>> flaw_q; // the flaw queue (for the graph building procedure)..
std::unordered_set<flaw *> visited; // the visited flaws, for graph cost propagation (and deferrable flaws check)..
std::unordered_set<flaw *> active_flaws; // the currently active flaws..
utils::var gamma; // the variable representing the validity of this graph..

/**
* @brief Represents a layer in the solver.
Expand Down
2 changes: 1 addition & 1 deletion include/resolver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ namespace ratio
virtual void apply() = 0;

#ifdef ENABLE_API
void on_sat_value_changed(std::size_t v) override;
void on_sat_value_changed(utils::var v) override;

/**
* @brief Get a JSON representation of the data of the resolver.
Expand Down
8 changes: 4 additions & 4 deletions include/types/consumable_resource.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ namespace ratio

void something_changed();

void on_sat_value_changed(std::size_t) override { something_changed(); }
void on_rdl_value_changed(std::size_t) override { something_changed(); }
void on_lra_value_changed(std::size_t) override { something_changed(); }
void on_ov_value_changed(std::size_t) override { something_changed(); }
void on_sat_value_changed(utils::var) override { something_changed(); }
void on_rdl_value_changed(utils::var) override { something_changed(); }
void on_lra_value_changed(utils::var) override { something_changed(); }
void on_ov_value_changed(utils::var) override { something_changed(); }

consumable_resource &cr;
};
Expand Down
8 changes: 4 additions & 4 deletions include/types/reusable_resource.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,10 @@ namespace ratio

void something_changed();

void on_sat_value_changed(std::size_t) override { something_changed(); }
void on_rdl_value_changed(std::size_t) override { something_changed(); }
void on_lra_value_changed(std::size_t) override { something_changed(); }
void on_ov_value_changed(std::size_t) override { something_changed(); }
void on_sat_value_changed(utils::var) override { something_changed(); }
void on_rdl_value_changed(utils::var) override { something_changed(); }
void on_lra_value_changed(utils::var) override { something_changed(); }
void on_ov_value_changed(utils::var) override { something_changed(); }

reusable_resource &rr;
};
Expand Down
8 changes: 4 additions & 4 deletions include/types/state_variable.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,10 @@ namespace ratio

void something_changed();

void on_sat_value_changed(std::size_t) override { something_changed(); }
void on_rdl_value_changed(std::size_t) override { something_changed(); }
void on_lra_value_changed(std::size_t) override { something_changed(); }
void on_ov_value_changed(std::size_t) override { something_changed(); }
void on_sat_value_changed(utils::var) override { something_changed(); }
void on_rdl_value_changed(utils::var) override { something_changed(); }
void on_lra_value_changed(utils::var) override { something_changed(); }
void on_ov_value_changed(utils::var) override { something_changed(); }

state_variable &sv;
};
Expand Down
4 changes: 2 additions & 2 deletions src/flaw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ namespace ratio
}

#ifdef ENABLE_API
void flaw::on_sat_value_changed(std::size_t v) { s.flaw_state_changed(*this); }
void flaw::on_sat_value_changed(utils::var v) { s.flaw_state_changed(*this); }

void flaw::on_idl_value_changed(std::size_t v) { s.flaw_position_changed(*this); }
void flaw::on_idl_value_changed(utils::var v) { s.flaw_position_changed(*this); }
#endif
} // namespace ratio
2 changes: 1 addition & 1 deletion src/resolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@ namespace ratio
}

#ifdef ENABLE_API
void resolver::on_sat_value_changed(std::size_t v) { f.get_solver().resolver_state_changed(*this); }
void resolver::on_sat_value_changed(utils::var v) { f.get_solver().resolver_state_changed(*this); }
#endif
} // namespace ratio
4 changes: 2 additions & 2 deletions src/types/reusable_resource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ namespace ratio

// we compute the possible resolvers..
std::vector<std::pair<utils::lit, double>> choices;
std::unordered_set<std::size_t> vars;
std::unordered_set<utils::var> vars;
// we consider all the pairs of atoms in the Minimal Conflict Sets (MCSs)..
for (const auto &as : utils::combinations(std::vector<atom *>(overlapping_atoms.cbegin(), overlapping_atoms.cend()), 2))
{
Expand Down Expand Up @@ -333,7 +333,7 @@ namespace ratio
reusable_resource::rr_flaw::rr_flaw(reusable_resource &rr_tp, const riddle::component &rr, const std::set<atom *> &mcs) : flaw(rr_tp.get_solver(), smart_type::get_resolvers(mcs), true, false), rr_tp(rr_tp), rr(rr), mcs(mcs) {}
void reusable_resource::rr_flaw::compute_resolvers()
{
std::unordered_set<std::size_t> vars;
std::unordered_set<utils::var> vars;
for (const auto &as : utils::combinations(std::vector<atom *>(mcs.cbegin(), mcs.cend()), 2))
{
if (const auto a0_it = rr_tp.leqs.find(as[0]); a0_it != rr_tp.leqs.cend())
Expand Down
4 changes: 2 additions & 2 deletions src/types/state_variable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ namespace ratio
has_conflict = true;
// we compute the possible resolvers..
std::vector<std::pair<utils::lit, double>> choices;
std::unordered_set<std::size_t> vars;
std::unordered_set<utils::var> vars;
// we consider all the pairs of atoms in the Minimal Conflict Sets (MCSs)..
for (const auto &as : utils::combinations(std::vector<atom *>(overlapping_atoms.cbegin(), overlapping_atoms.cend()), 2))
{
Expand Down Expand Up @@ -259,7 +259,7 @@ namespace ratio
state_variable::sv_flaw::sv_flaw(state_variable &sv_tp, const riddle::component &sv, const std::set<atom *> &mcs) : flaw(sv_tp.get_solver(), smart_type::get_resolvers(mcs), true, false), sv_tp(sv_tp), sv(sv), mcs(mcs) {}
void state_variable::sv_flaw::compute_resolvers()
{
std::unordered_set<std::size_t> vars;
std::unordered_set<utils::var> vars;
for (const auto &as : utils::combinations(std::vector<atom *>(mcs.cbegin(), mcs.cend()), 2))
{
if (const auto a0_it = sv_tp.leqs.find(as[0]); a0_it != sv_tp.leqs.cend())
Expand Down

0 comments on commit 3d3df76

Please sign in to comment.