NNWarehouse: Constructor for the 'NNWarehosue' class.

View source: R/Warehouse.R

NNWarehouseR Documentation

Constructor for the NNWarehosue class.

Description

This is the constructor for the NNWarehouse class. This produces NeticaNode objects, which are instances of the Pnode abstract class.

Usage

NNWarehouse(manifest = data.frame(), session = getDefaultSession(),
            key = c("Model","NodeName"), prefix = "V")

Arguments

manifest

A data frame containing instructions for building the nodes. See BuildNodeManifest.

session

A link to a NeticaSession object for managing the nets.

key

A character vector giving the name of the column in the manifest which contains the network name and the node name.

prefix

A character scaler used in front of numeric names to make legal Netica names. (See as.IDname).

Details

Each network defines its own namespace for nodes, so the key to the node manifest is a pair (Model,NodeName) where Model is the name of the net and NodeName is the name of the node.

Value

An object of class NNWarehouse.

Author(s)

Russell Almond

See Also

Warehouse for the general warehouse protocol.

Examples


sess <- NeticaSession()
startSession(sess)

### This tests the manifest and factory protocols.

nodeman1 <- read.csv(system.file("auxdata", "Mini-PP-Nodes.csv", 
                     package="Peanut"),
                     row.names=1,stringsAsFactors=FALSE)

netman1 <- read.csv(system.file("auxdata", "Mini-PP-Nets.csv", 
                     package="Peanut"),
                    row.names=1, stringsAsFactors=FALSE)


### Test Net building
Nethouse <- BNWarehouse(manifest=netman1,session=sess,key="Name",
                        address=system.file("testnets",package="PNetica"))

CM <- WarehouseSupply(Nethouse,"miniPP_CM")
stopifnot(is.null(WarehouseFetch(Nethouse,"PPcompEM")))
EM1 <- WarehouseMake(Nethouse,"PPcompEM")

EMs <- lapply(c("PPcompEM","PPconjEM", "PPtwostepEM", "PPdurAttEM"),
              function(nm) WarehouseSupply(Nethouse,nm))

### Test Node Building with already loaded nets

Nodehouse <- NNWarehouse(manifest=nodeman1,
                         key=c("Model","NodeName"),
                         session=sess)

phyd <- WarehouseData(Nodehouse,c("miniPP_CM","Physics"))

p3 <- MakePnode.NeticaNode(CM,"Physics",phyd)

phys <- WarehouseSupply(Nodehouse,c("miniPP_CM","Physics"))
stopifnot(p3==phys)

for (n in 1:nrow(nodeman1)) {
  name <- as.character(nodeman1[n,c("Model","NodeName")])
  if (is.null(WarehouseFetch(Nodehouse,name))) {
    cat("Building Node ",paste(name,collapse="::"),"\n")
    WarehouseSupply(Nodehouse,name)
  }
}

WarehouseFree(Nethouse,PnetName(EM1))




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