Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
abelsiqueira opened this issue Oct 22, 2023 · 2 comments
Labels
good first issue Good for newcomers

Comments

@abelsiqueira
Copy link
Member

abelsiqueira commented Oct 22, 2023

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.

@abelsiqueira
Copy link
Member Author

@Jay-sanjay, if you want to work on this, can you try implementing strategy 2?

@tmigot
Copy link
Member

tmigot commented Oct 24, 2023

I like the idea of having a more informative output, and even better if it shows nicely on Pluto.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants