Optimal controller synthesis for timed systems (Logical Methods in Computer Science, 2023)