PathmindAI / nativerl

Train reinforcement learning agents using AnyLogic or Python-based simulations
Apache License 2.0
19 stars 4 forks source link

Add the `+=` operator to Nativerl Arrays #508

Closed slinlee closed 2 years ago

slinlee commented 3 years ago

Docs here https://pybind11.readthedocs.io/en/stable/advanced/classes.html#operator-overloading

Most of this was generated with Github Copilot.

slinlee commented 3 years ago

This gets us to the next error:

    return next(self.local_it)
  File "/app/conda/lib/python3.7/site-packages/ray/rllib/evaluation/rollout_worker.py", line 332, in gen_rollouts
    yield self.sample()
  File "/app/conda/lib/python3.7/site-packages/ray/rllib/evaluation/rollout_worker.py", line 706, in sample
    batches = [self.input_reader.next()]
  File "/app/conda/lib/python3.7/site-packages/ray/rllib/evaluation/sampler.py", line 96, in next
    batches = [self.get_data()]
  File "/app/conda/lib/python3.7/site-packages/ray/rllib/evaluation/sampler.py", line 223, in get_data
    item = next(self.rollout_provider)
  File "/app/conda/lib/python3.7/site-packages/ray/rllib/evaluation/sampler.py", line 648, in _env_runner
    base_env.send_actions(actions_to_send)
  File "/app/conda/lib/python3.7/site-packages/ray/rllib/env/base_env.py", line 421, in send_actions
    obs, rewards, dones, infos = env.step(agent_dict)
  File "/app/work/pathmind_training/environments.py", line 281, in step
    self.term_contributions_dict.values()
TypeError: unsupported operand type(s) for +: 'int' and 'nativerl.Array'
maxpumperla commented 3 years ago

@slinlee either create a native Array from the second operand, too, or define the += op for Arrays and Python lists (?)

slinlee commented 2 years ago

Replaced by #511