NeticaBN-class {RNetica} | R Documentation |
"NeticaBN"
This is an R side container for a Netica netork. Note that it has a container for the nodes which have been advertised from the network.
A NeticaBN
is an R wrapper for the internal pointer to the
Netica nework. A network is said to be ‘active’ if it
references a network object in a current Netica session. A network
become inactive when it is deleted (with a call to
DeleteNetwork
) or when the R session is saved an
restored. In the latter case, if the network was saved with a call to
WriteNetworks
, then calling ReadNetworks
on the inactive network will reload it from the save file.
Generally, NeticaBN
objects are created with calls to either
CreateNetwork
or ReadNetworks
. Both
require a reference to an active NeticaSession
object. NeticaBN
objects are registered with the
NeticaSession
object, which contains a collection
of all of the networks known about by the session.
The nodes
field of the NeticaBN
object
(net$nodes
) contains a cache of all code
NeticaNode
objects that are contained by the
network and known about by R. Nodes are registered by their Netica
name so the expression net$nodes$nodename
or
net$nodes[[nodename]]
references a node with the name
nodename
in net
.
Note that R node objects are created when a node is created in R, but
not when a network is read in using ReadNetworks
. This
is useful for cases where the network is large and only a few nodes
will be reference in the R code. The function
NetworkFindNode()
will find a node by name and create
the R object corresponding to the node if needed. The function
NetworkAllNodes()
will create R objects for all nodes in
the net.
All reference classes extend and inherit methods from
"envRefClass"
. Note that because this is a
reference class unlike traditional S3 and S4 classes it can be
destructively modified. Also fields (slots) are accessed using the
‘$’ operator.
signature(e1 = "NeticaBN", e2 = "NeticaBN")
:
Tests for equality (mainly of pointers.
signature(x = "NeticaBN")
: Returns true if
the NeticaBN
objectcurrently references an active Netica
object, and returns false if it references a deleted network or a
network created in a previous sesion which has not be
re-activated.
signature(x = "NeticaBN")
: Creates a printed
representation.
signature(x = "NeticaBN")
: Creates a
character representation.
signature(el = "NeticaBN", set = "list")
:
Checks to see if el is in list of nets.
Note these should be regarded as read-only from user code.
Name
:Object of class character
giving the
Netica name of the network. Must follow the IDname
rules. This should not be set by user code, use
NetworkName
instead.
PathnameName
:Object of class character
giving
the path from which the network was last read or to which it was
last saved.
Netica_bn
:Object of class externalptr
linking
to the Netica object corresponding to this network.
Session
:Object of class NeticaSession
: a back
pointer to the NeticaSession
object in which
the network was created.
nodes
:Object of class environment
which
contains a cache of NeticaNode
objects
belonging to this network.
listNodes()
: Lists all of the cached nodes.
(Contrast this to NetworkAllNodes(net)
which lists
all nodes in the network.
searchNodes(pattern)
: Lists all cached nodes matching
the regular expression given in pattern. (See
objects
.)
show()
:Gives a detailed description of the object.
isActive()
:Returns true if the object currently points to a Netica network, and false if it does not.
findNode(nodename)
: Searches for a cached node with
name nodename
, returns it if found or NULL
if not.
clearErrors(severity)
: Calls clearErrors
on
the Session
object.
reportErrors(maxreport, clear)
: Calls
reportErrors
on the Session
object.
initialize(Name, Session, ...)
:Initialization function. Should not be called by user code.
deactivate()
:Destroys the pointer to the Netica object. Should not be called by user code.
deactivateNodes()
:Recursively deactives all nodes contained by this network. Should not be called by user code.
The NeticaBN
class was changed into a formal R6 reference class
as of version 0.5 of RNetica. Prior to that, it was an S3 class
created by adding attributes to a string. That proved to be less than
robust, as several R functions (notably c()
) would
strip the attributes.
Another change is the method for finding the network object from the
Netica pointer inside of the C code. Now the R objects are cached
inside of a NeticaSession
object by their netica
name. The R object is found by searching the cache inside of the
session object.
Russell Almond
http://norsys.com/onLineAPIurl/index.html: GetNetUserData_bn(), SetNetUserData_bn() (these are used to maintain the back pointers to the R object).
NeticaBN
objects are contained by
NeticaSession
objects and contain
NeticaNode
objects.
CreateNetwork()
,DeleteNetwork()
,
GetNamedNetworks()
,NetworkName()
,
is.active()
, NetworkAllNodes()
,
WriteNetworks()
, GetNetworkFileName()
,
sess <- NeticaSession() startSession(sess) net1 <- CreateNetwork("aNet",sess) stopifnot(is.NeticaBN(net1)) stopifnot(is.active(net1)) stopifnot(net1$Name=="aNet") net2 <- GetNamedNetworks("aNet",sess) stopifnot(net2$Name=="aNet") stopifnot(net1==net2) NetworkName(net1) <- "Unused" stopifnot(net1==net2) netd <- DeleteNetwork(net1) stopifnot(!is.active(net1)) stopifnot(!is.active(net2)) stopifnot(netd$Name=="Unused") stopifnot(netd == net1) stopSession(sess)