stan-dev / cmdstan

CmdStan, the command line interface to Stan
https://mc-stan.org/users/interfaces/cmdstan
BSD 3-Clause "New" or "Revised" License
210 stars 93 forks source link

Discrepancy between `help-all` print and defaults: Pathfinder, LBFGS and BFGS #1214

Closed andrewjradcliffe closed 10 months ago

andrewjradcliffe commented 10 months ago

Summary:

The detailed print of the argument tree contains a few nodes which exhibit a discrepancy between the default value (as printed) and the default logged in the output. This only affects tol_obj, tol_grad and tol_param.

Description:

The problem affects 2 methods: optimize and pathfinder. For optimize, both the LBFGS and BFGS algorithms are affected. Together, this forms 3 cases in which the same 3 double values are printed with insufficient precision by help-all.

Reproducible Steps:

Assuming that one has the Bernoulli example built:

# Produce the default values which are logged in the output
./bernoulli method=optimize algorithm=lbfgs data file=bernoulli.data.json output file=lbfgs.csv
./bernoulli method=optimize algorithm=bfgs data file=bernoulli.data.json output file=bfgs.csv
./bernoulli method=pathfinder data file=bernoulli.data.json output file=pathfinder.csv

for name in lbfgs bfgs pathfinder ; do
    echo ================ ${name} ================
    grep -E "tol_(obj|grad|param)" ${name}.csv
done

# Compare against defaults in detailed print -- `rg` is ripgrep (has multiline option)
./bernoulli help-all | rg -U "tol_(obj|grad|param)=<double>\n.*\n.*\n.*Defaults to"

Current Output:

For each case of the 3 cases, this produces the information in the table below.

variable default value printed by help-all true default logged by call with no arguments supplied
tol_obj 0.000000 9.9999999999999998e-13
tol_grad 0.000000 1e-08
tol_param 0.000000 1e-08

Expected Output:

help-all should print values with sufficient precision.

Current Version:

v2.33.1