From bc7b128b3d2cc53e16eb9d252c7a1bf10e004e2e Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Sat, 23 Sep 2006 23:37:49 +0200 Subject: [PATCH] reduced_basis: reset "negative widths" to zero There is no point in iterating when the width is close enough to zero that the LP solution becomes negative. --- basis_reduction.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/basis_reduction.c b/basis_reduction.c index 73382c1..5867e68 100644 --- a/basis_reduction.c +++ b/basis_reduction.c @@ -136,6 +136,8 @@ Matrix *reduced_basis(Polyhedron *P) lpx_simplex(lp); F[0] = lpx_get_obj_val(lp); assert(F[0] > -1e-10); + if (F[0] < 0) + F[0] = 0; do { int mu[2]; @@ -160,6 +162,8 @@ Matrix *reduced_basis(Polyhedron *P) } F[i+1] = F_new; assert(F[i+1] > -1e-10); + if (F[i+1] < 0) + F[i+1] = 0; mu[0] = (int)floor(alpha+1e-10); @@ -194,6 +198,8 @@ Matrix *reduced_basis(Polyhedron *P) Vector_Combine(basis->p[i+1], basis->p[i], basis->p[i+1], one, tmp, dim); assert(F_new > -1e-10); + if (F_new < 0) + F_new = 0; F_old = F[i]; use_saved = 0; -- 2.11.4.GIT