Skip to content

Commit 923a7b5

Browse files
committed
foo
1 parent 66f9626 commit 923a7b5

File tree

4 files changed

+19
-1
lines changed

4 files changed

+19
-1
lines changed

src/OptimalControl.jl

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ using CTProblems
2222

2323
# declarations
2424
const __display = CTBase.__display
25+
__ocp_init() = CTBase.OCPInit()
2526

2627
include("solve.jl")
2728

src/solve.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ julia> sol = solve(ocp, init=(state=t->[-1+t, t*(t-1)], control=t->6-12*t))
6666
"""
6767
function solve(ocp::OptimalControlModel, description::Symbol...;
6868
display::Bool=__display(),
69-
init=nothing,
69+
init=__ocp_init(),
7070
kwargs...)
7171

7272
#

test/runtests.jl

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ using CTProblems
77
#
88
@testset verbose = true showtiming = true "Optimal control tests" begin
99
for name (
10+
:basic,
1011
:goddard_direct,
1112
:goddard_indirect,
1213
:init,

test/test_basic.jl

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
function test_basic()
2+
3+
@def ocp begin
4+
t [ 0, 1 ], time
5+
x R², state
6+
u R, control
7+
x(0) == [ -1, 0 ]
8+
x(1) == [ 0, 0 ]
9+
(t) == [ x₂(t), u(t) ]
10+
( 0.5u(t)^2 ) min
11+
end
12+
13+
sol = solve(ocp)
14+
@test sol.objective 6 atol=1e-2
15+
16+
end

0 commit comments

Comments
 (0)