PnetWarehouse-class: Class '"PnetWarehouse"'

PnetWarehouse-classR Documentation

Class "PnetWarehouse"

Description

A Warehouse object which holds and builds Pnet objects. In particular, its WarehouseManifest contains a network manifest (see BuildNetManifest) which contains information about how to either load the networks from the file system, or build them on demand.

Details

The PnetWarehouse either supplies prebuilt nets or builds them from the instructions found in the manifest. In particular, the function WarehouseSupply will attempt to:

  1. Find an existing network with name.

  2. Try to read the network from the location given in the Pathname column of the manifest.

  3. Build a blank network, using the metadata in the manifest.

The manifest is an object of type data.frame where the columns have the values show below. The key is the “Name” column which should be unique for each row. The name argument to WarehouseData should be a character scalar corresponding to name, and it will return a data.frame with a single row.

Name

A character value giving the name of the network. This should be unique for each row and normally must conform to variable naming conventions. Corresponds to the function PnetName.

Title

An optional character value giving a longer human readable name for the netowrk. Corresponds to the function PnetTitle.

Hub

If this model is incomplete without being joined to another network, then the name of the hub network. Otherwise an empty character vector. Corresponds to the function PnetHub.

Pathname

The location of the file from which the network should be read or to which it should be written. Corresponds to the function PnetPathname.

Description

An optional character value documenting the purpose of the network. Corresponds to the function PnetDescription.

The function BuildNetManifest will build a manifest for an existing collection of networks.

Objects from the Class

A virtual Class: No objects may be created from it.

Classes can register as belonging to this abstract class. The trick for doing this is: setIs("NethouseClass","PnetWarehouse")

Currently BNWarehouse is an example of an object of this class.

Methods

WarehouseSupply

signature(warehouse = "PnetWarehouse", name = "character"). This finds a network with the appropriate name. If one does not exist, it is created by reading it from the pathname specified in the manifest. If no file exists at the pathname, a new blank network with the properities specified in the manifest is created.

WarehouseFetch

signature(warehouse = "PnetWarehouse", name = "character"). This fetches the network with the given name, or returns NULL if it has not been built.

WarehouseMake

signature(warehouse = "PnetWarehouse", name = "character"). This loads the network from a file or builds the network using the data in the Manifest.

WarehouseFree

signature(warehouse = "PnetWarehouse", name = "character"). This removes the network from the warehouse inventory.

ClearWarehouse

signature(warehouse = "PnetWarehouse"). This removes all networks from the warehouse inventory.

is.PnetWarehouse

signature(obj = "PnetWarehouse"). This returns TRUE.

WarehouseManifest

signature(warehouse = "PnetWarehouse"). This returns the data frame with instructions on how to build networks. (see Details)

WarehouseManifest<-

signature(warehouse = "PnetWarehouse", value="data.frame"). This sets the data frame with instructions on how to build networks.(see Details)

WarehouseData

signature(warehouse = "PnetWarehouse", name="character"). This returns the portion of the data frame with instructions on how to build a particular network. (see Details)

WarehouseUnpack

signature(warehouse = "PnetWarehouse", serial="list"). This restores a serialized network, in particular, it is used for saving network state across sessions. See PnetSerialize for an example.

Note

In the PNetica implementation, the BNWarehouse implementatation contains an embedded NeticaSession object. When WarehouseSupply is called, it attempts to satisfy the demand by trying in order:

  1. Search for the named network in the active networks in the session.

  2. If not found in the session, it will attempt to load the network from the Pathname field in the manifest.

  3. If the network is not found and there is not file at the target pathename, a new blank network is built and the appropriate fields are set from the metadata.

Author(s)

Russell Almond

See Also

Warehouse, WarehouseManifest, BuildNetManifest

Implementation in the PNetica package: BNWarehouse, MakePnet.NeticaBN

Examples

## Not run: 
library(PNetica)  ## Example requires PNetica

sess <- NeticaSession()
startSession(sess)

## BNWarehouse is the PNetica Net Warehouse.
## This provides an example network manifest.
netman1 <- read.csv(system.file("auxdata", "Mini-PP-Nets.csv",
                                package="PNetica"),
                    row.names=1, stringsAsFactors=FALSE)
Nethouse <- BNWarehouse(manifest=netman1,session=sess,key="Name")

CM <- WarehouseSupply(Nethouse, "miniPP_CM")
EM <- WarehouseSupply(Nethouse, "PPcompEM")


DeleteNetwork(list(CM,EM))
stopSession(sess)

## End(Not run)

ralmond/Peanut documentation built on Sept. 19, 2023, 8:27 a.m.