Skip to content

Commit

Permalink
Merge branch 'main' into add_some_ocp_indicators
Browse files Browse the repository at this point in the history
  • Loading branch information
ocots committed Jun 20, 2024
2 parents b3cc4ed + b214a72 commit 15f5c25
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 8 deletions.
7 changes: 6 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,18 @@ LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
MLStyle = "d8e11817-5142-5d16-987a-aa16d5891078"
MacroTools = "1914dd2f-81c6-5fcd-8719-6d5c9610ff09"
Parameters = "d96e819e-fc66-5662-9728-84c9c7592b0a"
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
PrettyTables = "08abe8d2-0d0c-5749-adfa-8a2ac140af0d"
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
Reexport = "189a3867-3050-52da-a836-e630ba90ab69"
ReplMaker = "b873ce64-0db9-51f5-a568-4457d8e49576"
Unicode = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5"

[weakdeps]
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"

[extensions]
CTBasePlots = "Plots"

[compat]
DataStructures = "0.18"
DifferentiationInterface = "0.5"
Expand Down
16 changes: 16 additions & 0 deletions ext/CTBasePlots.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
module CTBasePlots

#
using DocStringExtensions
using MLStyle # pattern matching

#
using CTBase
using Plots
using LinearAlgebra
import Plots: plot, plot!

# --------------------------------------------------------------------------------------------------
include("plot.jl")

end
6 changes: 3 additions & 3 deletions src/plot.jl → ext/plot.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ $(TYPEDEF)
A leaf of a plot tree.
"""
struct PlotLeaf <: AbstractPlotTreeElement
value::Tuple{Symbol,Integer}
PlotLeaf(value::Tuple{Symbol,Integer}) = new(value)
value::Tuple{Symbol, Integer}
PlotLeaf(value::Tuple{Symbol, Integer}) = new(value)
end

"""
Expand Down Expand Up @@ -402,7 +402,7 @@ function Plots.plot(sol::OptimalControlSolution;
#
p = __initial_plot(sol; layout=layout, control=control, size=size, kwargs...)
#
return plot!(p, sol; layout=layout, control=control, time=time, solution_label=solution_label,
return Plots.plot!(p, sol; layout=layout, control=control, time=time, solution_label=solution_label,
state_style=state_style, control_style=control_style, costate_style=costate_style, kwargs...)
end

Expand Down
3 changes: 0 additions & 3 deletions src/CTBase.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import ForwardDiff
using Interpolations: linear_interpolation, Line, Interpolations # for default interpolation
using MLStyle # pattern matching
using Parameters # @with_kw: to have default values in struct
using Plots
using Printf # to print an Opt imalControlModel
using DataStructures # OrderedDict for aliases
using Unicode # unicode primitives
Expand Down Expand Up @@ -205,7 +204,6 @@ include("utils.jl")
include("checking.jl")
#
include("print.jl")
include("plot.jl")
#
include("functions.jl")
include("model.jl")
Expand Down Expand Up @@ -256,7 +254,6 @@ export dim_boundary_conditions, dim_control_constraints, dim_state_constraints,

# solution
export OptimalControlSolution
export plot, plot!

# initialization
export OptimalControlInit
Expand Down
1 change: 1 addition & 0 deletions test/test_plot_joseph.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

# a la main
using CTBase
using PlotUtils

n=1
m=1
Expand Down
2 changes: 1 addition & 1 deletion test/test_plot_manual.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using CTBase
#using Plots
using Plots

layout = :split
size = (900, 600)
Expand Down

0 comments on commit 15f5c25

Please sign in to comment.