Example #1
0
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;
}
Example #2
0
//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;

}
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());
}
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;
}
Example #5
0
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;
}
Example #6
0
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.;
}