TRIQS/maxent

verbosity during run

Closed this issue · 4 comments

Hello,

Im currently trying to run this code without getting text output into my terminal. I found on the website that there exist this function set_verbosity(), but for me it is doing nothing.

    tm = TauMaxEnt(cost_function='bryan', probability='normal')
    tm.set_verbosity(0)
    tm.set_G_tau(gtau)
    tm.set_error(0.001)
    result = tm.run()

With kind regards
Marcel Klett

Hi Marcel,

You're right, the verbosity setting is a bit confusing, this should be improved!

For the verbosity mechanism to work, both the verbose flag in the logtaker and the verbose_callback of the minimizer has to be set. The default value for the verbose flag in the logtaker is 1, but the default callback is None. This is not good, I will change that to something sensible so that the default value is consistent.

All in all, on the level of TauMaxEnt, the default value of the verbosity is 0. That means, I did not consider the one line per alpha that is written out something that you might want to turn off - but I guess that's exactly what you wanted to do. So, right now you can only get more info written out by changing the verbosity (e.g. to 1 or 2), but not less.

I guess we should change the verbosity levels (this would not be backward-compatible, but I guess that's ok in the case of verbosity).

What would you think of the following verbosity levels (also, @mzingl please comment):

  • 0: write out nothing at all
  • 1: write out the header and timing info
  • 2: write out one line per alpha (=current verbosity 0, current and probably future default)
  • 3: write out convergence info (= current verbosity 2)

And then I would add an extra flag about whether to write this in one line that gets updated (as with verbosity=1 now), for the new verbosity 2 and 3, or whether to write it out as usual (as current verbosity 2).

Ok, this was now maybe a bit much, I hope you understand what I mean. In short, what the code does is expected behavior for me, but I agree that it's not logical and will change it.

Best
Gernot

first of all thank you for the fast response. Yeah, what i wanted to "avoid" is the output for the lines with

alpha = ...

I think the level of verbosities you present are good for all purposes one could think of

Regards,
Marcel

Agreed, but let's keep the output of the alpha lines as default. This is important information.

I went for a slightly different approach: I introduced a class called VerbosityFlags, which are flags that can be combined using |.

The levels mentioned above would be

  • 0: VerbosityFlags.Quiet
  • 1: VerbosityFlags.Header | VerbosityFlags.Timing
  • 2: VerbosityFlags.Default
  • 3: VerbosityFlags.Default | VerbosityFlags.SolverDetails

More info in the doc (VerbosityFlags and set_verbosity).

The "write this in one line" stuff is handled by the Logtaker's one_line argument. All flags set in one_line are the ones that will overwrite the current line instead of producing a new line.