Module Fehu_algorithmsSource

Reinforcement learning algorithms for Fehu.

This library provides production-ready implementations of standard RL algorithms. Each algorithm follows a consistent interface: create an agent with a policy network and configuration, train with learn, and use the trained policy with predict.

Available Algorithms

Policy Gradient Methods

Value-Based Methods

Usage Pattern

All algorithms follow this pattern:

  open Fehu

  (* 1. Create policy network *)
  let policy_net = Kaun.Layer.sequential [...] in

  (* 2. Initialize algorithm *)
  let agent = Algorithm.create
    ~policy_network:policy_net
    ~n_actions:n
    ~rng:(Rune.Rng.key 42)
    Algorithm.default_config
  in

  (* 3. Train *)
  let agent = Algorithm.learn agent ~env ~total_timesteps:100_000 () in

  (* 4. Use trained policy *)
  let action = Algorithm.predict agent obs ~training:false |> fst

Choosing an Algorithm

Future algorithms:

Sourcemodule Reinforce : sig ... end

Reinforce algorithm implementation.

Sourcemodule Dqn : sig ... end

Dqn algorithm implementation.