bitsim
Model, simulate, estimate and control robots in C++
Loading...
Searching...
No Matches
a2c.cpp File Reference
#include "bitrl/base/bitrl_config.h"
#include "bitrl/base/bitrl_types.h"
#include "bitrl/maths/optimization/optimizer_type.h"
#include "bitrl/maths/optimization/pytorch_optimizer_factory.h"
#include "bitrl/maths/statistics/distributions/torch_categorical.h"
#include "bitrl/rl/algorithms/pg/a2c.h"
#include "bitrl/rl/algorithms/pg/a2c_config.h"
#include "bitrl/rl/trainers/rl_serial_agent_trainer.h"
#include "bitrl/base/bitrl_log.h"
#include "bitrl/envs/gymnasium/classic_control/cart_pole_env.h"
#include "bitrl/network/rest_rl_env_client.h"
#include "bitsim/utils/io/csv_file_writer.h"
#include <torch/torch.h>
#include <filesystem>
#include <fstream>
#include <iostream>
#include <unordered_map>
Include dependency graph for a2c.cpp:

Classes

class  rl_example_11::ActorNetImpl
class  rl_example_11::CriticNetImpl
 The Critic network. More...
class  rl_example_11::TorchCategorical
class  rl_example_11::RESTRLEnvClient
 Utility class to facilitate HTTP requests between the environments REST API and C++ drivers. More...
class  rl_example_11::RLSerialAgentTrainer< EnvType, AgentType >
struct  rl_example_11::RLSerialTrainerConfig
 The RLSerialTrainerConfig struct. Configuration struct for the serial RL agent trainer. More...
struct  rl_example_11::A2CConfig
 The A2CConfig struct. Configuration for A2CSolver class. More...
class  rl_example_11::A2CSolver< EnvType, PolicyType, CriticType >
 A2C solver assuming separate networks for the actor and the critic. Similar to the Reinforce algorithm implementation, the PolicyType should expose an act method with the following signature. More...

Namespaces

namespace  rl_example_11

Typedefs

typedef bitrl::envs::gymnasium::CartPole rl_example_11::env_type
using rl_example_11::real_t
 real_t
typedef torch::Tensor rl_example_11::torch_tensor_t
 torch_tensor_t
using rl_example_11::uint_t
 uint_t

Enumerations

enum class  rl_example_11::DeviceType
 Enumeration of various device types. More...

Functions

 rl_example_11::TORCH_MODULE (ActorNet)
 rl_example_11::TORCH_MODULE (CriticNet)
int main ()

Variables

const std::string rl_example_11::SERVER_URL = "http://0.0.0.0:8001/api"
const std::string rl_example_11::EXPERIMENT_ID = "1"
const std::string rl_example_11::POLICY = "policy.csv"
const uint_t rl_example_11::L1 = 4
 Layer sizes for Actor.
const uint_t rl_example_11::L2 = 128
const uint_t rl_example_11::L3 = 2
const real_t rl_example_11::LEARNING_RATE = 0.01
const auto rl_example_11::N_EPISODES = 1000

Function Documentation

◆ main()

int main ( )