Reinforcement learning should be fast, safe and easy to use.
rsrl
provides generic constructs for reinforcement learning (RL)
experiments in an extensible framework with efficient implementations of
existing methods for rapid prototyping.
toml
[dependencies]
rsrl = "0.7"
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...
```rust extern crate rsrl;
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 nactions = domain.actionspace().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);
// Training phase:
let _training_result = {
// Start a serial learning experiment up to 1000 steps per episode.
let e = SerialExperiment::new(&mut agent, domain_builder.clone(), 1000);
// Realise 1000 episodes of the experiment generator.
run(e, 1000, Some(logger.clone()))
};
// Testing phase:
let testing_result = Evaluation::new(&mut agent, domain_builder).next().unwrap();
info!(logger, "solution"; testing_result);
} ```
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).