https://mooseframework.inl.gov
Loading...
Searching...
No Matches
LibtorchRLValueEstimator.h
Go to the documentation of this file.
1//* This file is part of the MOOSE framework
2//* https://mooseframework.inl.gov
3//*
4//* All rights reserved, see COPYRIGHT for full restrictions
5//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6//*
7//* Licensed under LGPL 2.1, please see LICENSE for details
8//* https://www.gnu.org/licenses/lgpl-2.1.html
9
10#ifdef MOOSE_LIBTORCH_ENABLED
11
12#pragma once
13
16
17#include <vector>
18
25{
26public:
30 struct Targets
31 {
33 std::vector<Real> advantages;
35 std::vector<Real> value_targets;
36 };
37
43 LibtorchRLValueEstimator(Real discount_factor, Real lambda_factor);
44
51 Moose::LibtorchArtificialNeuralNet & value_network) const;
52
59 Moose::LibtorchArtificialNeuralNet & value_network) const;
60
61private:
67 std::vector<Real> evaluate(const std::vector<std::vector<Real>> & observations,
68 Moose::LibtorchArtificialNeuralNet & value_network) const;
69
71 const Real _discount_factor;
73 const Real _lambda_factor;
74};
75
76#endif
On-policy trajectory storage for fixed-horizon RL training.
Computes generalized-advantage estimates and value targets for an on-policy trajectory buffer,...
Targets estimate(const LibtorchRLTrajectoryBuffer::Trajectory &trajectory, Moose::LibtorchArtificialNeuralNet &value_network) const
Compute value targets and advantages for one trajectory.
const Real _discount_factor
Reward discount factor used in the temporal-difference recursion.
std::vector< Real > evaluate(const std::vector< std::vector< Real > > &observations, Moose::LibtorchArtificialNeuralNet &value_network) const
Evaluate the critic on a batch of observations.
void computeValueTargets(LibtorchRLTrajectoryBuffer &buffer, Moose::LibtorchArtificialNeuralNet &value_network) const
Fill every trajectory in the buffer with value targets and advantages.
const Real _lambda_factor
GAE lambda factor used in the reverse-time advantage recursion.
Vector data for one on-policy trajectory.
Generalized-advantage estimates and critic targets for one trajectory.
std::vector< Real > value_targets
Critic regression targets.
std::vector< Real > advantages
Generalized-advantage estimates.