cmm-21 / a6

0 stars 1 forks source link

Constraints and regularizer #4

Open PanagiotisAnagnostaras opened 3 years ago

PanagiotisAnagnostaras commented 3 years ago

Hello everyone, I have two questions:

1) We implement all the constraints throughout the assignment by penalizing their deviation at the objective right? For example at direct subscription we don't enforce the dynamics as "real" constraints. Is this in order to keep it simpler and not go through constrained optimization? (eg lecture trajectory optimization, slide 20, the dynamics are enforced as equality constraints)

2) At the transcription-app, at my menu there is the choice to change the value of log_c_reg, while at demo I can see that there are lo_c_x0 and log_c_physics. Should it be that way? If yes, I suppose that it is not possible to tune our objectine in a way it behaves well for all the values of the log_c_reg right?

MiguelZamoraM commented 3 years ago

1) Yes, you are correct. The constraint is implemented by penalizing deviations from a certain target.

2) It might be possible to just tune the objective with just log_c_reg. But you can create the log_c_x0 and log_c_physics variables and added to the gui just as it is done with log_c_reg. That way you can weight the part of your objective that penalizes the deviation from x_0 using pow(10., log_c_x0) and also use a different weight (log_c_physics) to penalize deviations from physics. Doing so will give you more freedom to tune your parameters.

Glanfaloth commented 3 years ago

A follow up question: Do I need log_c_v0 as well?

MiguelZamoraM commented 3 years ago

In general it's potentially useful and you will have more degrees of freedom to tune and more power. But don't over do it. As the saying goes: "With great power comes great responsibility".

robindurkowitzer commented 3 years ago

I have a question about the regularizer in General and how the H.toDense().determinant() function works. I Implemented the Regularization and with the suggested regularization of |u|^2, and scaled with the pow(10, log_c_reg) . The resulting regularization factor ('reg') is then smaller when the objective Position is to the right of the initial Position (initial velocity (1,0)) and is bigger to the left of the initial position, which makes a lot of sense as it is proportionate to the thrust we need to apply to move the space ship in the right direction.

Now what is happening is that when 'reg' drops below .67 (estimate through a bit of testing) , the Warning" det H~0" shows up. How can the determinant drop close to 0, if we add this to the diagonal? And is there a reason to the value of .67?

MiguelZamoraM commented 3 years ago

The value of 0.67 is probably just a particular case that arises from the way in which you have set up your objective. Feel free to push your code so that I can take a better look at it. Bare in mind that the hessian is NOT super accurate since it is being computed via finite differences and that the overall conditioning of the hessian also depends on the weights you are using for other terms of the objective.

robindurkowitzer commented 3 years ago

Alright, that makes sense. I pushed the code if you would like to look at it.

Maenzgi commented 3 years ago

Just to be clear: What kind of norm is this? |u|^2 Is it the euclidean norm squared, or absolute values squared? I used .squaredNorm()

MiguelZamoraM commented 3 years ago

.squaredNorm() is euclidean norm squared.

Maenzgi commented 3 years ago

Yes, but I wondered what you meant by "|u|^2". You meant euclidean norm right? In other sources, euclidean is something like ||u||_2^2

MiguelZamoraM commented 3 years ago

Although I never typed |u|^2, I believe the comment in https://github.com/cmm-21/a6/issues/4#issuecomment-845495490 refers to the euclidean norm, which as you say it's usually denoted by ||u||_2^2

MiguelZamoraM commented 3 years ago

Oh I guess you might be referring to the notation in the writeup. A better notation would be ||u||_2^2 indeed.