Skip to content

Better output for GenericExecutionStats (show vs print) (Pluto display) #80

Description

@abelsiqueira

This is moved from JuliaSmoothOptimizers/SolverTools.jl#93
To define the issue better:

The is a show method in https://github.com/JuliaSmoothOptimizers/SolverCore.jl/blob/main/src/stats.jl#L405
And a print method right below.

This means that on the REPL, the output of

output = trunk(nlp)

is

"Execution stats: first-order stationary"

And to see details, you have to use

print(output)

Which shows

Generic Execution stats
  status: first-order stationary
  objective value: 1.2067821564748022e-25
  primal feasibility: 0.0
  dual feasibility: 3.0567567125153457e-13
  solution: [0.99999999999966  0.9999999999992844]
  iterations: 10
  elapsed time: 0.0009999275207519531

At least in Pluto notebooks, I want the initial call output = trunk(nlp) to show the complete output.
From the little I gathered, there are two strategies:

  1. Don't have a separate print functions, instead, put everything in show; or
  2. Use MIME types to show a different output for Pluto (which I guess is related to HTML).

I like option 2 more. @tmigot @dpo, opinions?

There is some information about display vs show vs print in this JuliaCon 2020 video: https://www.youtube.com/watch?v=S1Fb5oNhhbc that might be useful.


To reproduce, open a Pluto notebook and add the following cells:

Cell 1

using ADNLPModel, JSOSolvers

Cell 2

let
nlp = ADNLPModel(x -> (x[1] - 1)^2 + 4 * (x[2] - x[1]^2)^2, [-1.2; 1.0])
output = trunk(nlp)
end


There is also a compact::Bool flag in show, that might be enough to have a single function with everything.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions