### Improved search for variables to be eliminated. Try to eliminate reals first integers last.

`git-svn-id: http://www.openflipper.org/svnrepo/CoMISo/trunk@26 1355f012-dd97-4b2f-ae87-10fa9f823a57`
parent f0634972
 ... ... @@ -62,7 +62,7 @@ public: /// default Constructor ConstrainedSolver() { } ConstrainedSolver() { epsilon_ = 1e-6; } /// Destructor ~ConstrainedSolver() { } ... ... @@ -203,6 +203,8 @@ public: /*@}*/ /// Set numerical epsilon for valid constraint coefficient void set_epsilon( double _epsilon) { epsilon_ = _epsilon;} /** @name Verify the result. * Functions to verify the result of the constrained solver. Are the constraints met, are the correct variables correctly rounded ... ... ... @@ -268,6 +270,8 @@ private: /// Assignment operator (not used) ConstrainedSolver& operator=(const ConstrainedSolver& _rhs); double epsilon_; }; ... ...
 ... ... @@ -211,6 +211,7 @@ make_constraints_independent( { // get elimination variable int elim_j = -1; int elim_int_j = -1; // iterate over current row, until variable found // first search for real valued variable ... ... @@ -245,28 +246,38 @@ make_constraints_independent( //break; } else // store smallest integer if( fabs(*row_it) < elim_val) { // store integer closest to 1 if( fabs(fabs(*row_it)-1.0) < elim_val) { elim_j = cur_j; elim_val = fabs(*row_it); elim_int_j = cur_j; elim_val = fabs(fabs(*row_it)-1.0); } } } } // first try to eliminate a valid (>epsilon_) real valued variable (safer) if( max_elim_val > epsilon_) {} else // use the best found integer elim_j = elim_int_j; // store result _c_elim[i] = elim_j; // error check result if( elim_j == -1) { // redundant or incompatible? if( fabs(gmm::mat_const_row(_constraints, i)[n_vars-1]) > 1e-6 ) if( fabs(gmm::mat_const_row(_constraints, i)[n_vars-1]) > epsilon_ ) std::cerr << "Warning: incompatible condition:\n"; else std::cerr << "Warning: redundant condition:\n"; } else if(roundmap[elim_j] && fabs(elim_val-1.0) > 1e-6) if(roundmap[elim_j] && elim_val > 1e-6) std::cerr << "Warning: eliminate non +-1 integer -> correct rounding cannot be guaranteed:\n" << gmm::mat_const_row(_constraints, i) << std::endl; ... ... @@ -274,7 +285,7 @@ make_constraints_independent( if( elim_j != -1 ) { // get elim variable value double elim_val = _constraints(i, elim_j); double elim_val_cur = _constraints(i, elim_j); // copy col CVector col = constraints_c.col(elim_j); ... ... @@ -287,7 +298,7 @@ make_constraints_independent( if( c_it.index() > i) { sw.start(); add_row_simultaneously( c_it.index(), -(*c_it)/elim_val, gmm::mat_row(_constraints, i), _constraints, constraints_c); add_row_simultaneously( c_it.index(), -(*c_it)/elim_val_cur, gmm::mat_row(_constraints, i), _constraints, constraints_c); // make sure the eliminated entry is 0 on all other rows and not 1e-17 _constraints( c_it.index(), elim_j) = 0; constraints_c(c_it.index(), elim_j) = 0; ... ...
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!