control-toolbox / control-toolbox/OptimalControl.jl
[Bug] Reverse over forward AD issues with ADNLP
- Dominant language
- Julia
- Stars
- 135
- Forks
- 11
- Avg merge
- 6h 54m
- Merged PRs (30d)
- 56
Description
@ocots @PierreMartinon Same kind of error with AD as in #384 tough here the problem seems to be directly related to using a constant in the computation: this fails (`Cannot determine ordering of Dual tags ForwardDiff.Tag`)
```julia
using OptimalControl
using NLPModelsIpopt
o = @def begin
v ∈ R, variable
t ∈ [0, 1], time
x ∈ R², state
u ∈ R, control
-1 ≤ v ≤ 1
x(0) - [-1, v] == [0, 0] # OK: the boundary contraint may involve the variable
x(1) == [0, 0]
ẋ(t) == [x₂(t), u(t)]
∫( 0.5u(t)^2 ) → min
end
s = solve(o)
```
this also fails (same error)
```julia
o = @def begin
v ∈ R, variable
t ∈ [0, 1], time
x ∈ R², state
u ∈ R, control
-1 ≤ v ≤ 1
x(0) - [-one(v), v] == [0, 0] # OK: the boundary contraint may involve the variable
x(1) == [0, 0]
ẋ(t) == [x₂(t), u(t)]
∫( 0.5u(t)^2 ) → min
end
```
while this is OK
```julia
o = @def begin
v ∈ R, variable
t ∈ [0, 1], time
x ∈ R², state
u ∈ R, control
-1 ≤ v ≤ 1
x(0) - [-1 + 0v, v] == [0, 0] # OK: the boundary contraint may involve the variable
x(1) == [0, 0]
ẋ(t) == [x₂(t), u(t)]
∫( 0.5u(t)^2 ) → min
end
```
@PierreMartinon I thought that using `one` as above (second version; see also `zero`) solved the problem, but this is not the case. any clue?
Contributor guide
Assessment
This issue has not been assessed yet.