239 points · by maydemir · 5y ago · 51 comments
Consider: if you were given a freeze-frame view of the car in the exact right spot, what controls would you send it to keep it there? It'd be impossible to say without knowing the car's velocity - if the car was in the process of reversing, it should apply forwards acceleration to come to a stop, but if it was in the process of going forwards it should apply reverse acceleration.
The solution is to add Derivative control. This would look like a second set of inputs to the system comprised of the difference between the current measurements and the prior ones.
When this happened on my job, I was very surprised that I hadn’t heard of PID controllers in CS school. They’re standard in other kinds of engineering.
There are often better variants and alternatives to a basic PID controller, but I’m quite partial to the core idea - the three terms in the PID controller are analogous to car/bike suspensions. It’s a unitless suspension system for sensors & data. Spring rate is like your proportional term, and compression damping and rebound damping are like the derivative and integral terms. This analogy ain’t perfect, but I dig the concept.
My concentration was embedded systems but the majority of the class were just regular CS students.
But yes, I couldn’t imagine a CS education without controls. My intro CS class in college explored controls in some depth and I took a follow up class. Some of the most incredible things I’ve created were control systems, and it’s one of the primary classes I think of when people ask about the merits of a college education.
https://codesandbox.io/embed/rocket-sim-final-with-position-...
There are supposed to be better controllers but dang PID just work.
Usually better to design the process to be controlled by a PID than the other way around.
In this case, the mapping of a complicated multi-step process involving external constraints to a "gene" is going to be a hack, no matter what you do.
I think calling it a "hack" misses the nuance: mapping the physical metrics and telemetry into a genome is nontrivial.
Plus 40 generations is no where NEAR enough. A GA needs millions (or billions) of generations to avoid local minima/maxima. Especially given the size of the input vector. His vector is what, 2^100 states?
> I think calling it a "hack" misses the nuance: mapping the physical metrics and telemetry into a genome is nontrivial.
Well, that's definitely what I was trying to say, so we're agreed.
I actually don't think GA a great fit for this problem as parking a car is a time- and circumstance-dependent process, and a fixed gene is...not. But that's a guess.
Assuming you can actually detect success, that's not really that big of a problem. You can do it in 11 lines by appending:
for(i in 1e7){g=do-generation(g);if(worksp(g)) return g}
It'll take while, but the claim is that it optimises on lines, not on runtime.Does this evolution park a car only if all the other cars are in those precise spots?
[1] https://www.npr.org/templates/story/story.php?storyId=122880...