AERA
|
#include <mdl_controller.h>
Public Member Functions | |
PrimaryMDLController (r_code::_View *view) | |
void | set_secondary (SecondaryMDLController *secondary) |
void | take_input (r_exec::View *input) override |
void | reduce (r_exec::View *input) |
void | reduce_batch (Fact *f_p_f_imdl, MDLController *controller) |
void | store_requirement (_Fact *f_p_f_imdl, MkRdx *mk_rdx, MDLController *controller, bool chaining_was_allowed) override |
void | predict (HLPBindingMap *bm, _Fact *input, Fact *f_imdl, bool chaining_was_allowed, RequirementsPair &r_p, Fact *ground, MkRdx *ground_mk_rdx, std::vector< P< _Fact > > &already_predicted) override |
bool | inject_prediction (Fact *prediction, Fact *f_imdl, float32 confidence, Timestamp::duration time_to_live, r_code::Code *mk_rdx) const |
void | register_pred_outcome (Fact *f_pred, r_code::Code *mk_rdx, bool success, _Fact *evidence, float32 confidence, bool rate_failures) override |
void | register_req_outcome (Fact *f_pred, bool success, bool rate_failures) override |
void | register_goal_outcome (Fact *goal, bool success, _Fact *evidence) const override |
void | register_simulated_goal_outcome (Fact *goal, bool success, _Fact *evidence) const override |
bool | check_imdl (Fact *goal, HLPBindingMap *bm) |
bool | check_simulated_imdl (Fact *goal, HLPBindingMap *bm, Sim *prediction_sim) |
void | abduce (HLPBindingMap *bm, Fact *super_goal, bool opposite, float32 confidence) |
void | abduce_no_simulation (Fact *super_goal, bool opposite, float32 confidence, _Fact *f_p_f_success=NULL) |
bool | get_template_timings (HLPBindingMap *bm, Timestamp &after, Timestamp &before) |
void | debug (View *input) |
![]() | |
void | add_g_monitor (_GMonitor *m) |
void | remove_g_monitor (_GMonitor *m) |
void | add_r_monitor (_GMonitor *m) |
void | remove_r_monitor (_GMonitor *m) |
void | register_predicted_goal_outcome (Fact *goal, HLPBindingMap *bm, Fact *f_imdl, bool success, bool injected_goal) |
void | inject_simulated_goal_success (Fact *goal, bool success, _Fact *evidence) const |
![]() | |
void | add_monitor (PMonitor *m) |
void | remove_monitor (PMonitor *m) |
_Fact * | get_lhs () const |
_Fact * | get_rhs () const |
Fact * | get_f_ihlp (HLPBindingMap *bindings, bool wr_enabled) const override |
ChainingStatus | retrieve_imdl_fwd (const HLPBindingMap *bm, Fact *f_imdl, RequirementsPair &r_p, std::vector< BindingResult > &results, MDLController *req_controller, bool &wr_enabled) |
ChainingStatus | retrieve_imdl_bwd (HLPBindingMap *bm, Fact *f_imdl, Fact *&ground, Fact *&strong_requirement_ground) |
ChainingStatus | retrieve_simulated_imdl_fwd (const HLPBindingMap *bm, Fact *f_imdl, Sim *sim, std::vector< BindingResult > &results) |
ChainingStatus | retrieve_simulated_imdl_bwd (HLPBindingMap *bm, Fact *f_imdl, Sim *prediction_sim, Fact *&ground, Fact *&strong_requirement_ground) |
void | add_requirement_to_rhs () |
void | remove_requirement_from_rhs () |
bool | is_requirement () const |
bool | is_reuse () const |
bool | is_cmd () const |
void | register_requirement (_Fact *f_pred, RequirementsPair &r_p) |
![]() | |
void | invalidate () override |
r_code::Code * | get_core_object () const override |
r_code::Code * | get_unpacked_object () const |
void | add_requirement (bool strong) |
void | remove_requirement (bool strong) |
uint32 | get_requirement_count (uint32 &weak_requirement_count, uint32 &strong_requirement_count) |
uint32 | get_requirement_count () |
void | store_evidence (_Fact *evidence) |
void | store_predicted_evidence (_Fact *evidence) |
uint16 | get_out_group_count () const |
r_code::Code * | get_out_group (uint16 i) const |
Group * | get_host () const |
bool | has_tpl_args () const |
bool | inject_prediction (Fact *prediction, float32 confidence) const |
![]() | |
std::chrono::microseconds | get_tsc () |
bool | is_invalidated () |
void | activate (bool a) |
bool | is_activated () const |
bool | is_alive () const |
r_code::Code * | get_object () const |
r_exec::View * | get_view () const |
void | _take_input (r_exec::View *input) |
virtual void | gain_activation () |
virtual void | lose_activation () |
void | set_view (View *view) |
void | debug (View *) |
![]() | |
void | incRef () |
virtual void | decRef () |
Additional Inherited Members | |
![]() | |
static MDLController * | New (View *view, bool &inject_in_secondary_group) |
static bool | get_imdl_template_timings (r_code::Code *imdl, Timestamp &after, Timestamp &before, uint16 *after_ts_index=NULL, uint16 *before_ts_index=NULL) |
![]() | |
enum | RequirementType { NOT_A_REQUIREMENT = 0, WEAK_REQUIREMENT = 1, STRONG_REQUIREMENT = 2 } |
![]() | |
virtual uint32 | get_rdx_out_group_count () const |
void | inject_goal (HLPBindingMap *bm, Fact *goal, Fact *f_imdl) const |
void | inject_simulation (Fact *simulation, Timestamp injectionTime) const |
bool | monitor_goals (_Fact *input) |
std::chrono::microseconds | get_sim_thz (Timestamp now, Timestamp deadline) const |
PMDLController (r_code::_View *view) | |
![]() | |
void | _store_requirement (r_code::list< RequirementEntry > *cache, RequirementEntry &e) |
float32 | get_success_rate () const |
template<class C > | |
void | reduce_cache (Fact *f_p_f_imdl, MDLController *controller) |
template<class E > | |
void | reduce_cache (CriticalSectionList< E > *cache, Fact *f_p_f_imdl, MDLController *controller) |
bool | monitor_predictions (_Fact *input) |
MDLController (r_code::_View *view) | |
![]() | |
template<class E > | |
void | _store_evidence (CriticalSectionList< E > *cache, _Fact *evidence) |
bool | evaluate_bwd_guards (HLPBindingMap *bm, bool narrow_fwd_timings=false) |
MatchResult | check_evidences (_Fact *target, _Fact *&evidence) |
MatchResult | check_predicted_evidences (_Fact *target, _Fact *&evidence) |
void | inject_notification_into_out_groups (r_code::Code *origin, r_code::Code *marker) const |
bool | is_orphan () |
bool | become_invalidated () |
HLPController (r_code::_View *view) | |
![]() | |
OController (r_code::_View *view) | |
![]() | |
template<class C > | |
void | __take_input (r_exec::View *input) |
Controller (r_code::_View *view) | |
![]() | |
static void | push_reduction_job (_ReductionJob *j) |
![]() | |
CriticalSection | g_monitorsCS_ |
r_code::list< P< _GMonitor > > | g_monitors_ |
r_code::list< P< _GMonitor > > | r_monitors_ |
![]() | |
RequirementCache | requirements_ |
RequirementCache | simulated_requirements_ |
CriticalSection | p_monitorsCS_ |
r_code::list< P< PMonitor > > | p_monitors_ |
P< r_code::Code > | lhs_ |
P< r_code::Code > | rhs_ |
RequirementType | requirement_type_ |
bool | is_reuse_ |
bool | is_cmd_ |
CriticalSection | active_requirementsCS_ |
std::unordered_map< P< _Fact >, RequirementsPair, r_code::PHash< _Fact > > | active_requirements_ |
![]() | |
CriticalSectionList< EvidenceEntry > | evidences_ |
CriticalSectionList< PredictedEvidenceEntry > | predicted_evidences_ |
P< HLPBindingMap > | bindings_ |
bool | has_tpl_args_ |
uint32 | ref_count_ |
std::vector< P< HLPController > > | controllers_ |
Timestamp | last_match_time_ |
![]() | |
r_code::list< P< Overlay > > | overlays_ |
![]() | |
volatile uint32 | invalidated_ |
volatile uint32 | activated_ |
std::chrono::microseconds | time_scope_ |
r_code::_View * | view_ |
CriticalSection | reductionCS_ |
![]() | |
std::atomic_int32_t | refCount_ |
![]() | |
static const uint32 | LHSController = 0 |
static const uint32 | RHSController = 1 |
Backward chaining: inputs are goals, actual or simulated. Actual goals: if LHS is in the fact cache, stop. if LHS is in the prediction cache, spawn a g-monitor (will be ready to catch a counter-prediction, invalidate the goal and re-issue a new goal). else if (before-now)*percentage<min sthz, commit sub-goal on LHS. else if chaining is allowed, simulate the LHS and spawn a g-monitor with sthz=min((before-now)*percentage,max sthz)-min sthz. else, simulate f->imdl and spawn a g-monitor with sthz=min((before-now)*percentage,max sthz)/2-min sthz. Simulated goals: if LHS is in the fact cache, . if LHS is in the prediction cache, else: if sthz/2>min thz, simulate the LHS and spawn a g-monitor with sthz/2-min sthz. else predict RHS (cfd=1) and stop. Commands with unbound values are not injected.
Definition at line 429 of file mdl_controller.h.
void r_exec::PrimaryMDLController::abduce_no_simulation | ( | Fact * | super_goal, |
bool | opposite, | ||
float32 | confidence, | ||
_Fact * | f_p_f_success = NULL |
||
) |
Make a binding map from the super_goal, then call abduce() with allow_simulation false to inject the LHS as an actual goal.
super_goal | A goal of the model RHS. |
opposite | See abduce(). |
confidence | See abduce(). |
f_success | The simulated (fact (pred (fact (success ...)))) for this abduction (only used for runtime logging). If this is NULL, then don't use it. |
Definition at line 1979 of file mdl_controller.cpp.
bool r_exec::PrimaryMDLController::check_simulated_imdl | ( | Fact * | goal, |
HLPBindingMap * | bm, | ||
Sim * | prediction_sim | ||
) |
This is called from RMonitor::signal or SRMonitor::signal to match the goal with a requirement. In case of a match, the signal "fires" by calling abduce_simulated_lhs to abduce the model's LHS.
goal | The target of the requirement monitor (from backward chaining), which is the goal imdl that is waiting for a predicted imdl in forward chaining giving the conditions to fire the model's LHS. |
bm | A copy of the requirement monitor's saved binding map which has values for variables in the goal. This binding map may be updated during matching. |
prediction_sim | The Sim of the input prediction, or NULL to just call retrieve_imdl_bwd. |
Definition at line 2286 of file mdl_controller.cpp.
bool r_exec::PrimaryMDLController::get_template_timings | ( | HLPBindingMap * | bm, |
Timestamp & | after, | ||
Timestamp & | before | ||
) |
Get the two timestamps from the last template value which is a ti value, assuming that they are the timings from the prerequisite model. This evaluates the backward guards if needed.
bm | The binding map, which is not changed. |
after | Set this to the after timestamp (if this returns true). |
before | Set this to the before timestamp (if this returns true). |
Definition at line 2698 of file mdl_controller.cpp.
|
overridevirtual |
If f_p_f_imdl->get_pred()->is_simulation(), then this is for a simulation.
Implements r_exec::MDLController.
Definition at line 1492 of file mdl_controller.cpp.