33.14. Netica Interface

This is an interface to the Netica C API (C API version 3.25) for working with Bayesian belief networks and influence diagrams.

The package NETICA is :CASE-SENSITIVE, e.g., you would write (netica:GetNodeExpectedUtils_bn ...) when you need to call GetNodeExpectedUtils_bn.

When this module is present, *FEATURES* contains the symbol :NETICA.

All public C functions are available as FFI:FOREIGN-FUNCTIONs.

The functions which are specified to return C arrays, namely

GetNodeBeliefs_bn
GetNodeExpectedUtils_bn
GetNodeLikelihood_bn
GetNodeProbs_bn
GetNodeLevels_bn

correspond to FFI:FOREIGN-FUNCTIONs which return FFI:C-POINTERs. We define low level wrappers for them, namely

GetNodeBeliefs
GetNodeExpectedUtils
GetNodeLikelihood
GetNodeProbs
GetNodeLevels

which return the appropriate VECTORs.

Additionally, some higher level functionality is available (see modules/netica/demo.lisp for sample usage):

(netica:start-netica &KEY :license :verbose)
Call NewNeticaEnviron_ns and InitNetica2_bn and print some statistics; initialize netica:*env*.
(netica:check-errors &KEY :env :clear :severity)
Show and, optionally, clear (ClearError_ns), the errors of the given severity (ErrorSeverity_ns) and above. You should call this function after every call to a Netica function. Every wrapper function in this list calls it, so you do not need to call it after a call to a wrapper function.
(netica:error-message error)

Convert netica error to a STRING containing

ErrorCategory_ns
ErrorSeverity_ns
ErrorNumber_ns
ErrorMessage_ns
(netica:close-netica &KEY :env :verbose)
Terminate the Netica session. Sets netica:*env* to NIL.
(netica:make-net &KEY :name :comment :title :env :verbose)
Call NewNet_bn, SetNetTitle_bn and SetNetComment_bn.
(netica:net-info net &KEY :out)

Print some information about the net:

GetNetName_bn
GetNetTitle_bn
GetNetComment_bn
GetNetFileName_bn
GetNetNodes_bn
(netica:make-node &KEY :name :net :kind :levels :states :num-states :title :comment :parents :cpt :x :y :env :verbose)
Call NewNode_bn with the given name and many other parameters.
(netica:node-info node &KEY :header :out)
Print some information about the node, preceded by the header.
(netica:get-beliefs node &KEY :env :verbose)
Call GetNodeBeliefs_bn on the node and pretty-print the results when :VERBOSE is non-NIL.
(netica:enter-finding net node state &KEY :env :verbose)
Call EnterFinding_bn using GetNodeNamed_bn and GetStateNamed_bn.
(netica:save-net net &KEY :file :env :verbose)
Call WriteNet_bn.
(netica:read-net file &KEY :env :verbose)
Call ReadNet_bn.
(netica:with-open-dne-file (var file &REST opts) &BODY body)
Call NewFileStream_ns, execute body, then DeleteStream_ns - just like WITH-OPEN-STREAM.
netica:*verbose*
The log STREAM or NIL; the default value for the :VERBOSE argument (initially set to NIL).
netica:*license*
The license key provided by Norsys; the default value for the :LICENSE argument.
netica:*env*
The Netica environment object; the default value for the :ENV argument.

These notes document CLISP version 2.49+Last modified: 2016-09-05