LucasAlegre / morl-baselines

Multi-Objective Reinforcement Learning algorithms implementations.
https://lucasalegre.github.io/morl-baselines
MIT License
271 stars 44 forks source link

Error when running CAPQL-based algorithm on Hopper #66

Closed sahandrez closed 1 year ago

sahandrez commented 1 year ago

Hello, I received this error when evaluating an algorithm based on CAPQL on hopper. Any insights what may have caused this?

File "/home/sahandr/workspace/morl-baselines/morl_baselines/common/evaluation.py", line 168, in log_all_multi_policy_metrics
    hv = hypervolume(hv_ref_point, filtered_front)
  File "/home/sahandr/workspace/morl-baselines/morl_baselines/common/performance_indicators.py", line 24, in hypervolume
    return HV(ref_point=ref_point * -1)(np.array(points) * -1)
  File "/home/sahandr/env/morlenv/lib/python3.9/site-packages/pymoo/core/indicator.py", line 15, in __call__
    return self.do(F, *args, **kwargs)
  File "/home/sahandr/env/morlenv/lib/python3.9/site-packages/pymoo/core/indicator.py", line 30, in do
    return self._do(F, *args, **kwargs)
  File "/home/sahandr/env/morlenv/lib/python3.9/site-packages/pymoo/indicators/hv/__init__.py", line 43, in _do
    val = hv.compute(F)
  File "/home/sahandr/env/morlenv/lib/python3.9/site-packages/pymoo/vendor/hv.py", line 56, in compute
    if weaklyDominates(point, referencePoint):
  File "/home/sahandr/env/morlenv/lib/python3.9/site-packages/pymoo/vendor/hv.py", line 47, in weaklyDominates
    if point[i] > other[i]:
IndexError: index 2 is out of bounds for axis 0 with size 2

Thanks in advance! Sahand

LucasAlegre commented 1 year ago

Hi! I believe this error was caused because the ref_point passed to the train() method has not the same dimension as the reward of the environment. Can you check if this is the case?

sahandrez commented 1 year ago

Hi! Thanks that was the issue! I was passing ref_point=np.array([-100.0, -100.0]) based on this example here, but forgot to set cost_objective=False in the mo_gym.make function.

ffelten commented 1 year ago

Hi @sahandrez,

Nice that it is fixed! Also note that there is an ID registered for hopper 2d in MO-Gymnasium: https://github.com/Farama-Foundation/MO-Gymnasium/blob/main/mo_gymnasium/envs/mujoco/__init__.py#L17

sahandrez commented 1 year ago

Hi @ffelten, That's great to know! Thank you.