本文整理汇总了C++中problem::base_ptr类的典型用法代码示例。如果您正苦于以下问题:C++ base_ptr类的具体用法?C++ base_ptr怎么用?C++ base_ptr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了base_ptr类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: number_violated_constraints
int number_violated_constraints(const constraint_vector &c, problem::base_ptr original_problem)
{
int viol = 0;
constraint_vector::size_type c_dim = original_problem->get_c_dimension();
for(constraint_vector::size_type i=0; i<c_dim; i++) {
if (!original_problem->test_constraint(c,i)) {
viol++;
}
}
return viol;
}
示例2: construct_test_point
//Construct a new test point d_from_center away from the mid point of upper bound and lower bound for each dimension
decision_vector construct_test_point(const problem::base_ptr &prob, double d_from_center)
{
assert(abs(d_from_center) <= 1.0);
decision_vector lb = prob->get_lb();
decision_vector ub = prob->get_ub();
decision_vector test_point(prob->get_dimension(), 0);
for(unsigned int i = 0; i < prob->get_dimension(); i++){
if(is_eq(ub[i], lb[i])) continue;
double middle_t = (ub[i] + lb[i]) / 2.0;
test_point[i] = middle_t + d_from_center * (ub[i] - middle_t);
}
return test_point;
}
示例3: std_dev
double std_dev(archipelago a, double mean, problem::base_ptr original_problem) {
double retval = 0;
for (archipelago::size_type i = 0; i< a.get_size(); ++i) {
// test feasibility
if(original_problem->feasibility_x(a.get_island(i)->get_population().champion().x))
retval += pow((a.get_island(i)->get_population().champion().f[0] - mean),2);
}
return sqrt(retval / a.get_size());
}
示例4: worst
double worst(archipelago a, problem::base_ptr original_problem) {
double retval = - boost::numeric::bounds<double>::highest();
for (archipelago::size_type i = 0; i< a.get_size(); ++i) {
// test feasibility
if(original_problem->feasibility_x(a.get_island(i)->get_population().champion().x))
retval = std::max(retval, a.get_island(i)->get_population().champion().f[0]);
}
return retval;
}
示例5: mean_violated_constraints
double mean_violated_constraints(const constraint_vector &c, problem::base_ptr original_problem) {
double viol = 0;
constraint_vector::size_type c_dim = original_problem->get_c_dimension();
problem::base::c_size_type number_of_eq_constraints =
original_problem->get_c_dimension() -
original_problem->get_ic_dimension();
const std::vector<double> &c_tol = original_problem->get_c_tol();
for(constraint_vector::size_type j=0; j<number_of_eq_constraints; j++) {
viol += std::max(0.,(std::abs(c.at(j)) - c_tol.at(j)));
}
for(constraint_vector::size_type j=number_of_eq_constraints; j<c_dim; j++) {
viol += std::max(0.,c.at(j));
}
viol /= c_dim;
return viol;
}
示例6: mean
double mean(archipelago a, problem::base_ptr original_problem) {
double retval = 0;
int count_feasible_arch = 0;
for (archipelago::size_type i = 0; i< a.get_size(); ++i) {
// test feasibility
if(original_problem->feasibility_x(a.get_island(i)->get_population().champion().x)) {
retval += a.get_island(i)->get_population().champion().f[0];
count_feasible_arch++;
}
}
if(count_feasible_arch != 0)
return retval / count_feasible_arch;
else
return 0.;
}