Replies: 6 comments 2 replies
-
|
This type of error occurs when the objective and/or constraints have a function or derivative that is ill-posed (e.g., divides by zero, takes the square root of a negative number). In this case, adding appropriate guesses to Regarding your formulation, what are On a side note, it is preferred that issues are reserved for bugs/feature requests and that usage questions like this one are asked in the forum (i.e., the Discussions tab). |
Beta Was this translation helpful? Give feedback.
-
|
Ha good catch, I will try.
My apologies, I wasn't aware. I think you can convert it to a discussion in the sidebar. |
Beta Was this translation helpful? Give feedback.
-
|
I would like to compute the maximum likelihood path (MLP) of an underdamped stochastic ordinary system. Suppose we SDE of the form: with where A typical example would be a double well problem such as the Maier Stein system given as: where one wants to know the optimal path between the two attractors (-1, 0) and (1, 0). If I correct my mistake of the derivative: using InfiniteOpt, Ipopt, Plots
T = 1
opt = Ipopt.Optimizer # desired solver
ns = 101; # number of points in the time grid
model = InfiniteModel(optimizer_with_attributes(opt));
@infinite_parameter(model, t in [0, T], num_supports = ns)
xx(t) = -1*(1-t) + 1*t
xxx = xx.(supports(t))
yy(t) = 0.3 .* (- xx(t) .^ 2 .+ 1)
yyy = yy.(supports(t))
scatter(xxx, yyy)
@variable(model, u, Infinite(t), start = xx)
@variable(model, v, Infinite(t), start = yy)
@objective(model, Min, ∫(√(∂(u, t)^2 + ∂(u, t)^2)*√(u^2 + v^2) - (∂(u, t)*u + ∂(u, t)*v), t))
@constraint(model, u(0) == -1)
@constraint(model, v(0) == 0)
@constraint(model, u(T) == 1)
@constraint(model, v(T) == 0)
@constraint(model, ∂(u, t) == u - u^3 - 10*u*v^2)
@constraint(model, ∂(v, t) == -(1 - u^2)*v )
optimize!(model)Ipopt says I have to0 few degrees of freedom: Do I have to introduce the velocity as a separate variable? |
Beta Was this translation helpful? Give feedback.
-
|
The key issue here is that with the two ODEs and the initial conditions, the problem is fully determined. Using control language, this problem has two state variables Consider the steady state case where we have: Hence, adding the terminal constraints likely makes the model infeasible. |
Beta Was this translation helpful? Give feedback.
-
|
Thank you very much for the explanation! I have managed to get the problem working for a slightly different "problem", i.e., This disadvantage is that know one has to additional minimise using InfiniteOpt, Ipopt, Plots
T = 50
opt = Ipopt.Optimizer # desired solver
ns = 501; # number of points in the time grid
model = InfiniteModel(optimizer_with_attributes(opt));
@infinite_parameter(model, t in [0, T], num_supports = ns)
xx(t) = (-1*(1-t/T) + 1*t/T)
xxx = xx.(supports(t))
yy(t) = 0.3 .* (- xx(t) .^ 2 .+ 1)
yyy = yy.(supports(t))
scatter(xxx, yyy)
@variable(model, u, Infinite(t), start = xx)
@variable(model, v, Infinite(t), start = yy)
du = u - u^3 - 10*u*v^2
dv = -(1 - u^2)*v
@objective(model, Min, ∫((∂(u, t) - du)^2 + (∂(v, t) - dv)^2, t))
@constraint(model, u(0) == -1)
@constraint(model, v(0) == 0)
@constraint(model, u(T) == 1)
@constraint(model, v(T) == 0)
# @constraint(model, ∂(u, t) == u - u^3 - 10*u*v^2)
# @constraint(model, ∂(v, t) == -(1 - u^2)*v )
optimize!(model)
u_opt = value.(u)
v_opt = value.(v)
plot(u_opt, v_opt)
xlims!(-1.1, 1.1)
ylims!(-0.1,0.5)Do you think there is a way to also do it for the geometric minimal action method? The main problem is that I need to 2-norm (sqrt) which seems to give instabilities. This would be a geometric implemetation: using InfiniteOpt, Ipopt, Plots
T = 1
opt = Ipopt.Optimizer # desired solver
ns = 101; # number of points in the time grid
model = InfiniteModel(optimizer_with_attributes(opt));
@infinite_parameter(model, t in [0, T], num_supports = ns)
xx(t) = (-1*(1-t/T) + 1*t/T)
xxx = xx.(supports(t))
yy(t) = 0.3 .* (- xx(t) .^ 2 .+ 1)
yyy = yy.(supports(t))
scatter(xxx, yyy)
@variable(model, u, Infinite(t), start = xx)
@variable(model, v, Infinite(t), start = yy)
du = u - u^3 - 10*u*v^2
dv = -(1 - u^2)*v
@objective(model, Min, ∫(√((∂(v, t)^2+∂(u, t)^2)*(dv^2+dv^2)) - (∂(v, t)*dv + ∂(u, t)*du), t))
# the sqrt makes it unstable
@constraint(model, u(0) == -1)
@constraint(model, v(0) == 0)
@constraint(model, u(T) == 1)
@constraint(model, v(T) == 0)
optimize!(model)
u_opt = value.(u)
v_opt = value.(v)
plot(u_opt, v_opt)
xlims!(-1.1, 1.1)
ylims!(-0.1,0.5)
which give the instability error again H |
Beta Was this translation helpful? Give feedback.
-
|
I am glad to see things are coming along. To deal with the square root, a common trick is to introduce an auxiliary variable and square it. Consider the following formulation: using InfiniteOpt, Ipopt
model = InfiniteModel(Ipopt.Optimizer)
@infinite_parameter(model, t in [0, 1], num_supports = 101)
@variable(model, y >= -1, Infinite(t))
@objective(model, Min, integral(sqrt(y), t))which leads to invalid derivative evaluations. We can reformulate it into: model = InfiniteModel(Ipopt.Optimizer)
@infinite_parameter(model, t in [0, 1], num_supports = 101)
@variable(model, y >= -1, Infinite(t))
@variable(model, aux, Infinite(t)) # auxiliary variable
@objective(model, Min, integral(aux, t))
@constraint(model, aux^2 == y) # aux == sqrt(y) --> aux^2 == ywhich avoids the invalid derivative evaluations. |
Beta Was this translation helpful? Give feedback.


Uh oh!
There was an error while loading. Please reload this page.
-
When I try to optimise the following system Ipopt complains that the system is not differentiable. Is the following intergral expression invalid?
Beta Was this translation helpful? Give feedback.
All reactions