tweag / economics

Data science focussed on economics and social science
BSD 3-Clause "New" or "Revised" License
2 stars 0 forks source link

A Better nixpkg for Stan? #3

Open idontgetoutmuch opened 6 years ago

idontgetoutmuch commented 6 years ago

With this https://github.com/NixOS/nixpkgs/pull/33076 I can now install http://mc-stan.org/users/interfaces/cmdstan with nix. However, the packagers of cmdstan have avoided any dependency problems by packaging up the source for dependencies also as sources within the cmdstan sources themselves e.g. sundials.

I now have the executable e.g. stanc but I don't have all the supporting files. To work round this I am doing

pwd
/Users/dom/Dropbox/Tidy/Economics

stanc bernoulli.stan --o=bernoulli.hpp 
Model name=bernoulli_model
Input file=bernoulli.stan
Output file=bernoulli.hpp
pwd
/nix/store/h7jbpf1mldd2xxg597vikk7kjz1pwl1f-cmdstan-2.17.1/opt/cmdstan

c++ -Wall -I . -isystem stan/lib/stan_math/lib/eigen_3.3.3 -isystem stan/lib/stan_math/lib/boost_1.64.0 -isystem stan/lib/stan_math/lib/cvodes_2.9.0/include -std=c++1y -DBOOST_RESULT_OF_USE_TR1 -DBOOST_NO_DECLTYPE -DBOOST_DISABLE_ASSERTS -DBOOST_PHOENIX_NO_VARIADIC_EXPRESSION -Wno-unused-function -Wno-uninitialized -I src -isystem stan/src -isystem stan/lib/stan_math/ -DFUSION_MAX_VECTOR_SIZE=12 -Wno-unused-local-typedefs -DEIGEN_NO_DEBUG -DNO_FPRINTF_OUTPUT -pipe  -c -O3 stan/src/stan/model/model_header.hpp -o /Users/dom/Dropbox/Tidy/Economics/model_header.hpp.gch

c++ -Wall -I . -isystem stan/lib/stan_math/lib/eigen_3.3.3 -isystem stan/lib/stan_math/lib/boost_1.64.0 -isystem stan/lib/stan_math/lib/cvodes_2.9.0/include -std=c++1y -DBOOST_RESULT_OF_USE_TR1 -DBOOST_NO_DECLTYPE -DBOOST_DISABLE_ASSERTS -DBOOST_PHOENIX_NO_VARIADIC_EXPRESSION -Wno-unused-function -Wno-uninitialized -I src -isystem stan/src -isystem stan/lib/stan_math/ -DFUSION_MAX_VECTOR_SIZE=12 -Wno-unused-local-typedefs -DEIGEN_NO_DEBUG -DNO_FPRINTF_OUTPUT -pipe    -O3 -o /Users/dom/Dropbox/Tidy/Economics/bernoulli src/cmdstan/main.cpp -include /Users/dom/Dropbox/Tidy/Economics/bernoulli.hpp stan/lib/stan_math/lib/cvodes_2.9.0/lib/libsundials_nvecserial.a stan/lib/stan_math/lib/cvodes_2.9.0/lib/libsundials_cvodes.a

Here's the same again but maybe easier to read?

c++ -Wall -I . -isystem stan/lib/stan_math/lib/eigen_3.3.3 -isystem \\
stan/lib/stan_math/lib/boost_1.64.0 -isystem \\
stan/lib/stan_math/lib/cvodes_2.9.0/include -std=c++1y -DBOOST_RESULT_OF_USE_TR1 \\
-DBOOST_NO_DECLTYPE -DBOOST_DISABLE_ASSERTS \\
-DBOOST_PHOENIX_NO_VARIADIC_EXPRESSION -Wno-unused-function -Wno-uninitialized \\
-I src -isystem stan/src -isystem stan/lib/stan_math/ \\
-DFUSION_MAX_VECTOR_SIZE=12 -Wno-unused-local-typedefs -DEIGEN_NO_DEBUG \\
-DNO_FPRINTF_OUTPUT -pipe -c -O3 stan/src/stan/model/model_header.hpp -o \\
/Users/dom/Dropbox/Tidy/Economics/model_header.hpp.gch

