Which algorithm for scheduling race grid?
What you're looking for is most likely constraint programming (CP). Essentially, with a CP model you declare a set of variables and a set of constraints (and an objective, optionally). Then a solver will solve your model and find a solution if one exists (if you had specified an objective, it will find the best solution).

Here is an example which is very silimar to your problem (a MiniZinc model which solves the problem is included). You can download MiniZinc and try it out for yourself.