void TestNewton::inflating_newton01() { Ponts30 p30; double eps=1e-2; IntervalVector error(30,-eps); IntervalVector box(30,BOX2); box += error; IntervalVector expected(30,BOX2); bool ret=inflating_newton(*p30.f,box); TEST_ASSERT(ret); TEST_ASSERT(almost_eq(box,expected,1e-10)); }
BoolInterval PdcHansenFeasibility::test(const IntervalVector& box) { int n=f.nb_var(); int m=f.image_dim(); IntervalVector mid=box.mid(); /* Determine the "most influencing" variable thanks to * the pivoting of Gauss elimination */ // ============================================================== Matrix A=f.jacobian(mid).mid(); Matrix LU(m,n); int pr[m]; int pc[n]; // the interesting output: the variables permutation try { real_LU(A,LU,pr,pc); } catch(SingularMatrixException&) { // means in particular that we could not extract an // invertible m*m submatrix return MAYBE; } // ============================================================== PartialFnc pf(f,pc,m,mid); IntervalVector box2(pf.chop(box)); IntervalVector savebox(box2); if (inflating) { if (inflating_newton(pf,box2)) { _solution = pf.extend(box2); return YES; } } else { try { newton(pf,box2); if (box2.is_strict_subset(savebox)) { _solution = pf.extend(box2); return YES; } } catch (EmptyBoxException& ) { } } _solution.set_empty(); return MAYBE; }
bool inflating_newton(const Fnc& f, const VarSet& vars, const IntervalVector& full_box, IntervalVector& box_existence, IntervalVector& box_unicity, int k_max, double mu_max, double delta, double chi) { return inflating_newton(f,&vars,full_box,box_existence,box_unicity,k_max,mu_max,delta,chi); }
BoolInterval PdcHansenFeasibility::test(const IntervalVector& box) { int n=f.nb_var(); int m=f.image_dim(); IntervalVector mid=box.mid(); /* Determine the "most influencing" variable thanks to * the pivoting of Gauss elimination */ // ============================================================== Matrix A=f.jacobian(mid).mid(); Matrix LU(m,n); int *pr = new int[m]; int *pc = new int[n]; // the interesting output: the variables permutation BoolInterval res=MAYBE; try { real_LU(A,LU,pr,pc); } catch(SingularMatrixException&) { // means in particular that we could not extract an // invertible m*m submatrix delete [] pr; delete [] pc; return MAYBE; } // ============================================================== // PartialFnc pf(f,pc,m,mid); BitSet _vars=BitSet::empty(n); for (int i=0; i<m; i++) _vars.add(pc[i]); VarSet vars(f.nb_var(),_vars); IntervalVector box2(box); // fix parameters to their midpoint vars.set_param_box(box2, vars.param_box(box).mid()); IntervalVector savebox(box2); if (inflating) { if (inflating_newton(f,vars,box2)) { _solution = box2; res = YES; } else { _solution.set_empty(); } } else { // ****** TODO ********** newton(f,vars,box2); if (box2.is_empty()) { _solution.set_empty(); } else if (box2.is_strict_subset(savebox)) { _solution = box2; res = YES; } } delete [] pr; delete [] pc; return res; }