From e8fa3909eaad03eb3d1349d330916bba2f8fe1b6 Mon Sep 17 00:00:00 2001 From: Johannes Gussenbauer - QM Date: Mon, 4 Dec 2023 12:57:34 +0100 Subject: [PATCH] explicitly set nr_cpus=1 when using xgboost --- R/simCategorical.R | 9 ++++++++- R/simContinuous.R | 6 ++++++ src/calibPop.cpp | 2 +- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/R/simCategorical.R b/R/simCategorical.R index 7cac9fe..789452c 100644 --- a/R/simCategorical.R +++ b/R/simCategorical.R @@ -555,7 +555,14 @@ simCategorical <- function(simPopObj, additional, }else{ xgb_verbose <- 0 } - + + # set nr_cpus=1 for xgboost + if(verbose){ + cat("\n Setting nr_cpus=1 when using xgboost\n") + } + nr_cpus <- 1 + + if(!dataS@ispopulation){ weight_str <- paste0("as.numeric(dataSample$", dataS@weight, ")") # xgb_weight <- paste0(", info = list(\"weight\" = (",weight_str," - min(", weight_str, ")) diff --git a/R/simContinuous.R b/R/simContinuous.R index aea0b21..18a0bf8 100755 --- a/R/simContinuous.R +++ b/R/simContinuous.R @@ -1265,6 +1265,12 @@ simContinuous <- function(simPopObj, additional = "netIncome", xgb_verbose <- 0 } + # set nr_cpus=1 for xgboost + if(verbose){ + cat("\n Setting nr_cpus=1 when using xgboost\n") + } + nr_cpus <- 1 + if(TRUE){ xgb_weight <- paste0(", info = list(\"weight\" = as.numeric(dataSample$", weight, "))") }else{ diff --git a/src/calibPop.cpp b/src/calibPop.cpp index 327e31d..a434043 100644 --- a/src/calibPop.cpp +++ b/src/calibPop.cpp @@ -195,7 +195,7 @@ IntegerVector calibPop_work(IntegerMatrix inp, NumericVector totals, IntegerVect cooldown = cooldown + 1; if ( (obj_new <= eps) | (cooldown == 500) ) { if ( verb ) { - Rprintf("Required precision reached!\nValue of objective function: %g (required precision=%g)\nNumber of iterations=%g", obj_new, eps,counter_all); + Rprintf("Required precision reached!\nValue of objective function: %g (required precision=%g)\nNumber of iterations=%f", obj_new, eps,counter_all); } break; }