CmdStan output code... not making sense to me.

35 views
Skip to first unread message

Krzysztof Sakrejda

unread,
Apr 4, 2016, 11:14:14 AM4/4/16
to stan development mailing list
I'm working through CmdStan command.hpp and wondering why the output_stream is used both directly (as a stream, e.g, lines 338-348) as well as through the sample_writer. Is this just pre-writer callbacks cruft?

I'm talking about this code:
if (output_stream) {
std::vector<std::string> names;
names.push_back("lp__");
model.constrained_param_names(names, true, true);

(*output_stream) << names.at(0);
for (size_t i = 1; i < names.size(); ++i) {
(*output_stream) << "," << names.at(i);
}
(*output_stream) << std::endl;
}

I'm modifying a bunch of this kind of stuff on a fork but I can go back and do a pull request with the straight cleanup pieces if that's what's going on .

Krzysztof

Krzysztof Sakrejda

unread,
Apr 4, 2016, 12:50:14 PM4/4/16
to stan development mailing list
Also, is mcmc_writer supposed to be writing iterations to more than one of the streams? Is mcmc_writer how output is going to be done going forward with the interface_callbacks or is it also a leftover that we are hoping to factor out?

Krzysztof

Krzysztof Sakrejda

unread,
Apr 4, 2016, 3:57:25 PM4/4/16
to stan development mailing list
After some gratuitous hacking on command.hpp there's a version of CmdStan that will write to a postgres database, with the 'model file =' argument hijacked for the database URI string. If you happen to use this you can get around specifying the URI by setting enough environmental variables to make a bare command line 'psql' call open a connection.

https://github.com/sakrejda/cmdstan

I'm going to wait to make this pretty until there's some agreement on output format.

Krzysztof

Bob Carpenter

unread,
Apr 5, 2016, 2:24:34 PM4/5/16
to stan...@googlegroups.com
The goal's to only use the writers from the services
layer. What happens behind the services layer is still
up for grabs.

Daniel will know more about the current state of refactoring.

- Bob
> --
> You received this message because you are subscribed to the Google Groups "stan development mailing list" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to stan-dev+u...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Michael Betancourt

unread,
Apr 5, 2016, 3:53:56 PM4/5/16
to stan...@googlegroups.com
mcmc_writer collects the writer objects to simplify MCMC I/O.
In particular, it grabs the current state of the Markov chain, as
well as the state of the sampler, and writes to the various output
streams (info, error, diagnostic, samples, etc) as necessary. This
way the MCMC code largely doesn’t need to know about the
writers.

Krzysztof Sakrejda

unread,
Apr 5, 2016, 7:06:20 PM4/5/16
to stan development mailing list
Ok, good to know it's going to be around after the refactor. I was surprised this isn't shared among the algorithms since it's such basic functionality.
Reply all
Reply to author
Forward
0 new messages