pyomeca / bioptim

An optimization framework that links CasADi, Ipopt, ACADOS and biorbd for Optimal Control Problem
MIT License
95 stars 47 forks source link

Plot errors in multi-phase #781

Open EveCharbie opened 1 year ago

EveCharbie commented 1 year ago

I get the following error message:

Traceback (most recent call last):
  File "/home/charbie/miniconda3/envs/dev_bioptim/lib/python3.11/site-packages/matplotlib/backend_bases.py", line 1226, in _on_timer
    ret = func(*args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^
  File "/home/charbie/Documents/Programmation/BiorbdOptim/bioptim/gui/plot.py", line 1363, in callback
    self.plot.update_data(v)
  File "/home/charbie/Documents/Programmation/BiorbdOptim/bioptim/gui/plot.py", line 946, in update_data
    y[i_node] = val[i_var]
                ~~~^^^^^^^
IndexError: index 4 is out of bounds for axis 0 with size 4

when running the code TechOpt831 from https://github.com/EveCharbie/VisionOCP with solver = Solver.IPOPT(show_online_optim=True, show_options=dict(show_bounds=True))

When I have time, I will look more deeply in what seems to be the issue.

EveCharbie commented 1 year ago

This problem seems to happen when there is a target in minimize_state/minimize_control and index is specified. I think define_target_mapping (currently l.891 from penalty option) could be upgraded to consider this mapping.

tiagocoelhoma commented 11 months ago

Hello! I also have the same problem. It should be great to have it working! :) And yes, I am using minimize_state/minimize_control and index is specified.

EveCharbie commented 11 months ago

Thank you for you confirmation of what seems to be the issue. There is a major refarctor/improvement going on right now. It should fix a lot of graph issues, but I am not sure it will fix this one. When it gets merged, I will have a look at it.

fbailly commented 10 months ago

@EveCharbie @pariterre Do you know if the major refactor fixed this issue ? Thanks !

pariterre commented 10 months ago

I am not sure since plot.py is a bit capricious, but I fix some problems with this specific line during the refactor, definitely worth retrying

EveCharbie commented 10 months ago
  1. On my side it does not even show the plots anymore with show_online_optim=True :(

  2. But the original error is still there. By adding a ObjectiveFcn.Mayer.MINIMIZE_STATE, key="q", target=1, index=0 I get a similar error as before

    Screenshot 2024-02-06 at 10 36 26 AM
EveCharbie commented 10 months ago

I do not have time to fix this right now. @pariterre or @tiagocoelhoma would you have time?

EveCharbie commented 9 months ago

@tiagocoelhoma I think I fixed it in PR #851 :) Could you test it ?