1.0</code></pre><h3 id="Step-4:-Analyze-the-Solution"><a class="docs-heading-anchor" href="#Step-4:-Analyze-the-Solution">Step 4: Analyze the Solution</a><a id="Step-4:-Analyze-the-Solution-1"></a><a class="docs-heading-anchor-permalink" href="#Step-4:-Analyze-the-Solution" title="Permalink"></a></h3><p>Now let's check out the solution. First of all, what kind of thing is the <code>sol</code>? We can see that by asking for its type:</p><pre><code class="language-julia hljs">typeof(sol)</code></pre><pre class="documenter-example-output"><code class="nohighlight hljs ansi">SciMLBase.OptimizationSolution{Float64, 1, Vector{Float64}, OptimizationBase.OptimizationCache{SciMLBase.OptimizationFunction{true, ADTypes.AutoForwardDiff{nothing, Nothing}, typeof(Main.L), OptimizationBase.var"#grad#16"{Vector{Float64}, SciMLBase.OptimizationFunction{true, ADTypes.AutoForwardDiff{nothing, Nothing}, typeof(Main.L), Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED_NO_TIME), Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing}, ADTypes.AutoForwardDiff{nothing, Nothing}}, Nothing, OptimizationBase.var"#hess#20"{Vector{Float64}, SciMLBase.OptimizationFunction{true, ADTypes.AutoForwardDiff{nothing, Nothing}, typeof(Main.L), Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED_NO_TIME), Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing}, DifferentiationInterface.SecondOrder{ADTypes.AutoForwardDiff{nothing, Nothing}, ADTypes.AutoForwardDiff{nothing, Nothing}}}, Nothing, OptimizationBase.var"#hv!#24"{Vector{Float64}, DifferentiationInterfaceForwardDiffExt.ForwardDiffOverSomethingHVPPrep{ADTypes.AutoForwardDiff{nothing, ForwardDiff.Tag{DifferentiationInterfaceForwardDiffExt.ForwardDiffOverSomethingHVPWrapper{typeof(Main.L)}, Float64}}, DifferentiationInterfaceForwardDiffExt.var"#inner_gradient#9"{typeof(Main.L), DifferentiationInterface.SecondOrder{ADTypes.AutoForwardDiff{nothing, Nothing}, ADTypes.AutoForwardDiff{nothing, Nothing}}, DifferentiationInterfaceForwardDiffExt.ForwardDiffGradientPrep{ForwardDiff.GradientConfig{ForwardDiff.Tag{DifferentiationInterface.FixTail{typeof(Main.L), Tuple{Vector{Float64}}}, ForwardDiff.Dual{ForwardDiff.Tag{DifferentiationInterfaceForwardDiffExt.ForwardDiffOverSomethingHVPWrapper{typeof(Main.L)}, Float64}, Float64, 1}}, ForwardDiff.Dual{ForwardDiff.Tag{DifferentiationInterfaceForwardDiffExt.ForwardDiffOverSomethingHVPWrapper{typeof(Main.L)}, Float64}, Float64, 1}, 2, Vector{ForwardDiff.Dual{ForwardDiff.Tag{DifferentiationInterface.FixTail{typeof(Main.L), Tuple{Vector{Float64}}}, ForwardDiff.Dual{ForwardDiff.Tag{DifferentiationInterfaceForwardDiffExt.ForwardDiffOverSomethingHVPWrapper{typeof(Main.L)}, Float64}, Float64, 1}}, ForwardDiff.Dual{ForwardDiff.Tag{DifferentiationInterfaceForwardDiffExt.ForwardDiffOverSomethingHVPWrapper{typeof(Main.L)}, Float64}, Float64, 1}, 2}}}}, DifferentiationInterface.Rewrap{1, Tuple{typeof(DifferentiationInterface.constant_maker)}}}, DifferentiationInterfaceForwardDiffExt.ForwardDiffOneArgPushforwardPrep{ForwardDiff.Tag{DifferentiationInterfaceForwardDiffExt.ForwardDiffOverSomethingHVPWrapper{typeof(Main.L)}, Float64}, Vector{ForwardDiff.Dual{ForwardDiff.Tag{DifferentiationInterfaceForwardDiffExt.ForwardDiffOverSomethingHVPWrapper{typeof(Main.L)}, Float64}, Float64, 1}}}}, SciMLBase.OptimizationFunction{true, ADTypes.AutoForwardDiff{nothing, Nothing}, typeof(Main.L), Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED_NO_TIME), Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing}, DifferentiationInterface.SecondOrder{ADTypes.AutoForwardDiff{nothing, Nothing}, ADTypes.AutoForwardDiff{nothing, Nothing}}}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED_NO_TIME), Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing}, OptimizationBase.ReInitCache{Vector{Float64}, Vector{Float64}}, Vector{Float64}, Vector{Float64}, Nothing, Nothing, Nothing, NLopt.Algorithm, Bool, OptimizationNLopt.var"#2#4", Nothing}, NLopt.Algorithm, Float64, NLopt.Opt, SciMLBase.OptimizationStats}</code></pre><p>From this, we can see that it is an <code>OptimizationSolution</code>. We can see the documentation for how to use the <code>OptimizationSolution</code> by checking the <a href="https://docs.sciml.ai/Optimization/stable/API/optimization_solution/">Optimization.jl solution type page</a>. For example, the solution is stored as <code>.u</code>. What is the solution to our optimization, and what is the final loss value? We can check it as follows:</p><pre><code class="language-julia hljs"># Analyze the solution
0 commit comments