infiniteopt / InfiniteOpt.jl

An intuitive modeling interface for infinite-dimensional optimization problems.
https://infiniteopt.github.io/InfiniteOpt.jl/stable
MIT License
254 stars 17 forks source link

Unsmooth points at the beginning and end of control function #250

Closed Song921012 closed 2 years ago

Song921012 commented 2 years ago

Hello, Pulsipher, appreciate your work on InfiniteOpt. While solving the following optimal control problem image The optimal control function should be smooth. But the numerical optimal results has unsmooth points at the beginning and end. image

I test many examples, it happened in most examples. Why it happens and how to deal with it?

using InfiniteOpt, Ipopt, Plots
using KNITRO
# Parmeters
# Time span
t0 = 0
tf = 1
# Initial values
x1 = 1
# Model
model = InfiniteModel(KNITRO.Optimizer)
# infinite_parameter
@infinite_parameter(model, t ∈ [t0, tf], num_supports = 101)
# variable
@variable(model, x ≥ 0, Infinite(t))
@variable(model, u, Infinite(t), start = 0)
# objective
@objective(model, Min, x(1)^2+∫(u^2, t))
# constraint
@constraint(model, x(0) == x1)
@constraint(model, x_constr, ∂(x, t) == x + u)
# Optimization
print(model)
optimize!(model)
# Visulization
ts = value(t)
u = value(u)
x = value(x)

@show plot(ts, u)
@show plot(ts, x)