Skip to contents

The built-in engines ("bnlearn", "causalDisco", "pcalg", "tetrad") are backed by R6 search classes (BnlearnSearch, CausalDiscoSearch, PcalgSearch, TetradSearch) that make_runner() knows how to build and configure. register_engine() lets you plug in a backend for a package that isn't one of the built-ins, so that it can be selected by name from make_runner() the same way as a built-in engine.

Usage

register_engine(name, make_runner_fn, pkgs = character(0))

Arguments

name

Engine name (string). Cannot be one of the built-in engine names ("bnlearn", "causalDisco", "pcalg", "tetrad").

make_runner_fn

A function implementing the engine. See Details.

pkgs

Character vector of package names required by the engine. Checked, with an informative error if missing, before make_runner_fn is called.

Details

make_runner_fn must accept alg and ..., and return a runner: a list with two elements,

  • set_knowledge, a function that takes a single Knowledge object and configures background knowledge on the underlying search, and

  • run, a function that takes a single data frame, runs the search, and returns the algorithm's result using as_disco().

make_runner() calls make_runner_fn with alg, test, alpha, score, and any additional arguments it was itself called with. Pick up whichever of these your engine needs by naming them explicitly, and let ... absorb the rest.