AERA
Classes | Public Member Functions | Static Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
r_exec::MDLController Class Referenceabstract

#include <mdl_controller.h>

Inheritance diagram for r_exec::MDLController:
r_exec::HLPController r_exec::OController r_exec::Controller core::_Object r_exec::PMDLController r_exec::SecondaryMDLController r_exec::PrimaryMDLController r_exec::TopLevelMDLController

Classes

class  RequirementCache
 
class  RequirementEntry
 

Public Member Functions

void add_monitor (PMonitor *m)
 
void remove_monitor (PMonitor *m)
 
_Factget_lhs () const
 
_Factget_rhs () const
 
Factget_f_ihlp (HLPBindingMap *bindings, bool wr_enabled) const override
 
virtual void store_requirement (_Fact *f_p_f_imdl, MkRdx *mk_rdx, MDLController *controller, bool chaining_was_allowed)=0
 
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)
 
virtual 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)=0
 
virtual void register_pred_outcome (Fact *f_pred, r_code::Code *mk_rdx, bool success, _Fact *evidence, float32 confidence, bool rate_failures)=0
 
virtual void register_req_outcome (Fact *f_pred, bool success, bool rate_failures)=0
 
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)
 
- Public Member Functions inherited from r_exec::HLPController
void invalidate () override
 
r_code::Codeget_core_object () const override
 
r_code::Codeget_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::Codeget_out_group (uint16 i) const
 
Groupget_host () const
 
bool has_tpl_args () const
 
bool inject_prediction (Fact *prediction, float32 confidence) const
 
- Public Member Functions inherited from r_exec::Controller
std::chrono::microseconds get_tsc ()
 
bool is_invalidated ()
 
void activate (bool a)
 
bool is_activated () const
 
bool is_alive () const
 
r_code::Codeget_object () const
 
r_exec::Viewget_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 *)
 
- Public Member Functions inherited from core::_Object
void incRef ()
 
virtual void decRef ()
 

Static Public Member Functions

static MDLControllerNew (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)
 

Protected Types

enum  RequirementType { NOT_A_REQUIREMENT = 0, WEAK_REQUIREMENT = 1, STRONG_REQUIREMENT = 2 }
 

Protected Member Functions

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)
 
- Protected Member Functions inherited from r_exec::HLPController
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 ()
 
virtual void kill_views ()
 
virtual void check_last_match_time (bool match)=0
 
 HLPController (r_code::_View *view)
 
- Protected Member Functions inherited from r_exec::OController
 OController (r_code::_View *view)
 
- Protected Member Functions inherited from r_exec::Controller
virtual void take_input (r_exec::View *)
 
template<class C >
void __take_input (r_exec::View *input)
 
 Controller (r_code::_View *view)
 

Protected Attributes

RequirementCache requirements_
 
RequirementCache simulated_requirements_
 
CriticalSection p_monitorsCS_
 
r_code::list< P< PMonitor > > p_monitors_
 
P< r_code::Codelhs_
 
P< r_code::Coderhs_
 
RequirementType requirement_type_
 
bool is_reuse_
 
bool is_cmd_
 
CriticalSection active_requirementsCS_
 
std::unordered_map< P< _Fact >, RequirementsPair, r_code::PHash< _Fact > > active_requirements_
 
- Protected Attributes inherited from r_exec::HLPController
CriticalSectionList< EvidenceEntryevidences_
 
CriticalSectionList< PredictedEvidenceEntrypredicted_evidences_
 
P< HLPBindingMapbindings_
 
bool has_tpl_args_
 
uint32 ref_count_
 
std::vector< P< HLPController > > controllers_
 
Timestamp last_match_time_
 
- Protected Attributes inherited from r_exec::OController
r_code::list< P< Overlay > > overlays_
 
- Protected Attributes inherited from r_exec::Controller
volatile uint32 invalidated_
 
volatile uint32 activated_
 
std::chrono::microseconds time_scope_
 
r_code::_Viewview_
 
CriticalSection reductionCS_
 
- Protected Attributes inherited from core::_Object
std::atomic_int32_t refCount_
 

Static Protected Attributes

static const uint32 LHSController = 0
 
static const uint32 RHSController = 1
 

Additional Inherited Members

- Static Protected Member Functions inherited from r_exec::Controller
static void push_reduction_job (_ReductionJob *j)
 

Detailed Description

Requirements don't monitor their predictions: they don't inject any; instead, they store a f->imdl in the controlled model controllers (both primary and secondary), thus, no success injected for the productions of requirements. Models controlled by requirements maintain for each prediction they make, a list of all the controllers of the requirements having allowed/inhibited said prediction. P-monitors (associated to non-requirement models) propagate the outcome to the controllers associated with the prediction they monitor.

Predictions and goals are injected in the primary group only. Simulations are injected in the primary group only; no mk.rdx.

Each time a prediction is made by a non-req model, a f->imdl is injected in both primary and secondary groups. If the input was a prediction, f->pred->f->imdl is injected instead. f->imdl can also be tagged as simulations.

Successes and failures are injected only in output groups.

If forward chaining is inhibited (by strong reqs with better cfd than weak reqs), predictions are still produced, but not injected (no mk.rdx): this is to allow the rating of the requirements.

Definition at line 187 of file mdl_controller.h.

Member Function Documentation

◆ get_imdl_template_timings()

bool r_exec::MDLController::get_imdl_template_timings ( r_code::Code imdl,
Timestamp &  after,
Timestamp &  before,
uint16 *  after_ts_index = NULL,
uint16 *  before_ts_index = NULL 
)
static

Get the two timestamps from the last template value which is a ti value, assuming that they are the timings from the prerequisite model.

Parameters
imdlThe imdl object.
afterSet this to the after timestamp (if this returns true).
beforeSet this to the before timestamp (if this returns true).
(optional)after_ts_index If not NULL, set this to the index in imdl Code array of the after time stamp structure.
(optional)before_ts_index If not NULL, set this to the index in imdl Code array of the before time stamp structure.
Returns
True for success, otherwise false if there are not enough template parameters, or if the value is some type other than a timestamp (such as an unbound variable).

Definition at line 1102 of file mdl_controller.cpp.

◆ get_success_rate()

float32 r_exec::MDLController::get_success_rate ( ) const
protected

Get the success rate from the mdl object.

Returns
The success rate.

Definition at line 365 of file mdl_controller.cpp.

◆ store_requirement()

virtual void r_exec::MDLController::store_requirement ( _Fact f_p_f_imdl,
MkRdx mk_rdx,
MDLController controller,
bool  chaining_was_allowed 
)
pure virtual

If f_p_f_imdl->get_pred()->is_simulation(), then this is for a simulation.

Implemented in r_exec::SecondaryMDLController, r_exec::PrimaryMDLController, and r_exec::TopLevelMDLController.


The documentation for this class was generated from the following files: