This year's Edelman Winners were US Cycling. Using optimization in sports has become a staple for teams that want to win. Today, we look at a not-so-serious race that happens once a year in DS City.
The ants of DS City are having their annual race. They start at the bottom of a block that is 4 meters high, 3 meters wide, and 5 meters deep.
The ants finish is on the opposite corner of the block, where the winner will wave to the crowd cheering below. Ant racer Hans Solo has asked you to help him plot his fastest route. He is pretty fast at 10cm per second, but that is on level surfaces. In a wall, his pace slows to 5cm per second. How will Hans achieve his best possible finish time?
Are you sure you have found the fastest route for Hans? Don't forget, he is only half as fast on vertical inclines. If that is too complicated, plot the best route first if there were no slowdown in the walls.
Hans' best way is to climb up the 5x4 face first, aiming at 1.615 meters into the 5-meter-long edge. From there, he then runs straight to the finish line. From start to finish, Hans should need a mere 2 minutes and 11.5 seconds.
You can solve this puzzle with calculus, of course. We prefer using Seeker.
import seeker as skr
sides = [3, 4, 5]
orders = [[1, 2, 0], [0, 2, 1], [0, 1, 2]]
sides2 = [a ** 2 for a in sides]
slowdown = [0, 0.5, 0]
env = skr.Env("license.sio")
path_splits = [env.continuous(0, 1) for _ in range(3)]
inv_splits = [1 - a for a in path_splits]
paths = [env.sqrt(sides2[orders[i][1]] + env.sqr(
sides[orders[i][2]] * path_splits[orders[i][2]])) / (
(1 - slowdown[orders[i][1]]) * (
1 - slowdown[orders[i][2]])) + \
env.sqrt(
env.sqr(sides[orders[i][2]] * inv_splits[orders[i][2]]) +
sides2[orders[i][0]]) / ((1 - slowdown[orders[i][0]]) * (
1 - slowdown[orders[i][2]])) for i in range(3)]
min_path = env.min(paths)
env.minimize(min_path, 1)
ord = int(env.argmin(paths).get_value())
print("path takes", min_path.get_value(),
"seconds if we cut edge with length", sides[ord], "at",
path_splits[ord].get_value() * sides[ord])
env.end()