# `RulezenexEngine`
[🔗](https://github.com/abitcipher/rulezenex/blob/v0.1.1/lib/rulezenex_engine.ex#L1)

GoRules ZEN evaluating JSON Decision Model (JDM) graphs in-process.

A graph is the map the JDM Editor produces; a context is any map.

    iex> RulezenexEngine.evaluate(graph, %{"amount" => 120})
    {:ok, %{"tier" => "high"}}

Set `RULEZENEX_NIF_PREBUILT=1` at compile time to load a library built
elsewhere (`priv/native/librulezenex.so` of this application) instead of
compiling the crate.

# `evaluate`

```elixir
@spec evaluate(map(), map(), keyword()) :: {:ok, map()} | {:error, term()}
```

Evaluates `graph` with `context`. Returns `{:ok, result}` with the output
node's value, or `{:error, reason}`. With `trace: true` the result also
holds the evaluation trace under `"trace"`.

# `simulate`

```elixir
@spec simulate(map(), map()) :: {:ok, map()} | {:error, term()}
```

A traced evaluation. Returns `{:ok, %{"result" => _, "trace" => _,
"performance" => _}}` or `{:error, reason}`.

# `validate`

```elixir
@spec validate(map()) :: :ok | {:error, String.t()}
```

Checks that `graph` is a well-formed decision graph.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
