diff options
author | Eduardo M. Fleury <eduardo.fleury@openbossa.org> | 2009-09-28 14:49:42 (GMT) |
---|---|---|
committer | Jan-Arve Sæther <jan-arve.saether@nokia.com> | 2009-10-06 09:28:49 (GMT) |
commit | ba66cc0bde91e1143ac0a34f249f98e4573a5737 (patch) | |
tree | 9df08eaed5c4f79e4efd210cd9c07183e6fcab1c /src/gui/graphicsview/qsimplex_p.h | |
parent | ad69bb73754534f61658a83e85dadb75e603c90a (diff) | |
download | Qt-ba66cc0bde91e1143ac0a34f249f98e4573a5737.zip Qt-ba66cc0bde91e1143ac0a34f249f98e4573a5737.tar.gz Qt-ba66cc0bde91e1143ac0a34f249f98e4573a5737.tar.bz2 |
QSimplex: Remove overly conservative assertion
This assertion started failing after the addition of expanding
state. After some investigation we felt that the assertion itself
was too strong and would fail in some valid cases.
The new assertion is formally right as it tests whether the
simplex solver was able to satisfy the simplex constraints,
_exactly_ what it is expected to do.
Signed-off-by: Eduardo M. Fleury <eduardo.fleury@openbossa.org>
Reviewed-by: Caio Marcelo de Oliveira Filho <caio.oliveira@openbossa.org>
Diffstat (limited to 'src/gui/graphicsview/qsimplex_p.h')
-rw-r--r-- | src/gui/graphicsview/qsimplex_p.h | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/src/gui/graphicsview/qsimplex_p.h b/src/gui/graphicsview/qsimplex_p.h index 54b080d..b517cb9 100644 --- a/src/gui/graphicsview/qsimplex_p.h +++ b/src/gui/graphicsview/qsimplex_p.h @@ -94,8 +94,32 @@ struct QSimplexConstraint QPair<QSimplexVariable *, qreal> helper; QSimplexVariable * artificial; -}; + #ifdef QT_DEBUG + bool isSatisfied() { + qreal leftHandSide(0); + + QHash<QSimplexVariable *, qreal>::const_iterator iter; + for (iter = variables.constBegin(); iter != variables.constEnd(); ++iter) { + leftHandSide += iter.value() * iter.key()->result; + } + + Q_ASSERT(constant > 0 || qFuzzyCompare(1, 1 + constant)); + + if (qFuzzyCompare(1000 + leftHandSide, 1000 + constant)) + return true; + + switch (ratio) { + case LessOrEqual: + return leftHandSide < constant; + case MoreOrEqual: + return leftHandSide > constant; + default: + return false; + } + } + #endif +}; class QSimplex { |