EthanJamesLew / AutoKoopman

AutoKoopman - automated Koopman operator methods for data-driven dynamical systems analysis and control.
GNU General Public License v3.0
53 stars 10 forks source link

Weighting Trajectories for Evaluation #84

Closed EthanJamesLew closed 5 months ago

EthanJamesLew commented 5 months ago

Summary

CC @Abdu-Hekal

Abdu-Hekal commented 5 months ago

Ideally for every N*M trajectory with N state variables and M time-steps, we could pass a N*M matrix of weights. So for a set of trajectories we have a set of these matrices. This would give use control over weights for each trajectory, state variable and time point

EthanJamesLew commented 5 months ago

@Abdu-Hekal does this code work for you?

EthanJamesLew commented 5 months ago

@Abdu-Hekal ping

Abdu-Hekal commented 5 months ago

@EthanJamesLew code runs well, Thank you!

Abdu-Hekal commented 5 months ago

@EthanJamesLew Is it possible to have the weights defined for each state variable? so that different state variables can have different weights?

EthanJamesLew commented 5 months ago

@Abdu-Hekal I believe that is doable as is (pass in a T x N x M array instead of T x M array), but lemme check

Abdu-Hekal commented 5 months ago

@EthanJamesLew I am getting the following error when I try it: Error: operands could not be broadcast together with shapes (101,2) (101,) I assume it multiplies each row of the variables difference by the full array of weights and not the corresponding row

EthanJamesLew commented 5 months ago

@Abdu-Hekal I see the issue--try now?

Abdu-Hekal commented 5 months ago

@EthanJamesLew Still getting the same error

EthanJamesLew commented 5 months ago

@Abdu-Hekal interesting. The GitHub CI/CD seemed to be okay with it: https://github.com/EthanJamesLew/AutoKoopman/actions/runs/8251423166/job/22568416799 (it ran the jupyter notebook with the updated example)

Abdu-Hekal commented 5 months ago

@EthanJamesLew Interesting, when I run the notebook I first get this error: AttributeError: 'UniformTimeTrajectory' object has no attribute 'abs'. Then I replace w = traj.abs().states with just w=abs(traj.states), and I run into the same error as before: Error: operands could not be broadcast together with shapes (101,2) (101,)

EthanJamesLew commented 5 months ago

@Abdu-Hekal I did just add the abs method to trajectories objects, so maybe the autokoopman version being imported is not at HEAD. In any case, I know GH comments is not the best troubleshooting experience--maybe we could setup a brief pair programming session this week (I can do 8am PT Thu--the time we normally meet on Friday)?

Abdu-Hekal commented 5 months ago

@EthanJamesLew Sounds good! In the meantime I will try to fix the issue on my end.

Abdu-Hekal commented 5 months ago

@EthanJamesLew All good, Notebook Kernel just needed restarting :) I am sometimes getting this warning though but does not seem detrimental RuntimeWarning: overflow encountered in matmul return np.real(self._A @ obs.T).flatten()[: len(x)]

EthanJamesLew commented 5 months ago

Great! Closing for now