Skip to content

Commit 539757f

Browse files
committed
add display
1 parent ac7b746 commit 539757f

1 file changed

Lines changed: 22 additions & 2 deletions

File tree

src/solve.jl

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
"""
22
$(TYPEDSIGNATURES)
33
4+
Used to set the default display toggle.
5+
The default value is true.
6+
"""
7+
__display() = true
8+
9+
"""
10+
$(TYPEDSIGNATURES)
11+
412
Return the list of available methods that can be used to solve optimal control problems.
513
"""
614
function available_methods()
@@ -94,14 +102,26 @@ julia> sol = solve(ocp, init=(state=[-0.5, 0.2], control=0.5))
94102
See [how to set an initial guess](@ref manual-initial-guess) for more details.
95103
"""
96104
function CommonSolve.solve(
97-
ocp::CTModels.Model, description::Symbol...; kwargs...
105+
ocp::CTModels.Model, description::Symbol...;
106+
display::Bool=__display(),
107+
kwargs...
98108
)::CTModels.Solution
99109

100110
# get the full description
101111
method = CTBase.complete(description; descriptions=available_methods())
102112

113+
# display the chosen method
114+
if display
115+
print("▫ This is OptimalControl running with: ")
116+
for (i, m) in enumerate(method)
117+
sep = i == length(method) ? "." : ", "
118+
printstyled(string(m) * sep, color = :cyan, bold = true)
119+
end
120+
println("\n")
121+
end
122+
103123
# solve the problem
104124
if :direct method
105-
return CTDirect.solve(ocp, clean(description)...; kwargs...)
125+
return CTDirect.solve(ocp, clean(description)...; display=display, kwargs...)
106126
end
107127
end

0 commit comments

Comments
 (0)