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


C++ IntervalVector::ub方法代码示例

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


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

示例1: centeredFormEval

Interval centeredFormEval(const Function& function, const IntervalVector& arg) {
	/*Interval natural_extension = function.eval(arg);
	Interval centered_form = function.eval(arg.mid()) + function.gradient(arg) * (arg - arg.mid());*/
	IntervalVector new_arg_ub(arg);
	IntervalVector new_arg_lb(arg);
	IntervalVector grad = function.gradient(arg);
	for(int i = 0; i < arg.size(); ++i) {
		if(grad[i].lb() > 0) {
			new_arg_ub[i] = arg[i].ub();
			new_arg_lb[i] = arg[i].lb();
		} else if(grad[i].ub() < 0) {
			new_arg_ub[i] = arg[i].lb();
			new_arg_lb[i] = arg[i].ub();
		}
	}
	Interval natural_extension = function.eval(arg);
	Interval centered_form = function.eval(arg.mid()) + grad * (arg - arg.mid());
	Interval ub_form = function.eval(arg.ub()) + grad * (arg - arg.ub());
	Interval lb_form = function.eval(arg.lb()) + grad * (arg - arg.lb());
	Interval res = natural_extension & centered_form & ub_form & lb_form;
	res &= Interval(function.eval(new_arg_lb).lb(), function.eval(new_arg_ub).ub());
	return res;
}
开发者ID:ibex-team,项目名称:ibex-lib,代码行数:23,代码来源:ibex_utils.cpp

示例2: hansen_bliek

void hansen_bliek(const IntervalMatrix& A, const IntervalVector& B, IntervalVector& x) {
	int n=A.nb_rows();
	assert(n == A.nb_cols()); // throw NotSquareMatrixException();
	assert(n == x.size() && n == B.size());

	Matrix Id(n,n);
	for (int i=0; i<n; i++)
		for (int j=0; j<n; j++) {
			Id[i][j]   = i==j;
		}

	IntervalMatrix radA(A-Id);
	Matrix InfA(Id-abs(radA.lb()));
	Matrix M(n,n);

	real_inverse(InfA, M);  // may throw SingularMatrixException...

	for (int i=0; i<n; i++)
		for (int j=0; j<n; j++)
			if (! (M[i][j]>=0.0)) throw NotInversePositiveMatrixException();

	Vector b(B.mid());
	Vector delta = (B.ub())-b;

	Vector xstar = M * (abs(b)+delta);

	double xtildek, xutildek, nuk, max, min;

	for (int k=0; k<n; k++) {
		xtildek = (b[k]>=0) ? xstar[k] : xstar[k] + 2*M[k][k]*b[k];
		xutildek = (b[k]<=0) ? -xstar[k] : -xstar[k] + 2*M[k][k]*b[k];

		nuk = 1/(2*M[k][k]-1);
		max = nuk*xutildek;
		if (max < 0) max = 0;

		min = nuk*xtildek;
		if (min > 0) min = 0;

		/* compute bounds of x(k) */
		if (xtildek >= max) {
			if (xutildek <= min) x[k] = Interval(xutildek,xtildek);
			else x[k] = Interval(max,xtildek);
		} else {
			if (xutildek <= min) x[k] = Interval(xutildek,min);
			else { x.set_empty(); return; }
		}
	}
}
开发者ID:ClementAubry,项目名称:ibex-lib,代码行数:49,代码来源:ibex_Linear.cpp


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