I am trying to write a thruster control system that manages an array of custom thruster structs. Each thruster has a location, orientation, maximum thrust, throttle and a range of gimbal for its Y Axis and Z Axis, etc. Given a supplied vector representing the desired direction of acceleration, the control system should adjust the gimbals and throttle within their possible ranges, in an attempt to match the desired direction.

Example, a pair of thrusters opposingly angled at 45 degrees from center would gimbal towards each other and cancel their remaining side to side components of their thrust vector to give a forward acceleration. (However, I cannot really on thrusters to be arranged in opposing pairs. It is very important that this system works with any number of thrusters in any arrangement/)

Essentially, the nomralized sum of the thrust from the individual thrusters needs to equal the desired direction of acceleration. However, this is complicated by the fact that the system needs to work with any number of thrusters. There are also many possible combinations that could satisfy the requirement of thrust being in the correct direction (or none, in which case I want the closest). Secondary criteria would be maximum total thrust, and least torque generated.

I know the physics for calculating thrust, acceleration, torque, etc. So that isn't a problem. However, I don't have much experience setting up this type of algorithm.

Representing the two axis of gimbal, and the throttle, as possible ranges of continous values means there is a nearly infinite number of solutions to check.

An idea I have is to limit the gimbal and throttle of a thruster to ten or twenty discrete increments, rather than the continous range. I would check combinations at random, and assign each a desirableness score, adopting any new combination with a higher score. (I really don't like doing things randomly if it can be avoided.)

The solution also needs to be fast enough to run each frame of a simulation.

Is there a smarter way to do this?

This is a bit outside of the types of problems I normally tackle, so I haven't made much headway with research. If you know terms I should be searching for, or anything at all that can help, please share.

Thank you very much.