sccomp/source/solver/solver.cxx | 19 ++++++++++++++++++- sccomp/source/solver/solver.hrc | 11 ++++++----- sccomp/source/solver/solver.hxx | 1 + sccomp/source/solver/solver.src | 7 +++++-- 4 files changed, 30 insertions(+), 8 deletions(-)
New commits: commit 389cc5a97f0d3fbf88fa15b92e849d821131ba6c Author: Pedro Giffuni <[email protected]> Date: Tue Sep 29 15:45:47 2015 +0000 Minor formatting fix diff --git a/sccomp/source/solver/solver.hxx b/sccomp/source/solver/solver.hxx index 5e161f2..7f69f0b 100644 --- a/sccomp/source/solver/solver.hxx +++ b/sccomp/source/solver/solver.hxx @@ -56,8 +56,7 @@ class SolverComponent : public comphelper::OMutexAndBroadcastHelper, sal_Int32 mnTimeout; sal_Int32 mnEpsilonLevel; sal_Bool mbLimitBBDepth; - sal_Bool - mbNonLinearTest; + sal_Bool mbNonLinearTest; // results sal_Bool mbSuccess; double mfResultValue; commit 899f3a1c6c24f71efabfbcaa0238308037cf830b Author: Pedro Giffuni <[email protected]> Date: Tue Sep 29 15:04:00 2015 +0000 i124091 - Reinstate the check for nonlinearity but turn it into an option. We only really support a linear solver at this time so the test for non-linearity was actually useful. Make it optional (ON by default) so that we can now override the check and provide a solution. diff --git a/sccomp/source/solver/solver.cxx b/sccomp/source/solver/solver.cxx index ca4ce39..496edcd 100644 --- a/sccomp/source/solver/solver.cxx +++ b/sccomp/source/solver/solver.cxx @@ -58,6 +58,7 @@ using ::rtl::OUString; #define STR_TIMEOUT "Timeout" #define STR_EPSILONLEVEL "EpsilonLevel" #define STR_LIMITBBDEPTH "LimitBBDepth" +#define STR_NONLINEARTEST "NonLinearTest" // ----------------------------------------------------------------------- // Resources from tools are used for translated strings @@ -82,7 +83,8 @@ namespace PROP_INTEGER, PROP_TIMEOUT, PROP_EPSILONLEVEL, - PROP_LIMITBBDEPTH + PROP_LIMITBBDEPTH, + PROP_NONLINEARTEST }; } @@ -146,6 +148,7 @@ SolverComponent::SolverComponent( const uno::Reference<uno::XComponentContext>& mnTimeout( 120 ), mnEpsilonLevel( 0 ), mbLimitBBDepth( sal_True ), + mbNonLinearTest( sal_True ), mbSuccess( sal_False ), mfResultValue( 0.0 ) { @@ -155,6 +158,7 @@ SolverComponent::SolverComponent( const uno::Reference<uno::XComponentContext>& registerProperty( C2U(STR_TIMEOUT), PROP_TIMEOUT, 0, &mnTimeout, getCppuType( &mnTimeout ) ); registerProperty( C2U(STR_EPSILONLEVEL), PROP_EPSILONLEVEL, 0, &mnEpsilonLevel, getCppuType( &mnEpsilonLevel ) ); registerProperty( C2U(STR_LIMITBBDEPTH), PROP_LIMITBBDEPTH, 0, &mbLimitBBDepth, getCppuType( &mbLimitBBDepth ) ); + registerProperty( C2U(STR_NONLINEARTEST), PROP_NONLINEARTEST, 0, &mbNonLinearTest, getCppuType( &mbNonLinearTest ) ); } SolverComponent::~SolverComponent() @@ -214,6 +218,9 @@ OUString SAL_CALL SolverComponent::getPropertyDescription( const OUString& rProp case PROP_LIMITBBDEPTH: nResId = RID_PROPERTY_LIMITBBDEPTH; break; + case PROP_NONLINEARTEST: + nResId = RID_PROPERTY_NONLINEARTEST; + break; default: { // unknown - leave empty @@ -369,6 +376,16 @@ void SAL_CALL SolverComponent::solve() throw(uno::RuntimeException) double fInitial = aCellsIter->second.front(); double fCoeff = aCellsIter->second.back(); // last appended: coefficient for this variable double fTwo = lcl_GetValue( mxDoc, aCellsIter->first ); + + if ( mbNonLinearTest ) + { + bool bLinear ( sal_True ); + bLinear = rtl::math::approxEqual( fTwo, fInitial + 2.0 * fCoeff ) || + rtl::math::approxEqual( fInitial, fTwo - 2.0 * fCoeff ); + // second comparison is needed in case fTwo is zero + if ( !bLinear ) + maStatus = lcl_GetResourceString( RID_ERROR_NONLINEAR ); + } } lcl_SetValue( mxDoc, *aVarIter, 0.0 ); // set back to zero for examining next variable diff --git a/sccomp/source/solver/solver.hrc b/sccomp/source/solver/solver.hrc index 9b75f45..0405651 100644 --- a/sccomp/source/solver/solver.hrc +++ b/sccomp/source/solver/solver.hrc @@ -31,11 +31,12 @@ #define RID_PROPERTY_TIMEOUT (SOLVER_RESOURCE_START + 3) #define RID_PROPERTY_EPSILONLEVEL (SOLVER_RESOURCE_START + 4) #define RID_PROPERTY_LIMITBBDEPTH (SOLVER_RESOURCE_START + 5) -#define RID_ERROR_NONLINEAR (SOLVER_RESOURCE_START + 6) -#define RID_ERROR_EPSILONLEVEL (SOLVER_RESOURCE_START + 7) -#define RID_ERROR_INFEASIBLE (SOLVER_RESOURCE_START + 8) -#define RID_ERROR_UNBOUNDED (SOLVER_RESOURCE_START + 9) -#define RID_ERROR_TIMEOUT (SOLVER_RESOURCE_START + 10) +#define RID_PROPERTY_NONLINEARTEST (SOLVER_RESOURCE_START + 6) +#define RID_ERROR_NONLINEAR (SOLVER_RESOURCE_START + 7) +#define RID_ERROR_EPSILONLEVEL (SOLVER_RESOURCE_START + 8) +#define RID_ERROR_INFEASIBLE (SOLVER_RESOURCE_START + 9) +#define RID_ERROR_UNBOUNDED (SOLVER_RESOURCE_START + 10) +#define RID_ERROR_TIMEOUT (SOLVER_RESOURCE_START + 11) #endif diff --git a/sccomp/source/solver/solver.hxx b/sccomp/source/solver/solver.hxx index 0a07ffe..5e161f2 100644 --- a/sccomp/source/solver/solver.hxx +++ b/sccomp/source/solver/solver.hxx @@ -56,6 +56,8 @@ class SolverComponent : public comphelper::OMutexAndBroadcastHelper, sal_Int32 mnTimeout; sal_Int32 mnEpsilonLevel; sal_Bool mbLimitBBDepth; + sal_Bool + mbNonLinearTest; // results sal_Bool mbSuccess; double mfResultValue; diff --git a/sccomp/source/solver/solver.src b/sccomp/source/solver/solver.src index b50b5f5..3ecb37a 100644 --- a/sccomp/source/solver/solver.src +++ b/sccomp/source/solver/solver.src @@ -48,10 +48,13 @@ String RID_PROPERTY_LIMITBBDEPTH { Text [ en-US ] = "Limit branch-and-bound depth"; }; - +String RID_PROPERTY_NONLINEARTEST +{ + Text [ en-US ] = "Run strict linearity checks"; +}; String RID_ERROR_NONLINEAR { - Text [ en-US ] = "The model is not linear."; + Text [ en-US ] = "The model seems nonlinear (see options)."; }; String RID_ERROR_EPSILONLEVEL { _______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
