@@ -25,35 +25,89 @@ __time_normalization() = :default
2525"""
2626$(TYPEDSIGNATURES)
2727
28+ """
29+ __description () = (:state , :states ,
30+ :costate , :costates ,
31+ :control , :controls ,
32+ :constraint , :constraints , :cons , :path ,
33+ :dual , :duals )
34+
35+ """
36+ $(TYPEDSIGNATURES)
37+
2838Used to set the default value of the plot size.
2939"""
3040function __size_plot (
3141 sol:: CTModels.Solution ,
3242 model:: Union{CTModels.Model,Nothing} ,
3343 control:: Symbol ,
3444 layout:: Symbol ,
45+ description:: Symbol... ;
46+ state_style:: Union{NamedTuple, Symbol} ,
47+ control_style:: Union{NamedTuple, Symbol} ,
48+ costate_style:: Union{NamedTuple, Symbol} ,
49+ path_style:: Union{NamedTuple, Symbol} ,
50+ dual_style:: Union{NamedTuple, Symbol} ,
3551)
36- if layout === :group
37- if control === :all
38- return (600 , 560 )
52+
53+ # set the default description if not given and then clean it
54+ description = description == () ? __description () : description
55+ description = clean (description)
56+
57+ # check what to plot
58+ do_plot_state, do_plot_costate, do_plot_control, do_plot_path, do_plot_dual = do_plot (
59+ description... ;
60+ state_style= state_style,
61+ control_style= control_style,
62+ costate_style= costate_style,
63+ path_style= path_style,
64+ dual_style= dual_style
65+ )
66+
67+ #
68+ if layout == :group
69+ nb_plots = 0
70+ nb_plots += do_plot_state ? 1 : 0
71+ nb_plots += do_plot_costate ? 1 : 0
72+ if do_plot_control
73+ if control == :components || control == :norm
74+ nb_plots += 1
75+ elseif control === :all
76+ nb_plots += 2
77+ end
78+ end
79+ if control == :all && nb_plots == 4
80+ return (600 , 420 )
3981 else
4082 return (600 , 280 )
4183 end
4284 else
4385 n = CTModels. state_dimension (sol)
86+ m = CTModels. control_dimension (sol)
4487 l = @match control begin
45- :components => CTModels . control_dimension (sol)
88+ :components => m
4689 :norm => 1
47- :all => CTModels . control_dimension (sol) + 1
90+ :all => m + 1
4891 _ => throw (
4992 CTBase. IncorrectArgument (
5093 " No such choice for control. Use :components, :norm or :all"
5194 ),
5295 )
5396 end
5497 nc = model === nothing ? 0 : CTModels. dim_path_constraints_nl (model)
55- return (600 , 140 * (n + l + nc))
98+ nb_lines = 0
99+ nb_lines += (do_plot_state || do_plot_costate) ? n : 0
100+ nb_lines += do_plot_control ? l : 0
101+ nb_lines += (do_plot_path || do_plot_dual) ? nc : 0
102+ if nb_lines== 1
103+ return (600 , 280 )
104+ elseif nb_lines== 2
105+ return (600 , 420 )
106+ else
107+ return (600 , 140 * nb_lines)
108+ end
56109 end
110+
57111end
58112
59113"""
0 commit comments