Advertisement
msfz751

pas a list from R to C++

Aug 16th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
R 2.12 KB | None | 0 0
  1. // [[Rcpp::export]]
  2. Rcpp::List DEoptim_impl(const arma::colvec & minbound,                  // user-defined lower bounds
  3.                         const arma::colvec & maxbound,                  // user-defined upper bounds
  4.                         SEXP fnS,                                       // function to be optimized, either R or C++
  5.                         const Rcpp::List & control,                     // parameters
  6.                         SEXP rhoS) {                                    // optional environment
  7.    
  8.     double VTR           = Rcpp::as<double>(control["VTR"]);            // value to reach
  9.     int i_strategy       = Rcpp::as<int>(control["strategy"]);          // chooses DE-strategy
  10.     int i_itermax        = Rcpp::as<int>(control["itermax"]);           // Maximum number of generations
  11.     long l_nfeval        = 0;                                           // nb of function evals (NOT passed in)
  12.     int i_D              = Rcpp::as<int>(control["npar"]);              // Dimension of parameter vector
  13.     int i_NP             = Rcpp::as<int>(control["NP"]);                // Number of population members
  14.     int i_storepopfrom   = Rcpp::as<int>(control["storepopfrom"]) - 1;  // When to start storing populations
  15.     int i_storepopfreq   = Rcpp::as<int>(control["storepopfreq"]);      // How often to store populations
  16.     int i_specinitialpop = Rcpp::as<int>(control["specinitialpop"]);    // User-defined inital population
  17.     double f_weight      = Rcpp::as<double>(control["F"]);              // stepsize
  18.     double f_cross       = Rcpp::as<double>(control["CR"]);             // crossover probability
  19.     int i_bs_flag        = Rcpp::as<int>(control["bs"]);                // Best of parent and child
  20.     int i_trace          = Rcpp::as<int>(control["trace"]);             // Print progress?
  21.     int i_check_winner   = Rcpp::as<int>(control["checkWinner"]);       // Re-evaluate best parameter vector?
  22.     int i_av_winner      = Rcpp::as<int>(control["avWinner"]);          // Average
  23.     double i_pPct        = Rcpp::as<double>(control["p"]);              // p to define the top 100p% best solutions
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement