当前位置: 首页>>代码示例>>C++>>正文


C++ base::get_c_tol方法代码示例

本文整理汇总了C++中base::get_c_tol方法的典型用法代码示例。如果您正苦于以下问题:C++ base::get_c_tol方法的具体用法?C++ base::get_c_tol怎么用?C++ base::get_c_tol使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在base的用法示例。


在下文中一共展示了base::get_c_tol方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: orthonormal

/**
 * 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();
}
开发者ID:DinCahill,项目名称:pagmo,代码行数:43,代码来源:rotated.cpp

示例2:

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());
}
开发者ID:DinCahill,项目名称:pagmo,代码行数:18,代码来源:robust.cpp

示例3:

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());
}
开发者ID:DominicDirkx,项目名称:pagmo,代码行数:21,代码来源:noisy.cpp

示例4: pow

/**
 * Constructor
 *
 * @param[in] p base::problem to be decomposed
 * @param[in] method decomposition method (WEIGHTS, TCHEBYCHEFF, BI)
 * @param[in] weights the weight vector (by default is set to random weights)
 * @param[in] z ideal reference point (used in Tchebycheff and Boundary Intersection (BI) methods, by default it is set to 0)
 * @param[in] adapt_ideal if true it updates the ideal reference point each time the objective function is called checking if the computed fitness is better (assumes minimization)
 * @see For the uniform random generation of weights vector see Appendix 2 in "A. Jaszkiewicz - On the Performance of Multiple-Objective Genetic Local Search
on the 0/1 Knapsack Problem—A Comparative Experiment"
 * @see For the different decomposition methods see "Q. Zhang - MOEA/D: A Multiobjective Evolutionary Algorithm Based on Decomposition"

 */
decompose::decompose(const base & p, method_type method, const std::vector<double> & weights, const std::vector<double> & z, const bool adapt_ideal):
	base_meta(
		 p,
		 p.get_dimension(), // Ambiguous without the cast ...
		 p.get_i_dimension(),
		 1, //it transforms the problem into a single-objective problem
		 p.get_c_dimension(),
		 p.get_ic_dimension(),
		 p.get_c_tol()),
		 m_method(method),
		 m_weights(weights),
		 m_z(z),
		 m_adapt_ideal(adapt_ideal)
{

	//0 - Check whether method is implemented
	if(m_method != WEIGHTED && m_method != TCHEBYCHEFF && m_method != BI) {
		pagmo_throw(value_error,"non existing decomposition method");
	}

	if (p.get_f_dimension() == 1) {
		pagmo_throw(value_error,"decompose works only for multi-objective problems, you are trying to decompose a single objective one.");
	}

	//1 - Checks whether the weight vector has a dimension, if not, sets its default value
	if (m_weights.size() == 0) {
		//Initialise a random weight vector
		rng_double m_drng = rng_generator::get<rng_double>();
		m_weights = std::vector<double>((int)p.get_f_dimension(), 0.0);
		double sum = 0;
		for(std::vector<double>::size_type i = 0; i<m_weights.size(); ++i) {
			m_weights[i] = (1-sum) * (1 - pow(boost::uniform_real<double>(0,1)(m_drng), 1.0 / (m_weights.size() - i - 1)));
			sum += m_weights[i];
		}
	} else {

		//1.1 - Checks whether the weight has lenght equal to the fitness size
		if (m_weights.size() != p.get_f_dimension()) {
			pagmo_throw(value_error,"the weight vector must have length equal to the fitness size");
		}

		//1.2 - Checks whether the weight vector sums to 1
		double sum = 0.0;
		for (std::vector<double>::size_type i=0; i<m_weights.size(); ++i) {
			sum += m_weights[i];
		}
		if (fabs(sum-1.0) > 1E-8) {
			pagmo_throw(value_error,"the weight vector should sum to 1 with a tolerance of E1-8");
		}
		
		//1.4 - Checks that all weights are positive
		for (std::vector<double>::size_type i=0; i<m_weights.size(); ++i) {
			if (m_weights[i] < 0) {
				pagmo_throw(value_error,"the weight vector should contain only positive values");
			}
		}
	}

	//2 - Checks whether the reference point has a dimension, if not, sets its default value m_z = (0, ..., 0)
	if (m_z.size() == 0) {
		m_z = std::vector<double>((int)p.get_f_dimension(), 0.0); //by default m_z = (0, ..., 0)
	} else {
		//2.1 - Checks whether the reference point has lenght equal to the fitness size
		if (m_z.size() != p.get_f_dimension()) {
			pagmo_throw(value_error,"the the reference point vector must have equal length to the fitness size");
		}
	}
}
开发者ID:DinCahill,项目名称:pagmo,代码行数:81,代码来源:decompose.cpp


注:本文中的base::get_c_tol方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。