Skip to content

Commit

Permalink
explicitly set nr_cpus=1 when using xgboost
Browse files Browse the repository at this point in the history
  • Loading branch information
Johannes Gussenbauer - QM committed Dec 4, 2023
1 parent 06c213d commit e8fa390
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
9 changes: 8 additions & 1 deletion R/simCategorical.R
Original file line number Diff line number Diff line change
Expand Up @@ -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, "))
Expand Down
6 changes: 6 additions & 0 deletions R/simContinuous.R
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
2 changes: 1 addition & 1 deletion src/calibPop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit e8fa390

Please sign in to comment.