simulate_choices<-function(data,utility,setspp,bcoeff,decisiongroups=c(0,1),manipulations=list(),estimate,preprocess_function=NULL){#the part in dataset that needs to be repeated in each run
if(!is.null(preprocess_function)){
if(!is.function(preprocess_function)){
stop("`preprocess_function` must be a function.")
}else{
# Execute the user-supplied `preprocess_function`
prepro_data<-preprocess_function()
cat("\n Preprocess function has been executed.\n")
}
}else{
cat("\n No preprocess function provided. Proceeding without additional preprocessing.\n")
}
### unpack the bcoeff list so variables are accessible