Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wingopt add actuator constraints #56

Merged
merged 58 commits into from
Jul 15, 2019
Merged

Wingopt add actuator constraints #56

merged 58 commits into from
Jul 15, 2019

Conversation

avikde
Copy link
Owner

@avikde avikde commented Jul 5, 2019

  • add them
  • do a small timestep simulation with the optimized knot points - would help the animation as well...
  • as another optimization method, could use gradient descent in the objective+penalty (as before), followed by a QP solve for constraint satisfaction?

TODO:

  • anim
  • fix newton method - Hessian singular??
  • inequality constraints
  • analytical gradients? confirm that evaluating the autograd is the slowest
  • periodicity constraint (not needed?)

For a lot of this, the Coros work in Geilinger seems quite suited.

Result

Alternate

  • gauss newton for traj with dyn penalty 1e-3
  • newton method for params with dyn penalty 1e3

image

[3.6155 0.0156 0.127  5.25   0.0027 0.0149] cost -132.9 -> -359.8
[0.     0.0293 0.1349 0.3796 0.0001 0.0575] cost 12390945.0 -> 9651572.7
[3.5883 0.0142 0.1241 5.2144 0.0007 0.0147] cost -336.1 -> -706.0
[0.     0.0294 0.1475 0.3781 0.0001 0.2003] cost 39636777.4 -> 13562140.0
[3.499  0.0143 0.1457 5.1834 0.0006 0.0149] cost -272.8 -> -360.1
[0.     0.0296 0.1307 0.3702 0.0001 0.0575] cost 10592822.2 -> 4832206.4
[3.5135 0.0151 0.1265 5.2246 0.0006 0.0151] cost -244.0 -> -286.1
[0.     0.0293 0.1313 0.3664 0.0001 0.0569] cost 7393967.0 -> 3723089.0
[array([0.005, 1.5  ]), array([0.0054, 1.3946]), array([0.0043, 1.0109]), array([0.0039, 0.8853]), array([0.0037, 0.8118])]

Observations:

  • Looks like params converge
  • the cost from the traj opts seem to not go monotonically down, so there is a problem caused by this alternation (especially with the different penalties).

Future work

  • needing to switch penalties motivates using a better method - augmented lagrangian?
  • timestep in the opt
  • other TODOs from Noah
  • Julia implementation?

@avikde
Copy link
Owner Author

avikde commented Jul 11, 2019

With no input limit penalty

image

With penalty of 1e3

image

@avikde
Copy link
Owner Author

avikde commented Jul 11, 2019

Using (traj, params) as the opt vec results in a garbage result

image

update the fact that this does not work naively is good. this means that being clever about design optimization might be needed. convex wrt avg performance?

@avikde
Copy link
Owner Author

avikde commented Jul 11, 2019

image

yellow is only lift, green is lift and drag (+x direction)

@avikde
Copy link
Owner Author

avikde commented Jul 14, 2019

Gauss newton implementation worked and reduced the run time from 15s to 7s. (first term now includes jacobian of r)

Jr J0 DJ0 D2J0 Step
Gauss Newton 3.2427 0.015 0.1125 4.0763 0.0279
Newton 0 0.0275 0.2949 13.5016 0.0314

Still, the most time-consuming calculation is the Hessian evaluation.

The remaining non-quadratic terms include the objective and the inequality constraints

@avikde
Copy link
Owner Author

avikde commented Jul 15, 2019

With the new Gauss Newton solver the results are actually better!

image

However, there is still some kind of non-convexity with both G and cbar...

[3.3169 0.014  0.1152 4.9416 0.003  0.0146] cost -147.9 -> -221.2
[0.     0.0288 0.1281 0.352  0.     4.262 ] cost -219.2 -> -334.2
[3.3161 0.0139 0.1167 4.9468 0.0007 0.0147] cost -483.0 -> -1055.7
[0.     0.0306 0.1399 0.3667 0.     0.0279] cost -941.3 -> -26192793084794296.0
[array([0.005, 1.   ]), array([0.0108, 1.0001]), array([110784.6877,   1763.6069])]

@avikde
Copy link
Owner Author

avikde commented Jul 15, 2019

confirmed: nonconvexity wrt params
image

Looking at the "slices" wrt the params:

image
image

Looks ~quadratic with T, ~linear with cbar?

@avikde
Copy link
Owner Author

avikde commented Jul 15, 2019

Evaluating dydt with the initial params and the params after returns these at t=0

[   -765.5635      23.9391 -727110.7488    9699.3942] [-7.6556e+02  2.3939e+01  2.6673e+09 -5.6170e+02]

i.e. the dynamics constraint be being violated. Perhaps the penalty is too small?

update:

yes, that was the problem. However, now, it seems like the dynamics constraint is "too strong". It may not be possible to update the params without also updating the traj.

Also did not make progress when trying to update both at the same time.

@avikde
Copy link
Owner Author

avikde commented Jul 15, 2019

Unfortunately the results are quite similar when optimizing just the traj starting from different params: there is a nonconvexity
Dyn penalty 1e-3
image

Higher dynamics penalty 1e3
image

1e6
image

conclusion

This is proving that #56 (comment) is actually wrong. The dynamics penalty is fine and was being satisfied. The problem is that this nonconvexity truly exists. Need to add constraints or missing some modeled effects.

@avikde
Copy link
Owner Author

avikde commented Jul 15, 2019

This is the simplest representation of the problem. f() changes as a function of T, and hence should be causing dynamics violations, but J seems to be going down with higher T

image

@avikde
Copy link
Owner Author

avikde commented Jul 15, 2019

Finally an optimal T!
image

Optimum agrees for different values of the penalty (good)
image

also optimum for ci
image

Wrt both:
image

Also holds on an optimized traj
image

@avikde avikde merged commit ea4da3c into master Jul 15, 2019
@avikde avikde deleted the wingopt-act-const branch July 15, 2019 23:17
@avikde avikde mentioned this pull request Jul 16, 2019
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant