BNEngineMongo-class | R Documentation |
"BNEngineMongo"
A Bayes net engine hooked to a Mongo database.
Class "BNEngine"
, directly.
All reference classes extend and inherit methods from
"envRefClass"
.
At the start of each iteration of the mainLoop
, it
checks eng$shouldHalt()
method. If this returns TRUE
,
then execution is immediately halted. When the queue is empty, it
checks the eng$stopWhenFinished()
method. If this returns
true, then the main loop also terminates.
The BNEngineMongo
this checks the “AuthorizedApps”
collection in the database to see if the current app
is
active and the value of the field EAsignal
. The
eng$activate()
method sets this field to “Running”. If
the field is set to “Halt”, then eng$shouldHalt()
will
return TRUE
and the mainLoop
will stop after
processing the current evidence set. If the field is set to
“Halt” (actually, anything other than “Running”), then
eng$stopWhenFinished()
will return TRUE
and the
mainLoop
will stop when the queue is empty.
The methods eng$activate()
and eng$deactivate()
set and
clear the EAactive
flag in the “AuthorizedApps”
database.
app
:Object of class character
giving an
globally unique identifier for the application
srs
:Object of class
StudentRecordSet
of NULL
giving the
student record set for the application.
profModel
:Object of class character
giving the
name of the proficiency model (for the default student record) in
the warehouse manifest.
listenerSet
:Object of class ListenerSet
giving
a set of listeners who will listen for new statistics.
statistics
:Object of class list
containing
Statistic
objects to be run on every update
cycle.
histNodes
:Object of class character
giving the
names of the nodes in the proficiency model whose history will be
recorded.
warehouseObj
:Object of class
PnetWarehouse
which stores the Bayes nets, both evidence models and student
models are stored here.
waittime
:Object of class numeric
giving the
time in seconds the main event loop should wait before checking
again for messages.
processN
:Object of class numeric
giving the
number of times that the main loop should run before stopping. If
Inf
, then the main loop will run without stopping.
dburi
:Object of class character
giving the URI
for the mongo database.
dbname
:Object of class character
giving the
name of the database to be used.
manifestDB
:Object of class
MongoDB
giving the collection used to store
the manifest. This object may not be initialized so it should be
accessed through the class-based function manifestdb()
.
evidenceDB
:Object of class
MongoDB
accessing the evidence set
collection. This object may not be initialized so it should be
accessed through the class-based function evidenceSets()
.
statDB
:Object of class MongoDB
giving the
statistics to use. This object may not be initialized so it should be
accessed through the class-based function statdb()
.
histNodesDB
:Object of class MongoDB
giving the
history nodes. This object may not be initialized so it should be
accessed through the class-based function histNodesdb()
.
admindbname
:Object of class character
giving name
admin (mongo) database, used for various listeners and the
is.active()
method.
adminDB
:Object of class MongoDB
giving the link
to the admin database. This object may not be initialized so it should be
accessed through the class-based function admindb()
.
activate()
:Sets the flag in the admin database to indicate that the process is running.
deactivate()
:Clears the flag in the admin database to indicate that the process is no longer running.
shouldHalt()
:This function checks the admin database to see whether or not the flag is set to cause the process to halt after processing the current record..
stopWhenFinished()
:This function checks the admin database to see whether or not the flag is set to cause the process to stop when the event queue is empty.
statdb()
:Returns the database contianing the statistic objects.
studentRecords()
: Returns the
StudentRecordSet
associated with this engine.
fetchStats()
:Fetches the statistics marked in the database configuration.
initialize(app, warehouse, listeners, username,
password, host, port, dbname, P4dbname, profModel, waittime,
statistics, histNodes, processN, ...)
: initializes the class.
Note that some initialization is done in the various XXXdb()
functions, so these should be called instead of directly accessing
the fields.
manifestdb()
: Returns the
MongoDB-class
handle to the manifest information
collection.
admindb()
: Returns the MongoDB-class
handle to the “AuthorizedApps” collection.
histNodesdb()
: Returns the
MongoDB-class
handle to the hist nodes collection.
saveManifest(manifest)
: Saves the current
PnetWarehouse
manifest to the
manifestdb()
collection
fetchManifest()
: Retrieves the saved manifest from
the manifestdb()
collection.
fetchNextEvidence()
: Retrieves the next
EvidenceSet
from the evidenceSets()
collection. Returns NULL
if there are not unprocessed
evidence sets.
saveStats(statmat)
: Saves the update statistic
definitions to the statdb()
collection.
setHistNodes(nodenames)
: Saves the history nodes to
the histNodesdb()
collection.
isActivated()
:Checks to see if the active flag is set.
setError(mess, e)
:Added an error message to an evidence set.
evidenceSets()
: Returns a
MongoDB-class
handle to the collection/queue of
evidence sets.
getHistNodes()
: Fetches the history nodes from the
histNodesdb()
collection.
show()
:Provides a printed representation of the engine.
The following methods are inherited (from the corresponding class): evidenceSets ("BNEngine"), getHistNodes ("BNEngine"), stats ("BNEngine"), setProcessed ("BNEngine"), setManifest ("BNEngine"), activate ("BNEngine"), isActivated ("BNEngine"), saveManifest ("BNEngine"), studentRecords ("BNEngine"), saveStats ("BNEngine"), fetchNextEvidence ("BNEngine"), warehouse ("BNEngine"), show ("BNEngine"), setHistNodes ("BNEngine"), setError ("BNEngine"), fetchManifest ("BNEngine"), fetchStats ("BNEngine")
The database connections are not created right away, so it
is important to use the class-based functions, manifestdb()
,
statdb()
, evidenceSets()
, histNodesdb()
,
studentRecords()
, and admindb()
rather than accessing
the fields directly.
Russell Almond
Almond, Mislevy, Steinberg, Yan and Williamson (2015). Bayesian Networks in Educational Assessment. Springer. Especially Chapter 13.
Classes:
BNEngine
, BNEngineNDB
Constituent parts:
StudentRecordSet
, PnetWarehouse
Setup Functions:
loadManifest
,
setupDefaultSR
,
configStats
,
baselineHist
,
Main Loop Functions:
mainLoop
,
accumulateEvidence
,
handleEvidence
,
getRecordForUser
,
logEvidence
,
updateSM
,
updateStats
,
updateHist
,
announceStats
,
showClass("BNEngineMongo")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.