Hacker News new | ask | show | jobs
by mg 1204 days ago
It's interesting to think about how the optimal strategy to land the lander would look like.

If the distance to the moon was large, I would expect 4 phases:

1: Turn the lander towards the moon

2: Constant thrust towards the moon

3: Turn the lander away from the moon

4: Constant thrust away from the moon

But if the initial distance is small enough, turning it around might not be worth it or even possible.

So the optimal strategy is probably a somewhat complex function of the initial angle and distance to the moon.

2 comments

when discussing about optimality, it is worth specifying what are you optimising for.

time optimal landing lends techniques from bang-bang control (e.g. starting with v=0, max thrust towards the target, before flipping around half way and max thrust away from target)

fuel optimal landing (incuding RCS) technique would depend on the available time to turn retrograde (pointy end pointing away from direction of movement). if the duration before the decelerating burn is T1 (so t1 = t0+T1), the smallest possible rcs impulse would be applied so that at t1-T_st the lander is pointing retrograde (retrograde at t1), with T_st being the time needed to cancel the initial rcs impulse. For the deceleration of the lander, fuel optimal landing includes a single burn, constantly retrograde, so that at t_end the lander altitude is 0, and both the vertical and horizontal velocity components are 0.

The time t1 to start that burn depends on the maximum thrust available, the rate of mass change when firing the rocket (not modelled in the game), the initial velocity etc.

in this simple case, model predictive control is not needed, and an LQR (linear quadratic regulator) is sufficient to achieve optimality

source: rocket scientist with control theory background. I remember this example (a bit more realistically modelled) being a project during my studies

In implementing an AI to achieve orbit in a Spacewar-style simulation with gravity, I ended up with a brute-force constraint optimizer that resembles MCP(I've never studied the theory): for each timestep, predict the solutions resulting for each combination of digital thrust inputs(left, right, forward, backwards). Then predict ahead several more steps with additional permutations of input. Then evaluate distance to goal and rank final solution by distance to target orbit and velocity match.

In doing this, it results in a few hundreds to thousands of solutions to test per timestep, which modern CPUs can shrug off easily. Not nearly as elegant as closed-form control theory systems, but easy to tune and give different goals.

replace the brute-force with a linear constraint solver, and you got yourself an MPC !

non-linear constraint solvers are not used because they cannot guarantee a time to solution, hence useless for control applications

almost guaranteed that this problem is already solved by the rocket scientists out there. hopefully someone on HN can point us to the relevant algorithm. this seems like a closed system at least in newtonian physics that should be easily solvable.

chatgpt pointed me to the Gravity Turn altho it refused to give me a formula for it https://en.wikipedia.org/wiki/Gravity_turn#Deorbit_and_entry

This is typically solved using a class of control algorithm called Model Predictive Control which are capable of optimizing for a given cost function (such as using minimal fuel).

Search for "fuel optimal rocket landing algorithm" for good starting points.