Skip to content

Racetrack optimization

dchudz edited this page Sep 1, 2013 · 2 revisions

When Kaggle went go-cart racing, I thought a bit about how to optimizing the speed. My simple model is a 1-D closed curve track with an maximum allowed speed at each point (if you exceed that, you slide and bad things happen) and a set of achievable accelerations between the "maximum breaking" (without sliding) and "maximum acceleration".

The interesting fact about this is that for the optimal accelerations, you are always either:

  • accelerating full;
  • decelerating full; or
  • at the current maximum speed allowed by your present location or some future constraint that you need to decelerate in time for

High-Level Plan

  1. get points for forming the racetrack curve
  2. fit smoothest curve through all of them---I had a bunch of trouble finding a curve-fitting algorithm already available that I'd like for this purpose. (https://www.picloud.com/accounts/notebook/#) -- probably tackle the curve-fitting as an independent problem, or proceed with this curve fitting (which isn't great for my purposes, but good enough). I haven't found a minimum energy 2D curve fitting implementation in Python, so maybe doing that is worthwile in its own right. This paper is interesting and descibes what I mean by "minimum energy" but probably doesn't help me with implementation. Not sure, though.
  3. choose set of points to represent the curve (more densely filled in than the original set of points)
  4. find maximum speed at each point based on curvature
  5. optimize speed through the whole course (see below)

optimization algorithm:

This problem actually has a very cute/simple optimization:

1, start at the most constrained point. Appropriate speed there is the max allowable speed there. 2. go back one instant (go back one point in our set of representative points). what is the largest speed there which is consistent with that point's max and the next point's max? that's the right speed for that point 3. repeat

When you get back to the original point, step (2) is consistent with the max speed already assigned there, because that's the most constrained point.

visualization

draw path with moving dot (video), paths with perpendicular bars for maximum speed at each point, for actual speed, and for acceleration

ggplot2 would be good for this.

blog post:

  • explanation for focusing on 1d path (your actual path is 1d, so any insights apply to a more realistic track, even if we aren't finding that path)
  • proof that either you're accelerating full, decelerating full, or current maximum speed is a binding constraint
  • explanation of algorithm
  • visualizations
  • write out the optimization problem it's solving... that looks complicated! (minimize time... maximize average velocity... over time, not position! means weighting by 1/v)

maybe blog post sooner on (1/v)-weighted velocity .... write about how this is actually a harmonic mean harmonic mean?