RSRL (api)

Reinforcement learning should be fast, safe and easy to use.
Overview
rsrl provides generic constructs for reinforcement learning (RL)
experiments in an extensible framework with efficient implementations of
existing methods for rapid prototyping.
Installation
[dependencies]
rsrl = "0.7"
Usage
The code below shows how one could use rsrl to evaluate a QLearning agent
using a linear function approximator with Fourier basis projection to solve the
canonical mountain car problem.
See examples/ for
more...
extern crate rsrl;
#[macro_use]
extern crate slog;
use rsrl::{
run, make_shared, Evaluation, SerialExperiment,
control::td::QLearning,
domains::{Domain, MountainCar},
fa::linear::{basis::{Fourier, Projector}, optim::SGD, LFA},
logging,
policies::{EpsilonGreedy, Greedy, Random},
spaces::Space,
};
fn main() {
let domain = MountainCar::default();
let mut agent = {
let n_actions = domain.action_space().card().into();
let basis = Fourier::from_space(5, domain.state_space()).with_constant();
let q_func = make_shared(LFA::vector(basis, SGD(1.0), n_actions));
let policy = EpsilonGreedy::new(
Greedy::new(q_func.clone()),
Random::new(n_actions),
0.2
);
QLearning::new(q_func, policy, 0.01, 1.0)
};
let logger = logging::root(logging::stdout());
let domain_builder = Box::new(MountainCar::default);
let _training_result = {
let e = SerialExperiment::new(&mut agent, domain_builder.clone(), 1000);
run(e, 1000, Some(logger.clone()))
};
let testing_result = Evaluation::new(&mut agent, domain_builder).next().unwrap();
info!(logger, "solution"; testing_result);
}
Contributing
Pull requests are welcome. For major changes, please open an issue first to
discuss what you would like to change.
Please make sure to update tests as appropriate and adhere to the angularjs
commit message conventions (see
here).
License
MIT