c++ -Wall -I . -isystem stan/lib/stan_math/lib/eigen_3.3.3 -isystem \\
stan/lib/stan_math/lib/boost_1.64.0 -isystem \\
stan/lib/stan_math/lib/cvodes_2.9.0/include -std=c++1y -DBOOST_RESULT_OF_USE_TR1 \\
-DBOOST_NO_DECLTYPE -DBOOST_DISABLE_ASSERTS \\
-DBOOST_PHOENIX_NO_VARIADIC_EXPRESSION -Wno-unused-function -Wno-uninitialized \\
-I src -isystem stan/src -isystem stan/lib/stan_math/ \\
-DFUSION_MAX_VECTOR_SIZE=12 -Wno-unused-local-typedefs -DEIGEN_NO_DEBUG \\
-DNO_FPRINTF_OUTPUT -pipe -O3 -o /Users/dom/Dropbox/Tidy/Economics/bernoulli \\
src/cmdstan/main.cpp -include /Users/dom/Dropbox/Tidy/Economics/bernoulli.hpp \\
stan/lib/stan_math/lib/cvodes_2.9.0/lib/libsundials_nvecserial.a \\
stan/lib/stan_math/lib/cvodes_2.9.0/lib/libsundials_cvodes.a
pwd
/Users/dom/Dropbox/Tidy/Economics

./bernoulli sample data file=bernoulli.data.R
method = sample (Default)
  sample
    num_samples = 1000 (Default)
    num_warmup = 1000 (Default)
    save_warmup = 0 (Default)
    thin = 1 (Default)
    adapt
      engaged = 1 (Default)
      gamma = 0.050000000000000003 (Default)
      delta = 0.80000000000000004 (Default)
      kappa = 0.75 (Default)
      t0 = 10 (Default)
      init_buffer = 75 (Default)
      term_buffer = 50 (Default)
      window = 25 (Default)
    algorithm = hmc (Default)
      hmc
        engine = nuts (Default)
          nuts
            max_depth = 10 (Default)
        metric = diag_e (Default)
        metric_file =  (Default)
        stepsize = 1 (Default)
        stepsize_jitter = 0 (Default)
id = 0 (Default)
data
  file = bernoulli.data.R
init = 2 (Default)
random
  seed = 2664532440
output
  file = output.csv (Default)
  diagnostic_file =  (Default)
  refresh = 100 (Default)

Gradient evaluation took 1.7e-05 seconds
1000 transitions using 10 leapfrog steps per transition would take 0.17 seconds.
Adjust your expectations accordingly!

Iteration:    1 / 2000 [  0%]  (Warmup)
Iteration:  100 / 2000 [  5%]  (Warmup)
Iteration:  200 / 2000 [ 10%]  (Warmup)
Iteration:  300 / 2000 [ 15%]  (Warmup)
Iteration:  400 / 2000 [ 20%]  (Warmup)
Iteration:  500 / 2000 [ 25%]  (Warmup)
Iteration:  600 / 2000 [ 30%]  (Warmup)
Iteration:  700 / 2000 [ 35%]  (Warmup)
Iteration:  800 / 2000 [ 40%]  (Warmup)
Iteration:  900 / 2000 [ 45%]  (Warmup)
Iteration: 1000 / 2000 [ 50%]  (Warmup)
Iteration: 1001 / 2000 [ 50%]  (Sampling)
Iteration: 1100 / 2000 [ 55%]  (Sampling)
Iteration: 1200 / 2000 [ 60%]  (Sampling)
Iteration: 1300 / 2000 [ 65%]  (Sampling)
Iteration: 1400 / 2000 [ 70%]  (Sampling)
Iteration: 1500 / 2000 [ 75%]  (Sampling)
Iteration: 1600 / 2000 [ 80%]  (Sampling)
Iteration: 1700 / 2000 [ 85%]  (Sampling)
Iteration: 1800 / 2000 [ 90%]  (Sampling)
Iteration: 1900 / 2000 [ 95%]  (Sampling)
Iteration: 2000 / 2000 [100%]  (Sampling)

 Elapsed Time: 0.016603 seconds (Warm-up)
               0.033538 seconds (Sampling)
               0.050141 seconds (Total)
idontgetoutmuch commented 6 years ago

This is unsatisfactory as I have to know about

/nix/store/h7jbpf1mldd2xxg597vikk7kjz1pwl1f-cmdstan-2.17.1