本文整理汇总了C++中base::clone方法的典型用法代码示例。如果您正苦于以下问题:C++ base::clone方法的具体用法?C++ base::clone怎么用?C++ base::clone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类base
的用法示例。
在下文中一共展示了base::clone方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
/**
* 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");
}
}
示例2: int
/**
* 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());
}
示例3:
/**
* 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");
}
}
示例4: base
/**
* Constructs a CORE constraints handling algorithm
*
* @param[in] original_algo pagmo::algorithm to use as 'original' optimization method. Its number of
* generations should be set to 1.
* @param[in] repair_algo pagmo::algorithm to use as 'repairing' optimization algorithm. It should be
* able to deal with population of size 1.
* @param[in] gen number of generations.
* @param[in] repair_frequency The infeasible are repaired at each repair frequency generations.
* @param[in] repair_ratio It the repair ratio is the ratio of repaired individuals over infeasible
* ones (a ratio of 1 will repair all the individuals).
* @param[in] ftol stopping criteria on the f tolerance.
* @param[in] xtol stopping criteria on the x tolerance.
* @throws value_error if gen is negative, if repair frequency is negative.
*/
cstrs_core::cstrs_core(const base &original_algo, const base &repair_algo,
int gen,
int repair_frequency,
double repair_ratio,
double ftol, double xtol):
base(),m_original_algo(original_algo.clone()),
m_repair_algo(repair_algo.clone()),
m_gen(gen),m_repair_frequency(repair_frequency),
m_repair_ratio(repair_ratio),m_ftol(ftol),m_xtol(xtol)
{
// m_original_algo = original_algo.clone();
// m_repair_algo = repair_algo.clone();
if(gen < 0) {
pagmo_throw(value_error,"number of generations must be nonnegative");
}
if(repair_frequency < 0) {
pagmo_throw(value_error,"repair frequency must be positive");
}
if((repair_ratio < 0) || (repair_ratio > 1)) {
pagmo_throw(value_error,"repair ratio must be in [0..1]");
}
}
示例5:
robust::robust(const base & p, unsigned int trials, const double param_rho, unsigned int seed):
base_stochastic((int)p.get_dimension(),
p.get_i_dimension(),
p.get_f_dimension(),
p.get_c_dimension(),
p.get_ic_dimension(),
p.get_c_tol(), seed),
m_original_problem(p.clone()),
m_normal_dist(0, 1),
m_uniform_dist(0, 1),
m_trials(trials),
m_rho(param_rho)
{
if(param_rho < 0){
pagmo_throw(value_error, "Rho should be greater than 0");
}
set_bounds(p.get_lb(),p.get_ub());
}
示例6:
noisy::noisy(const base & p, unsigned int trials, const double param_first, const double param_second, noise_type distribution, unsigned int seed):
base_stochastic((int)p.get_dimension(),
p.get_i_dimension(),
p.get_f_dimension(),
p.get_c_dimension(),
p.get_ic_dimension(),
p.get_c_tol(), seed),
m_original_problem(p.clone()),
m_trials(trials),
m_normal_dist(0.0,1.0),
m_uniform_dist(0.0,1.0),
m_decision_vector_hash(),
m_param_first(param_first),
m_param_second(param_second),
m_noise_type(distribution)
{
if(distribution == UNIFORM && param_first > param_second){
pagmo_throw(value_error, "Bounds specified for the uniform noise are not valid.");
}
set_bounds(p.get_lb(),p.get_ub());
}
示例7: set_algorithm
/**
* A copy of the input algorithm will be set as the internal local algorithm.
*
* @param[in] algo algorithm to be set as local algorithm.
*/
void cstrs_co_evolution::set_algorithm(const base &algo)
{
m_original_algo = algo.clone();
}
示例8: set_algorithm
/**
* A copy of the input algorithm will be set as the internal algorithm.
*
* @param[in] algo algorithm to be set for multistart.
*/
void ms::set_algorithm(const base &algo)
{
m_algorithm = algo.clone();
}
示例9: set_repair_algorithm
/**
* A copy of the input algorithm will be set as the internal local repair algorithm.
*
* @param[in] algo algorithm to be set as local repair algorithm.
*/
void cstrs_core::set_repair_algorithm(const base &algo)
{
m_repair_algo = algo.clone();
}
示例10: set_algorithm
/**
* A copy of the input algorithm will be set as the internal local algorithm.
*
* @param[in] algo algorithm to be set as local algorithm.
*/
void cstrs_core::set_algorithm(const base &algo)
{
m_original_algo = algo.clone();
}