Skip to content

Commit

Permalink
deploy: f27f0b2
Browse files Browse the repository at this point in the history
  • Loading branch information
andrjohns committed Dec 25, 2023
1 parent b6d56e1 commit 381aa19
Show file tree
Hide file tree
Showing 35 changed files with 22 additions and 66 deletions.
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ LinkingTo:
Rcpp,
RcppEigen,
BH,
RcppParallel
RcppParallel,
rapidjsonr
Suggests:
testthat (>= 3.0.0)
Config/testthat/edition: 3
22 changes: 11 additions & 11 deletions R/util.R
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
write_data <- function(Npars, finite_diff, lower_bounds, upper_bounds, bounds_types, data_filepath) {
no_bounds <- all(lower_bounds == -Inf) && all(upper_bounds == Inf)
dat_string <- paste0(
dat_string <- paste(
'{',
'"Npars":', Npars, ',',
'"finite_diff":', finite_diff, ',',
'"no_bounds":', as.integer(no_bounds), ',',
'"lower_bounds":[', paste0(lower_bounds, collapse = ','), '],',
'"upper_bounds":[', paste0(upper_bounds, collapse = ','), '],',
'"bounds_types":[', paste0(bounds_types, collapse = ','), ']',
'"Npars" : ', Npars, ',',
'"finite_diff" : ', finite_diff, ',',
'"no_bounds" : ', as.integer(no_bounds), ',',
'"lower_bounds" : [', paste0(lower_bounds, collapse = ','), '],',
'"upper_bounds" : [', paste0(upper_bounds, collapse = ','), '],',
'"bounds_types" : [', paste0(bounds_types, collapse = ','), ']',
'}'
)
cat(dat_string, file = data_filepath)
writeLines(dat_string, con = data_filepath)
invisible(NULL)
}

write_inits <- function(inits, init_filepath) {
dat_string <- paste0(
dat_string <- paste(
'{',
'"pars":[', paste0(inits, collapse = ','), ']',
'"pars" : [', paste0(inits, collapse = ','), ']',
'}'
)
cat(dat_string, file = init_filepath)
writeLines(dat_string, con = init_filepath)
invisible(NULL)
}

Expand Down
8 changes: 0 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,6 @@ provide a function for analytical calculation.

## Installation

You can install pre-built binaries using:

``` r
# we recommend running this is a fresh R session or restarting your current session
install.packages("StanEstimators",
repos = c("https://andrjohns.github.io/StanEstimators/", getOption("repos")))
```

Or you can build from source using:

``` r
Expand Down
4 changes: 2 additions & 2 deletions bin/macosx/big-sur-x86_64/contrib/4.3/PACKAGES
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: StanEstimators
Version: 0.0.0.9000
Imports: Rcpp, RcppParallel, posterior, methods, stats, callr
LinkingTo: Rcpp, RcppEigen, BH, RcppParallel
LinkingTo: Rcpp, RcppEigen, BH, RcppParallel, rapidjsonr
Suggests: testthat (>= 3.0.0)
License: MIT + file LICENSE
MD5sum: 82d792fb542890c43034a2255d57b0ef
MD5sum: 311eb91c5636f71f94276f5bf59e15ec
Binary file modified bin/macosx/big-sur-x86_64/contrib/4.3/PACKAGES.gz
Binary file not shown.
Binary file modified bin/macosx/big-sur-x86_64/contrib/4.3/PACKAGES.rds
Binary file not shown.
Binary file not shown.
4 changes: 2 additions & 2 deletions bin/macosx/contrib/4.2/PACKAGES
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: StanEstimators
Version: 0.0.0.9000
Imports: Rcpp, RcppParallel, posterior, methods, stats, callr
LinkingTo: Rcpp, RcppEigen, BH, RcppParallel
LinkingTo: Rcpp, RcppEigen, BH, RcppParallel, rapidjsonr
Suggests: testthat (>= 3.0.0)
License: MIT + file LICENSE
MD5sum: bf0926fec280104551e92f20cc56d549
MD5sum: 49499bc184ea8294a2a297bf9164403e
Binary file modified bin/macosx/contrib/4.2/PACKAGES.gz
Binary file not shown.
Binary file modified bin/macosx/contrib/4.2/PACKAGES.rds
Binary file not shown.
Binary file modified bin/macosx/contrib/4.2/StanEstimators_0.0.0.9000.tgz
Binary file not shown.
2 changes: 1 addition & 1 deletion bin/windows/contrib/4.2/PACKAGES
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: StanEstimators
Version: 0.0.0.9000
Imports: Rcpp, RcppParallel, posterior, methods, stats, callr
LinkingTo: Rcpp, RcppEigen, BH, RcppParallel
LinkingTo: Rcpp, RcppEigen, BH, RcppParallel, rapidjsonr
Suggests: testthat (>= 3.0.0)
License: MIT + file LICENSE
Archs: x64
Binary file modified bin/windows/contrib/4.2/PACKAGES.gz
Binary file not shown.
Binary file modified bin/windows/contrib/4.2/PACKAGES.rds
Binary file not shown.
Binary file modified bin/windows/contrib/4.2/StanEstimators_0.0.0.9000.zip
Binary file not shown.
2 changes: 1 addition & 1 deletion bin/windows/contrib/4.3/PACKAGES
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: StanEstimators
Version: 0.0.0.9000
Imports: Rcpp, RcppParallel, posterior, methods, stats, callr
LinkingTo: Rcpp, RcppEigen, BH, RcppParallel
LinkingTo: Rcpp, RcppEigen, BH, RcppParallel, rapidjsonr
Suggests: testthat (>= 3.0.0)
License: MIT + file LICENSE
Archs: x64
Binary file modified bin/windows/contrib/4.3/PACKAGES.gz
Binary file not shown.
Binary file modified bin/windows/contrib/4.3/PACKAGES.rds
Binary file not shown.
Binary file modified bin/windows/contrib/4.3/StanEstimators_0.0.0.9000.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
16 changes: 0 additions & 16 deletions inst/include/cmdstan/command.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ stan::math::mpi_cluster &get_mpi_cluster() {
#endif

int command(int argc, const char *argv[]) {
Rcpp::Rcout << "a" << std::endl;
stan::callbacks::stream_writer info(Rcpp::Rcout);
stan::callbacks::stream_writer err(Rcpp::Rcerr);
stan::callbacks::stream_logger logger(Rcpp::Rcout, Rcpp::Rcout, Rcpp::Rcout,
Expand Down Expand Up @@ -154,18 +153,15 @@ int command(int argc, const char *argv[]) {
throw std::invalid_argument(thread_msg.str());
}
}
Rcpp::Rcout << "b" << std::endl;
stan::math::init_threadpool_tbb(num_threads);

unsigned int num_chains = get_num_chains(parser);
check_file_config(parser);
Rcpp::Rcout << "c" << std::endl;

parser.print(info);
write_parallel_info(info);
write_opencl_device(info);
info();
Rcpp::Rcout << "d" << std::endl;

// General config for all methods
unsigned int id = get_arg_val<int_argument>(parser, "id");
Expand All @@ -175,21 +171,17 @@ int command(int argc, const char *argv[]) {
//////////////////////////////////////////////////
// Initialize Model //
//////////////////////////////////////////////////
Rcpp::Rcout << "e" << std::endl;
arg_seed *random_arg
= dynamic_cast<arg_seed *>(parser.arg("random")->arg("seed"));
unsigned int random_seed = random_arg->random_value();

std::string filename = get_arg_val<string_argument>(parser, "data", "file");

Rcpp::Rcout << "f" << std::endl;
std::shared_ptr<stan::io::var_context> var_context
= get_var_context(filename);

Rcpp::Rcout << "g" << std::endl;
stan::model::model_base &model
= new_model(*var_context, random_seed, &Rcpp::Rcout);
Rcpp::Rcout << "h" << std::endl;

// Setup callbacks
stan::callbacks::interrupt interrupt;
Expand All @@ -204,11 +196,9 @@ int command(int argc, const char *argv[]) {
std::vector<stan::callbacks::json_writer<std::ofstream>>
diagnostic_json_writers;

Rcpp::Rcout << "i" << std::endl;
init_callbacks(parser, sample_writers, diagnostic_csv_writers,
diagnostic_json_writers);

Rcpp::Rcout << "j" << std::endl;
// Setup initial parameter values - arg "init"
// arg is either filename or init radius value
std::string init = get_arg_val<string_argument>(parser, "init");
Expand All @@ -219,13 +209,10 @@ int command(int argc, const char *argv[]) {
} catch (const std::logic_error &e) {
}

Rcpp::Rcout << "k" << std::endl;
std::vector<std::shared_ptr<stan::io::var_context>> init_contexts
= get_vec_var_context(init, num_chains, id);
Rcpp::Rcout << "l" << std::endl;
std::vector<std::string> model_compile_info = model.model_compile_info();

Rcpp::Rcout << "m" << std::endl;
for (int i = 0; i < num_chains; ++i) {
write_stan(sample_writers[i]);
write_model(sample_writers[i], model.model_name());
Expand All @@ -238,7 +225,6 @@ int command(int argc, const char *argv[]) {
write_model(diagnostic_csv_writers[i], model.model_name());
parser.print(diagnostic_csv_writers[i]);
}
Rcpp::Rcout << "n" << std::endl;

//////////////////////////////////////////////////
// Invoke Services //
Expand Down Expand Up @@ -474,14 +460,12 @@ int command(int argc, const char *argv[]) {
tol_rel_grad, tol_param, num_iterations, save_iterations,
refresh, interrupt, logger, init_writers[0], sample_writers[0]);
} else {
Rcpp::Rcout << "o" << std::endl;
return_code
= stan::services::optimize::lbfgs<stan::model::model_base, false>(
model, *(init_contexts[0]), random_seed, id, init_radius,
history_size, init_alpha, tol_obj, tol_rel_obj, tol_grad,
tol_rel_grad, tol_param, num_iterations, save_iterations,
refresh, interrupt, logger, init_writers[0], sample_writers[0]);
Rcpp::Rcout << "p" << std::endl;
}
}
// ---- optimize end ---- //
Expand Down
8 changes: 1 addition & 7 deletions inst/include/cmdstan/command_helper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,19 +174,13 @@ using shared_context_ptr = std::shared_ptr<stan::io::var_context>;
* @param file A system file to read from
*/
inline shared_context_ptr get_var_context(const std::string &file) {
Rcpp::Rcout << "f1" << std::endl;
if (file.empty()) {
return std::make_shared<stan::io::empty_var_context>();
}
Rcpp::Rcout << "f2" << std::endl;
std::fstream stream(file.c_str(), std::fstream::in);
Rcpp::Rcout << "f3" << std::endl;
std::ifstream stream = safe_open(file);
if (get_suffix(file) == ".json") {
Rcpp::Rcout << "f4" << std::endl;
stan::json::json_data var_context(stream);
Rcpp::Rcout << "f5" << std::endl;
return std::make_shared<stan::json::json_data>(var_context);
Rcpp::Rcout << "f6" << std::endl;
}
Rcpp::Rcerr
<< "Warning: file '" << file
Expand Down
3 changes: 0 additions & 3 deletions inst/include/stan/io/json/json_data.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,8 @@ class json_data : public stan::io::var_context {
* @throws json_exception if data is not well-formed stan data declaration
*/
explicit json_data(std::istream &in) : vars_r_(), vars_i_() {
Rcpp::Rcout << "f41" << std::endl;
json_data_handler handler(vars_r_, vars_i_);
Rcpp::Rcout << "f42" << std::endl;
rapidjson_parse(in, handler);
Rcpp::Rcout << "f43" << std::endl;
}

/**
Expand Down
5 changes: 0 additions & 5 deletions inst/include/stan/io/json/json_data_handler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -457,17 +457,13 @@ class json_data_handler : public stan::json::json_handler {
* but we still need to track the number of tuple slots.
*/
void key(const std::string& key) {
Rcpp::Rcout << "f423.9.5.6.1.9.1" << std::endl;
if (event != meta_event::OBJ_OPEN) {
Rcpp::Rcout << "f423.9.5.6.1.9.2" << std::endl;
save_key_value_pair();
}
Rcpp::Rcout << "f423.9.5.6.1.9.3" << std::endl;
event = meta_event::KEY;
reset_values();
std::string outer = key_str();
key_stack.push_back(key);
Rcpp::Rcout << "f423.9.5.6.1.9.4" << std::endl;
if (key_stack.size() == 1) {
not_stan_var = !valid_varname(key);
}
Expand All @@ -485,7 +481,6 @@ class json_data_handler : public stan::json::json_handler {
tuple_slots_map[outer].slots_acc++;
}
}
Rcpp::Rcout << "f423.9.5.6.1.9.5" << std::endl;
std::string vname = key_str();
if (slot_types_map.count(vname) == 0) {
slot_types_map[vname] = meta_type::SCALAR;
Expand Down
5 changes: 0 additions & 5 deletions inst/include/stan/io/json/rapidjson_parser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,17 +109,13 @@ struct RapidJSONHandler {
*/
template <typename Handler>
void rapidjson_parse(std::istream &in, Handler &handler) {
Rcpp::Rcout << "f421" << std::endl;
rapidjson::Reader reader;
RapidJSONHandler<Handler> filter(handler);
rapidjson::IStreamWrapper isw(in);
Rcpp::Rcout << "f422" << std::endl;
handler.start_text();
Rcpp::Rcout << "f423" << std::endl;
if (!reader.Parse<rapidjson::kParseNanAndInfFlag
| rapidjson::kParseValidateEncodingFlag
| rapidjson::kParseFullPrecisionFlag>(isw, filter)) {
Rcpp::Rcout << "f424" << std::endl;
rapidjson::ParseErrorCode err = reader.GetParseErrorCode();
std::stringstream ss;
ss << "Error in JSON parsing " << std::endl
Expand All @@ -131,7 +127,6 @@ void rapidjson_parse(std::istream &in, Handler &handler) {
}
throw json_error(ss.str());
}
Rcpp::Rcout << "f425" << std::endl;
handler.end_text();
}
} // namespace json
Expand Down
1 change: 0 additions & 1 deletion inst/upgrade_headers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ mkdir -p include

cp -r cmdstan-$CMDSTAN_VER/src/cmdstan include/cmdstan
cp -r cmdstan-$CMDSTAN_VER/stan/src/stan include/stan
cp -r cmdstan-$CMDSTAN_VER/stan/lib/rapidjson*/* include/rapidjson
cp -r cmdstan-$CMDSTAN_VER/stan/lib/stan_math/stan/math include/stan/math
cp -r cmdstan-$CMDSTAN_VER/stan/lib/stan_math/stan/math.hpp include/stan/math.hpp
rm -rf include/stan/math/opencl
Expand Down
1 change: 0 additions & 1 deletion src/Makevars
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
PKG_CPPFLAGS = -I"../inst/include" -I"../inst/include/sundials" -D_REENTRANT -DSTAN_THREADS -DRCPP_PARALLEL_USE_TBB=1
PKG_CPPFLAGS += -DSTRICT_R_HEADERS -D_HAS_AUTO_PTR_ETC=0 -DEIGEN_PERMANENTLY_DISABLE_STUPID_WARNINGS
PKG_CPPFLAGS += $(shell "${R_HOME}/bin/Rscript" -e "RcppParallel::CxxFlags()" | tail -n 1)
PKG_CXXFLAGS += -g -O0
PKG_LIBS = $(shell "${R_HOME}/bin/Rscript" -e "RcppParallel::RcppParallelLibs()" | tail -n 1)
CXX_STD = CXX17
4 changes: 2 additions & 2 deletions src/contrib/PACKAGES
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: StanEstimators
Version: 0.0.0.9000
Imports: Rcpp, RcppParallel, posterior, methods, stats, callr
LinkingTo: Rcpp, RcppEigen, BH, RcppParallel
LinkingTo: Rcpp, RcppEigen, BH, RcppParallel, rapidjsonr
Suggests: testthat (>= 3.0.0)
License: MIT + file LICENSE
MD5sum: dc0f1abdc9e6bd828feb4d99eefaedb4
MD5sum: c6b4ffdce3d4b58366ac9439eee02b61
NeedsCompilation: yes
Binary file modified src/contrib/PACKAGES.gz
Binary file not shown.
Binary file modified src/contrib/PACKAGES.rds
Binary file not shown.
Binary file modified src/contrib/StanEstimators_0.0.0.9000.tar.gz
Binary file not shown.

0 comments on commit 381aa19

Please sign in to comment.