AMPL and Modelica are modelling languages, not a solver or optimization algorithm. So, you don't use AMPL or Modelica to solve some optimization problem: you express the problem in AMPL or Modelica, then you use some other solver to find the optimal solution.
AMPL tends to be used for problems that can be solved with optimization methods: e.g., linear programming, integer linear programming, quadratic programming, convex optimization, that sort of thing. Modelica seems to be used for problems that can be solved by solving differential equations or by using hybrid model-checking.
Modelica is for modelling how some continuous variables change over time. Contrary to what you wrote, there's no simple way to model in that in AMPL by "adding a time variable". To put it another way: Modelica lets us model, say, the position of a component as a function of time. This is a function $f(t)$. AMPL lets us model, say, the position, as a fixed continuous value. This is a value $x$. Adding a second variable $t$ still doesn't give you any way to model a function of $t$.
So, the two approaches are for modelling different kinds of problems; and typically they're used with different kinds of back-end solvers, which use different techniques. They're not interchangeable.
Disclaimer: This is all based on my (rather limited) understanding of these systems.