mga_target_event::mga_target_event( const kep_toolbox::plantes::planet_ptr start, const kep_toolbox::planet::planet_ptr end, const kep_toolbox::epoch t_end, double T_max, bool discount_launcher ):base(6), m_start(start), m_end(end), m_t_end(t_end), m_T_max(T_max), m_discount_launcher(discount_launcher) { // We check that all planets have equal central body if (start->get_mu_central_body() != end->get_mu_central_body()) { pagmo_throw(value_error,"The planets do not all have the same mu_central_body"); } // We check that T_max is positive if (T_max <= 0) { pagmo_throw(value_error,"T_max must be larger than zero"); } // Now setting the problem bounds decision_vector lb(6,0.0), ub(6,1.0); lb[0] = 1.; lb[5] = 1e-5; ub[0] = T_max; ub[2] = 12000.0; ub[5] = 1-1e-5; set_bounds(lb,ub); }
static int __mo_dimension__(const pagmo::problem::base &original_problem, const pagmo::problem::con2mo::method_type method) { if( method > 2 || method < 0) { pagmo_throw(value_error, "The constrained to multi-objective method must be set to OBJ_CSTRS for Coello type constrained to multi-objective, to OBJ_CSTRSVIO for COMOGO type constrained to nobj+1 objectives problem or to OBJ_EQVIO_INEQVIO for COMOGO type constrained to nobj+2 objectives problem."); } if(original_problem.get_c_dimension() <= 0){ pagmo_throw(value_error,"The original problem has no constraints."); } switch(method) { case pagmo::problem::con2mo::OBJ_CSTRS: { return original_problem.get_f_dimension() + original_problem.get_c_dimension(); break; } case pagmo::problem::con2mo::OBJ_CSTRSVIO: { return original_problem.get_f_dimension() + 1; break; } case pagmo::problem::con2mo::OBJ_EQVIO_INEQVIO: { return original_problem.get_f_dimension() + 2; break; } default: { return 0.; break; } } }
/** * Constructor using std::vector (for python exposition purposes) * * @param[in] p base::problem to be rotated * @param[in] rotation std::vector<std::vector<double> > expressing the problem rotation * * @see problem::base constructors. */ rotated::rotated(const base &p, const std::vector<std::vector<double> > &rotation): base_meta( p, p.get_dimension(), p.get_i_dimension(), p.get_f_dimension(), p.get_c_dimension(), p.get_ic_dimension(), p.get_c_tol()), m_Rotate(),m_normalize_translation(), m_normalize_scale() { if(!(rotation.size()==get_dimension())){ pagmo_throw(value_error,"The input matrix dimensions seem incorrect"); } if(p.get_i_dimension()>0){ pagmo_throw(value_error,"Input problem has an integer dimension. Cannot rotate it."); } m_Rotate.resize(rotation.size(),rotation.size()); for (base::size_type i = 0; i < rotation.size(); ++i) { if(!(rotation.size()==rotation[i].size())){ pagmo_throw(value_error,"The input matrix seems not to be square"); } for (base::size_type j = 0; j < rotation[i].size(); ++j) { m_Rotate(i,j) = rotation[i][j]; } } m_InvRotate = m_Rotate.transpose(); Eigen::MatrixXd check = m_InvRotate * m_Rotate; if(!check.isIdentity(1e-5)){ pagmo_throw(value_error,"The input matrix seems not to be orthonormal (to a tolerance of 1e-5)"); } configure_new_bounds(); }
// Write into retval the gradient of the continuous part of the objective function of prob calculated in input. void gsl_gradient::objfun_numdiff_central(gsl_vector *retval, const problem::base &prob, const decision_vector &input, const double &step_size) { if (input.size() != prob.get_dimension()) { pagmo_throw(value_error,"invalid input vector dimension in numerical differentiation of the objective function"); } if (prob.get_f_dimension() != 1) { pagmo_throw(value_error,"numerical differentiation of the objective function cannot work on multi-objective problems"); } // Size of the continuous part of the problem. const problem::base::size_type cont_size = prob.get_dimension() - prob.get_i_dimension(); // Structure to pass data to the wrapper. objfun_numdiff_wrapper_params pars; pars.x = input; pars.f.resize(1); pars.prob = &prob; // GSL function. gsl_function F; F.function = &objfun_numdiff_wrapper; F.params = (void *)&pars; double result, abserr; // Numerical differentiation component by component. for (problem::base::size_type i = 0; i < cont_size; ++i) { pars.coord = i; gsl_deriv_central(&F,input[i],step_size,&result,&abserr); gsl_vector_set(retval,i,result); } }
cstrs_self_adaptive::cstrs_self_adaptive(const base &problem): base_meta( problem, problem.get_dimension(), problem.get_i_dimension(), problem.get_f_dimension(), 0, 0, std::vector<double>()), m_apply_penalty_1(false), m_scaling_factor(0.0), m_c_scaling(problem.get_c_dimension(),0.0), m_f_hat_down(problem.get_f_dimension(),0.0), m_f_hat_up(problem.get_f_dimension(),0.0), m_f_hat_round(problem.get_f_dimension(),0.0), m_i_hat_down(0.0), m_i_hat_up(0.0), m_i_hat_round(0.0), m_map_fitness(), m_map_constraint(), m_decision_vector_hash() { population pop(*m_original_problem,0); if(m_original_problem->get_c_dimension() <= 0){ pagmo_throw(value_error,"The original problem has no constraints."); } // check that the dimension of the problem is 1 if (m_original_problem->get_f_dimension() != 1) { pagmo_throw(value_error,"The original fitness dimension of the problem must be one, multi objective problems can't be handled with self adaptive meta problem."); } update_penalty_coeff(pop); }
/** * Constructor of antibodies meta-problem * * Note: This problem is not intended to be used by itself. Instead use the * cstrs_immune_system algorithm if you want to solve constrained problems. * * @param[in] problem base::problem to be used to set up the boundaries * @param[in] method method_type to used for the distance computation. * Two posssibililties are available: HAMMING, EUCLIDEAN. */ antibodies_problem::antibodies_problem(const base &problem, const algorithm::cstrs_immune_system::distance_method_type method): base((int)problem.get_dimension(), problem.get_i_dimension(), problem.get_f_dimension(), 0, 0, 0.), m_original_problem(problem.clone()), m_pop_antigens(), m_method(method) { if(m_original_problem->get_c_dimension() <= 0){ pagmo_throw(value_error,"The original problem has no constraints."); } // check that the dimension of the problem is 1 if(m_original_problem->get_f_dimension() != 1) { pagmo_throw(value_error,"The original fitness dimension of the problem must be one, multi objective problems can't be handled with co-evolution meta problem."); } // encoding for hamming distance m_bit_encoding = 25; m_max_encoding_integer = int(std::pow(2., m_bit_encoding)); set_bounds(m_original_problem->get_lb(),m_original_problem->get_ub()); }
/** * Initialises the MPI environment with MPI_Init_thread. pagmo::mpi_environment objects should be created only in the main * thread of execution. * * @throws std::runtime_error if another instance of this class has already been created, * or if the MPI implementation does not support at least the MPI_THREAD_SERIALIZED thread level and this is the root node, * or if the world size is not at least 2. */ mpi_environment::mpi_environment() { if (m_initialised) { pagmo_throw(std::runtime_error,"cannot re-initialise the MPI environment"); } m_initialised = true; int thread_level_provided; MPI_Init_thread(NULL,NULL,MPI_THREAD_MULTIPLE,&thread_level_provided); if (thread_level_provided >= MPI_THREAD_MULTIPLE) { m_multithread = true; } if (get_rank()) { // If this is a slave, it will have to stop here, listen for jobs, execute them, and exit() // when signalled to do so. listen(); } // If this is the root node, it will need to be able to call MPI from multiple threads. if (thread_level_provided < MPI_THREAD_SERIALIZED && get_rank() == 0) { pagmo_throw(std::runtime_error,"the master node must support at least the MPI_THREAD_SERIALIZED thread level"); } // World sizes less than 2 are not allowed. if (get_size() < 2) { pagmo_throw(std::runtime_error,"the size of the MPI world must be at least 2"); } }
ipopt::ipopt( const int &max_iter, const double &constr_viol_tol, const double &dual_inf_tol, const double &compl_inf_tol, const bool &nlp_scaling_method, const double &obj_scaling_factor, const double &mu_init) : m_max_iter(max_iter),m_constr_viol_tol(constr_viol_tol), m_dual_inf_tol(dual_inf_tol), m_compl_inf_tol(compl_inf_tol), m_nlp_scaling_method(nlp_scaling_method), m_obj_scaling_factor(obj_scaling_factor), m_mu_init(mu_init) { if (max_iter < 0) { pagmo_throw(value_error,"number of maximum iterations cannot be negative"); } if (constr_viol_tol < 0) { pagmo_throw(value_error,"tolerance is not in ]0,1["); } if (dual_inf_tol < 0) { pagmo_throw(value_error,"obj_tol is not in ]0,1["); } if (compl_inf_tol < 0) { pagmo_throw(value_error,"obj_tol is not in ]0,1["); } if (mu_init <= 0) { pagmo_throw(value_error,"mu_init is not in ]0, inf["); } }
/** * Allows to specify in detail all the parameters of the algorithm. * * @param[in] iter number of iterations. * @param[in] limit number of tries after which a source of food is dropped if not improved * @throws value_error if number of iterations or limit are negative */ bee_colony::bee_colony(int iter, int limit):base(),m_iter(iter), m_limit(limit) { if (iter < 0) { pagmo_throw(value_error,"number of iterations must be nonnegative"); } if (limit < 0) { pagmo_throw(value_error,"limit value must be nonnegative"); } }
/** * Allows to specify all the parameters needed to initialise a GSL minimiser without derivatives, as specified in the GSL documentation. * Will fail if max_iter is negative or if at least one of the other parameters is negative. * * @param[in] max_iter maximum number of iterations the algorithm will be allowed to perform. * @param[in] tol desired tolerance in the localisation of the minimum. * @param[in] step_size initial step size for the simplex. */ gsl_derivative_free::gsl_derivative_free(int max_iter, const double &tol, const double &step_size): base_gsl(),m_max_iter(boost::numeric_cast<std::size_t>(max_iter)),m_tol(tol),m_step_size(step_size) { if (step_size <= 0) { pagmo_throw(value_error,"step size must be positive"); } if (tol <= 0) { pagmo_throw(value_error,"tolerance must be positive"); } }
/** * Allows to specify in detail all the parameters of the algorithm. * * @param[in] gen Number of generations to evolve. * @param[in] ri Probability of performing a random invert (mutation probability) */ inverover::inverover(int gen, double ri, initialization_type ini_type) :base(),m_gen(gen),m_ri(ri),m_ini_type(ini_type) { if (gen < 0) { pagmo_throw(value_error,"number of generations must be nonnegative"); } if (ri > 1 || ri < 0) { pagmo_throw(value_error,"random invert probability must be in the [0,1] range"); } }
/** * Build a BA network with clustering mechanism applied. The initial kernel has size m0 and the elements * being inserted after the construction of the kernel is completed are connected randomly to a maximum of m nodes. These nodes * are then connected to eachother with probability p. * Will fail if m0 < 2, if m < 1 or if m > m0 or if p < 0 or p > 1 * * @param[in] m0 size of the kernel * @param[in] m number of random connections to be established when a new node is added. * @param[in] p probability that a connection is established between two nodes that are adjacent to a new node. */ clustered_ba::clustered_ba(int m0, int m, double p): m_m0(boost::numeric_cast<std::size_t>(m0)),m_m(boost::numeric_cast<std::size_t>(m)), m_p(double(p)), m_drng(rng_generator::get<rng_double>()),m_urng(rng_generator::get<rng_uint32>()) { if (m0 < 2 || m < 1 || m > m0) { pagmo_throw(value_error,"the value of m and m0 must be at least 1 and 2, and m must not be greater than m0"); } if(p < 0 || p > 1) { pagmo_throw(value_error,"the value of p must be between 0 and 1"); } }
/** * Constructs a global optimization problem (box-bounded, continuous) representing an interplanetary trajectory modelled * as a Multiple Gravity Assist trajectory that allows one only Deep Space Manouvre between each leg. * * @param[in] seq std::vector of kep_toolbox::planet_ptr containing the encounter sequence for the trajectoty (including the initial planet) * @param[in] t0_l kep_toolbox::epoch representing the lower bound for the launch epoch * @param[in] t0_u kep_toolbox::epoch representing the upper bound for the launch epoch * @param[in] tof time-of-flight vector containing lower and upper bounds (in days) for the various legs time of flights * @param[in] Tmax maximum time of flight * @param[in] Dmin minimum distance from Jupiter (for radiation protection) * * @throws value_error if the planets in seq do not all have the same central body gravitational constant * @throws value_error if tof has a size different from seq.size() */ mga_incipit_cstrs::mga_incipit_cstrs( const std::vector<kep_toolbox::planets::planet_ptr> seq, const kep_toolbox::epoch t0_l, const kep_toolbox::epoch t0_u, const std::vector<std::vector<double> > tof, double Tmax, double Dmin) : base(4*seq.size(),0,1,2,2,1E-3), m_tof(tof), m_tmax(Tmax), m_dmin(Dmin) { // We check that all planets have equal central body std::vector<double> mus(seq.size()); for (std::vector<kep_toolbox::planets::planet_ptr>::size_type i = 0; i< seq.size(); ++i) { mus[i] = seq[i]->get_mu_central_body(); } if ((unsigned int)std::count(mus.begin(), mus.end(), mus[0]) != mus.size()) { pagmo_throw(value_error,"The planets do not all have the same mu_central_body"); } // We check the consistency of the time of flights if (tof.size() != seq.size()) { pagmo_throw(value_error,"The time-of-flight vector (tof) has the wrong length"); } for (size_t i = 0; i < tof.size(); ++i) { if (tof[i].size()!=2) pagmo_throw(value_error,"Each element of the time-of-flight vector (tof) needs to have dimension 2 (lower and upper bound)"); } // Filling in the planetary sequence data member. This requires to construct the polymorphic planets via their clone method for (std::vector<kep_toolbox::planets::planet_ptr>::size_type i = 0; i < seq.size(); ++i) { m_seq.push_back(seq[i]->clone()); } // Now setting the problem bounds size_type dim(4*m_tof.size()); decision_vector lb(dim), ub(dim); // First leg lb[0] = t0_l.mjd2000(); ub[0] = t0_u.mjd2000(); lb[1] = 0; lb[2] = 0; ub[1] = 1; ub[2] = 1; lb[3] = m_tof[0][0]; ub[3] = m_tof[0][1]; // Successive legs for (std::vector<kep_toolbox::planets::planet_ptr>::size_type i = 1; i < m_tof.size(); ++i) { lb[4*i] = - 2 * boost::math::constants::pi<double>(); ub[4*i] = 2 * boost::math::constants::pi<double>(); lb[4*i+1] = 1.1; ub[4*i+1] = 30; lb[4*i+2] = 1e-5; ub[4*i+2] = 1-1e-5; lb[4*i+3] = m_tof[i][0]; ub[4*i+3] = m_tof[i][1]; } // Adjusting the minimum and maximum allowed fly-by rp to the one defined in the kep_toolbox::planet class for (std::vector<kep_toolbox::planets::planet_ptr>::size_type i = 0; i < m_tof.size()-1; ++i) { lb[4*i+5] = m_seq[i]->get_safe_radius() / m_seq[i]->get_radius(); ub[4*i+5] = (m_seq[i]->get_radius() + 2000000) / m_seq[i]->get_radius(); //from gtoc6 problem description } set_bounds(lb,ub); }
/** * Allows to specify in detail the parameters of the algorithm. * * @param[in] iterations number of iterations. * @param[in] phmcr rate of choosing from memory. * @param[in] ppar_min minimum pitch adjustment rate. * @param[in] ppar_max maximum pitch adjustment rate. * @param[in] bw_min minimum distance bandwidth. * @param[in] bw_max maximum distance bandwidth. * @throws value_error if phmcr is not in the ]0,1[ interval, ppar min/max are not in the ]0,1[ interval, * min/max quantities are less than/greater than max/min quantities. */ ihs::ihs(int iterations, const double &phmcr, const double &ppar_min, const double &ppar_max, const double &bw_min, const double &bw_max): base(),m_gen(boost::numeric_cast<std::size_t>(iterations)),m_phmcr(phmcr),m_ppar_min(ppar_min),m_ppar_max(ppar_max),m_bw_min(bw_min),m_bw_max(bw_max) { if (phmcr > 1 || phmcr < 0 || ppar_min > 1 || ppar_min < 0 || ppar_max > 1 || ppar_max < 0) { pagmo_throw(value_error,"probability of choosing from memory and pitch adjustment rates must be in the [0,1] range"); } if (ppar_min > ppar_max) { pagmo_throw(value_error,"minimum pitch adjustment rate must not be greater than maximum pitch adjustment rate"); } if (bw_min <= 0 || bw_max < bw_min) { pagmo_throw(value_error,"bandwidth values must be positive, and minimum bandwidth must not be greater than maximum bandwidth"); } }
/** * Allows to specify some of the parameters of the SNOPT solver. * * @param[in] major Number of major iterations (refer to SNOPT manual). * @param[in] feas Feasibility tolerance (refer to SNOPT manual). * @param[in] opt Optimality tolerance (refer to SNOPT manual). * @throws value_error if major is not positive, and feas,opt are not in \f$]0,1[\f$ */ snopt::snopt(const int major,const double feas, const double opt) : m_major(major),m_feas(feas),m_opt(opt), m_file_out(false) { if (major < 0) { pagmo_throw(value_error,"number of major iterations cannot be negative"); } if (feas < 0 || feas > 1) { pagmo_throw(value_error,"feasibility cireria "); } if (opt < 0 || opt > 1) { pagmo_throw(value_error,"number of major iterations cannot be negative"); } }
/** * Verifies whether basic requirements are met for the initial set of points. * * @throws value_error if point size is empty or when the dimensions among the points differ */ void hypervolume::verify_after_construct() const { if ( m_points.size() == 0 ) { pagmo_throw(value_error, "Point set cannot be empty."); } fitness_vector::size_type f_dim = m_points[0].size(); if (f_dim <= 1) { pagmo_throw(value_error, "Points of dimension > 1 required."); } for (std::vector<fitness_vector>::size_type idx = 1 ; idx < m_points.size() ; ++idx) { if ( m_points[idx].size() != f_dim ) { pagmo_throw(value_error, "All point set dimensions must be equal."); } } }
/** * Remove the edge connecting n to m. Will fail if are_adjacent() returns false. * * @param[in] n index of the first vertex. * @param[in] m index of the second vertex. */ void base::remove_edge(const vertices_size_type &n, const vertices_size_type &m) { if (!are_adjacent(n,m)) { pagmo_throw(value_error,"cannot remove edge, vertices are not connected"); } boost::remove_edge(boost::vertex(n,m_graph),boost::vertex(m,m_graph),m_graph); }
cs::cs(const int& max_eval, const double &stop_range, const double &start_range, const double &reduction_coeff) :base(),m_stop_range(stop_range),m_start_range(start_range),m_reduction_coeff(reduction_coeff),m_max_eval(max_eval) { if (reduction_coeff >= 1 || reduction_coeff <=0) { pagmo_throw(value_error,"the reduction coefficient must be smaller than one and positive, You Fool!!"); } if (start_range > 1 || start_range <= 0) { pagmo_throw(value_error,"the starting range must be smaller than one and positive, You Fool!!"); } if (stop_range > 1 || stop_range <= 0 || stop_range>start_range) { pagmo_throw(value_error,"the minimum range must be smaller than one, positive and smaller than the starting range, (o44portebat studuisse)!!"); } if (max_eval < 0) { pagmo_throw(value_error,"Maximum number of function evaluations needs to be positive"); } }
void antibodies_problem::set_antigens(const std::vector<decision_vector> &pop_antigens) { if(pop_antigens.size() == 0) { pagmo_throw(value_error,"The size of the antigens population must be different from 0."); } m_pop_antigens = pop_antigens; }
/** * Allows to specify in detail all the parameters of the algorithm. * * @param[in] algorithm pagmo::algorithm for the multistarts * @param[in] starts number of multistarts * @throws value_error if starts is negative */ ms::ms(const base &algorithm, int starts):base(),m_starts(starts) { m_algorithm = algorithm.clone(); if (starts < 0) { pagmo_throw(value_error,"number of multistarts needs to be larger than zero"); } }
/** * Verifies whether reference point and the hypervolume method meet certain criteria. * * @param[in] r_point fitness vector describing the reference point * * @throws value_error if reference point's and point set dimension do not agree */ void hypervolume::verify_before_compute(const fitness_vector &r_point, hv_algorithm::base_ptr hv_algorithm) const { if ( m_points[0].size() != r_point.size() ) { pagmo_throw(value_error, "Point set dimensions and reference point dimension must be equal."); } hv_algorithm->verify_before_compute(m_points, r_point); }
static int __check__(int N){ if (N < 8 || (N) % 4) { pagmo_throw(value_error,"problem dimension N needs to be at least 8 and a multiple of 4"); } return N; }
/** * Configure parameters for the noise distribution * * param[in] param_first Mean of the Gaussian noise / Lower bound of the uniform noise * param[in] param_second Standard deviation of the Gaussian noise / Upper bound of the uniform noise * */ void noisy::set_noise_param(double param_first, double param_second) { if(m_noise_type == UNIFORM && param_first > param_second){ pagmo_throw(value_error, "Bounds specified for the uniform noise are not valid."); } m_param_first = param_first; m_param_second = param_second; }
/** * Verifies whether given algorithm suits the requested data. * * @param[in] points vector of points containing the d dimensional points for which we compute the hypervolume * @param[in] r_point reference point for the vector of points * * @throws value_error when trying to compute the hypervolume for the dimension other than 3 or non-maximal reference point */ void hv3d::verify_before_compute(const std::vector<fitness_vector> &points, const fitness_vector &r_point) const { if (r_point.size() != 3) { pagmo_throw(value_error, "Algorithm hv3d works only for 3-dimensional cases"); } base::assert_minimisation(points, r_point); }
/** * This setter changes the problem bounds as to define a minimum and a maximum allowed total time of flight * * @param[in] tof vector of times of flight */ void mga_incipit_cstrs::set_tof(const std::vector<std::vector<double> >& tof) { if (tof.size() != (m_seq.size())) { pagmo_throw(value_error,"The time-of-flight vector (tof) has the wrong length"); } m_tof = tof; for (size_t i=0; i< m_seq.size(); ++i) { set_bounds(3+4*i,tof[i][0],tof[i][1]); } }
/** * Allows to specify all the parameters needed to initialise a GSL minimiser with derivatives, as specified in the GSL documentation. * Will fail if max_iter is negative or if at least one of the other parameters is negative. * * @param[in] max_iter maximum number of iterations allowed. * @param[in] grad_tol tolerance when testing the norm of the gradient as stopping criterion. * @param[in] numdiff_step_size step size for the numerical computation of the gradient. * @param[in] tol accuracy of the line minimisation. * @param[in] step_size size of the first trial step. */ gsl_gradient::gsl_gradient(int max_iter, const double &grad_tol, const double &numdiff_step_size, const double &step_size, const double &tol): base_gsl(), m_max_iter(boost::numeric_cast<std::size_t>(max_iter)),m_grad_tol(grad_tol),m_numdiff_step_size(numdiff_step_size), m_step_size(step_size),m_tol(tol) { if (step_size <= 0) { pagmo_throw(value_error,"step size must be positive"); } if (tol <= 0) { pagmo_throw(value_error,"tolerance must be positive"); } if (numdiff_step_size <= 0) { pagmo_throw(value_error,"step size for numerical differentiation must be positive"); } if (grad_tol <= 0) { pagmo_throw(value_error,"gradient tolerance must be positive"); } }
/** * Will construct an n dimensional Levy problem. * * @param[in] n integer dimension of the problem. * * @see problem::base constructors. */ levy5::levy5(int n):base(n) { if (n < 2) { pagmo_throw(value_error,"the Levy5 problem's dimension must be at least 2"); } // Set bounds. set_lb(-100); set_ub(100); }
double worhp::get_param(const std::string name) const { // We check that the key exists auto el = m_param_map.find(name); if (el == m_param_map.end()) { pagmo_throw(value_error,"Unknown parameter name, cannot get it."); } // We make a copy for const correctness std::map<std::string, int> map_copy = m_param_map; double retval = 0; // According to the input we return the appropriate parameter switch ( map_copy[name] ) { case 1: retval = m_params.AcceptTolFeas; break; case 2: retval = m_params.AcceptTolOpti; break; case 3: retval = m_params.TolFeas; break; case 4: retval = m_params.TolComp; break; case 5: retval = m_params.TolOpti; break; case 6: retval = m_params.NLPprint; break; case 7: retval = m_params.InitialLMest; break; case 8: retval = m_params.MaxIter; break; default: pagmo_throw(value_error,"You should not be here!!"); } return retval; }
/** * Constructs a co-evolution adaptive algorithm * * @param[in] original_algo pagmo::algorithm to use as 'original' optimization method * @param[in] original_algo_penalties pagmo::algorithm to use as 'original' optimization method * for population representing the penaltiesweights * @param[in] pop_penalties_size population size for the penalty encoding population. * @param[in] gen number of generations. * @param[in] method the method used for the population 2. * Three possibililties are available: SIMPLE, SPLIT_NEQ_EQ and SPLIT_CONSTRAINTS. * The simple one is the original version of the Coello/He implementation. The SPLIT_NEQ_EQ, * splits the equalities and inequalities constraints in two different sets for the * penalty weigths, containing respectively inequalities and equalities weigths. The * SPLIT_CONSTRAINTS splits the constraints in M set of weigths with M the number of * constraints. * @param[in] pen_lower_bound the lower boundary used for penalty. * @param[in] pen_upper_bound the upper boundary used for penalty. * @param[in] ftol stopping criteria on the f tolerance. * @param[in] xtol stopping criteria on the x tolerance. * @throws value_error if stop is negative */ cstrs_co_evolution::cstrs_co_evolution(const base &original_algo, const base &original_algo_penalties, int pop_penalties_size, int gen,method_type method, double pen_lower_bound, double pen_upper_bound, double ftol, double xtol): base(),m_original_algo(original_algo.clone()), m_original_algo_penalties(original_algo_penalties.clone()), m_gen(gen),m_pop_penalties_size(pop_penalties_size),m_method(method), m_pen_lower_bound(pen_lower_bound),m_pen_upper_bound(pen_upper_bound),m_ftol(ftol),m_xtol(xtol) { if(gen < 0) { pagmo_throw(value_error,"number of generations must be nonnegative"); } if(pop_penalties_size <= 0) { pagmo_throw(value_error,"the population size of the penalty weights must be greater than 0"); } if(pen_lower_bound>=pen_upper_bound){ pagmo_throw(value_error,"Lower Bound of penalty coefficients must be smaller than Upper Bound"); } }
/** * Allows to specify in detail all the parameters of the algorithm. * * @param[in] niter number of total iterations. * @param[in] Ts starting temperature * @param[in] Tf final temperature * @param[in] niterT * @param[in] niterR * @param[in] range * @throws value_error niter is non positive, Ts is greater than Tf, Ts is non positive, Tf is non positive, * niterT or niterR are negative, range is not in the [0,1] interval */ sa_corana::sa_corana(int niter, const double &Ts, const double &Tf, int niterT, int niterR, const double &range): base(),m_niter(niter),m_Ts(Ts),m_Tf(Tf),m_step_adj(niterT),m_bin_size(niterR),m_range(range) { if (niter < 0) { pagmo_throw(value_error,"number of iterations must be nonnegative"); } if (Ts <= 0 || Tf <= 0 || Ts <= Tf) { pagmo_throw(value_error,"temperatures must be positive and Ts must be greater than Tf"); } if (niterT < 0) { pagmo_throw(value_error,"number of iteration before adjusting the temperature must be positive"); } if (niterR < 0) { pagmo_throw(value_error,"number of iteration before adjusting the neighbourhood must be positive"); } if (range < 0 || range >1) { pagmo_throw(value_error,"Initial range must be between 0 and 1"); } }