Skip to content

Commit

Permalink
Apply pybind11 commit 2b6b98e to avoid crash
Browse files Browse the repository at this point in the history
  • Loading branch information
wcaarls committed Oct 29, 2024
1 parent 2f0b400 commit 96f937f
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 1 deletion.
67 changes: 67 additions & 0 deletions addons/python/cfg/pendulum_sarsa.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
experiment:
type: experiment/online_learning
runs: 1
trials: 1000
steps: 0
rate: 0
test_interval: 10
environment:
type: environment/modeled
model:
type: model/dynamical
control_step: 0.03
integration_steps: 5
dynamics:
type: dynamics/pendulum
task:
type: task/pendulum/swingup
timeout: 2.99
randomization: 0
agent:
type: agent/td
policy:
type: mapping/policy/discrete/value/q
discretizer:
type: discretizer/uniform
min: experiment/environment/task/action_min
max: experiment/environment/task/action_max
steps: [3]
projector:
type: projector/tile_coding
tilings: 16
memory: 8388608
safe: 0
resolution: [0.31415, 3.1415, 3]
wrapping: [6.283, 0, 0]
representation:
type: representation/parameterized/linear
init_min: [0]
init_max: [1]
memory: experiment/agent/policy/projector/memory
outputs: 1
output_min: []
output_max: []
sampler:
type: sampler/epsilon_greedy
rand_max: 0
epsilon: 0.05
predictor:
type: predictor/critic/sarsa
alpha: 0.2
gamma: 0.97
lambda: 0.65
projector: experiment/agent/policy/projector
representation: experiment/agent/policy/representation
trace:
type: trace/enumerated/replacing
test_agent:
type: agent/fixed
policy:
type: mapping/policy/discrete/value/q
discretizer: experiment/agent/policy/discretizer
projector: experiment/agent/policy/projector
representation: experiment/agent/policy/representation
sampler:
type: sampler/greedy
rand_max: 0
save_every: never
14 changes: 14 additions & 0 deletions addons/python/share/experiment_example.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/python3
#
# GRL experiment example

import gym
import grlpy

# Create GRL agent
conf = grlpy.Configurator("../cfg/pendulum_sarsa.yaml")
inst = conf.instantiate()
exp = grlpy.Experiment(inst["experiment"])
exp.run()
exp.reset()
exp.run()
3 changes: 3 additions & 0 deletions addons/python/src/grlpy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ PYBIND11_MODULE(grlpy, m) {
mycfg.set(item.first.attr("__str__")().cast<std::string>(), item.second.attr("__str__")().cast<std::string>());

conf.reconfigure(mycfg);
})
.def("reset", [](Configurable &conf) {
conf.reset();
});

// Experiment
Expand Down
4 changes: 3 additions & 1 deletion externals/pybind11/include/pybind11/detail/class.h
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,9 @@ inline bool deregister_instance_impl(void *ptr, instance *self) {
auto &registered_instances = get_internals().registered_instances;
auto range = registered_instances.equal_range(ptr);
for (auto it = range.first; it != range.second; ++it) {
if (Py_TYPE(self) == Py_TYPE(it->second)) {
// #2252 / 2b6b98e
//if (Py_TYPE(self) == Py_TYPE(it->second)) {
if (self == it->second) {
registered_instances.erase(it);
return true;
}
Expand Down

0 comments on commit 96f937f

Please sign in to comment.