本文整理匯總了C++中Interval::mid方法的典型用法代碼示例。如果您正苦於以下問題:C++ Interval::mid方法的具體用法?C++ Interval::mid怎麽用?C++ Interval::mid使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Interval
的用法示例。
在下文中一共展示了Interval::mid方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1:
Affine2Main<AF_iAF>::Affine2Main(int n, int m, const Interval& itv) :
_n (n),
_elt (NULL,0.0)
{
assert((n>=0) && (m>=0) && (m<=n));
if (!(itv.is_unbounded()||itv.is_empty())) {
_elt._val =new Interval[n + 1];
_elt._val[0] = itv.mid();
for (int i = 1; i <= n; i++){
_elt._val[i] = 0.0;
}
if (m == 0) {
_elt._err = itv.rad();
} else {
_elt._val[m] = itv.rad();
}
} else {
*this = itv;
}
}
示例2: if
Affine2Main<AF_iAF>::Affine2Main(const Interval & itv):
_n (0),
_elt (NULL,0.0) {
if (itv.is_empty()) {
_n = -1;
_elt._err = itv;
} else if (itv.ub()>= POS_INFINITY && itv.lb()<= NEG_INFINITY ) {
_n = -2;
_elt._err = itv;
} else if (itv.ub()>= POS_INFINITY ) {
_n = -3;
_elt._err = itv;
} else if (itv.lb()<= NEG_INFINITY ) {
_n = -4;
_elt._err = itv;
} else {
_n = 0;
_elt._val = new Interval[1];
_elt._val[0] = itv.mid();
_elt._err = itv.rad();
}
}
示例3: X_Linearization
//.........這裏部分代碼省略.........
/*
case GREEDY7:
//select the coin nearest to the loup
if(goal_ctr!=-1 && Dimension(Optimizer::global_optimizer())>0){
// if(j==0)cout<< Optimizer::global_optimizer()<<end;
inf_x=(abs(Optimizer::global_optimizer()(j+1)-Inf(savebox(j+1))) <
abs(Optimizer::global_optimizer()(j+1)-Sup(savebox(j+1))))? true:false;
}else{
inf_x=(rand()%2==0);
}
break;
*/
/*
case GREEDY6:
save=space.box;
fh_inf, fh_sup;
D=Diam(savebox(j+1));
space.box=Mid(space.box);
space.box(j+1)=Inf(savebox(j+1));
fh_inf=Mid(sys.ctr(ctr).eval(space));
space.box(j+1)=Sup(savebox(j+1));
fh_sup=Mid(sys.ctr(ctr).eval(space));
if (op == LEQ || op== LT)
inf_x=((fh_sup-fh_inf)/(REAL)(n-1) - 0.5*D*(Inf(G(j+1))+Sup(G(j+1))) > 0)? false:true;
else
inf_x=((fh_sup-fh_inf)/(REAL)(n-1) - 0.5*D*(Inf(G(j+1))+Sup(G(j+1))) < 0)? false:true;
last_rnd[j]=inf_x? 0:1;
space.box=save;
break;
case GREEDY5:
save=space.box;
fh_inf, fh_sup;
D=Diam(savebox(j+1));
space.box=Mid(space.box);
space.box(j+1)=Inf(savebox(j+1));
fh_inf=Mid(sys.ctr(ctr).eval(space));
space.box(j+1)=Sup(savebox(j+1));
fh_sup=Mid(sys.ctr(ctr).eval(space));
if (op == LEQ || op== LT)
inf_x=(fh_sup-fh_inf - 0.5*D*(Inf(G(j+1))+Sup(G(j+1))) > 0)? false:true;
else
inf_x=(fh_sup-fh_inf - 0.5*D*(Inf(G(j+1))+Sup(G(j+1))) < 0)? false:true;
last_rnd[j]=inf_x? 0:1;
space.box=save;
break;
*/
default:
last_rnd[j] = rand();
inf_x = (last_rnd[j] % 2 == 0);
break;
}
// cout << " j " << j << " " << savebox[j] << G[j] << endl;
box[j]=inf_x? savebox[j].lb():savebox[j].ub();
Interval a = ((inf_x && (op == LEQ || op== LT)) ||
(!inf_x && (op == GEQ || op== GT))) ? G[j].lb() : G[j].ub();
row1[j] = a.mid();
ev -= a*box[j];
}
// cout << " ev " << ev << endl;
/* used in BEST not implemented in v2.0
if(corner) delete[] corner;
*/
ev+= sys.ctrs[ctr].f.eval(box);
if(id_point==0) nb_nonlinear_vars=nonlinear_var;
for(int j=0;j<n;j++)
tot_ev+=row1[j]*savebox[j]; //natural evaluation of the left side of the linear constraint
bool added=false;
if (op == LEQ || op == LT) {
//g(xb) + a1' x1 + ... + an xn <= 0
if(tot_ev.lb()>(-ev).ub())
throw EmptyBoxException(); // the constraint is not satisfied
if((-ev).ub()<tot_ev.ub()) { // otherwise the constraint is satisfied for any point in the box
lp_solver.addConstraint( row1, LEQ, (-ev).ub());
added=true;
}
} else {
if(tot_ev.ub()<(-ev).lb())
throw EmptyBoxException();
if ((-ev).lb()>tot_ev.lb()) {
lp_solver.addConstraint( row1, GEQ, (-ev).lb() );
added=true;
}
}
//box=savebox;
return (added)? 1:0;
}