solver.cxx (e74d7e62) solver.cxx (b1f1da72)
1/**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance

--- 44 unchanged lines hidden (view full) ---

53
54#define C2U(constAsciiStr) (::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( constAsciiStr ) ))
55
56#define STR_NONNEGATIVE "NonNegative"
57#define STR_INTEGER "Integer"
58#define STR_TIMEOUT "Timeout"
59#define STR_EPSILONLEVEL "EpsilonLevel"
60#define STR_LIMITBBDEPTH "LimitBBDepth"
1/**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance

--- 44 unchanged lines hidden (view full) ---

53
54#define C2U(constAsciiStr) (::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( constAsciiStr ) ))
55
56#define STR_NONNEGATIVE "NonNegative"
57#define STR_INTEGER "Integer"
58#define STR_TIMEOUT "Timeout"
59#define STR_EPSILONLEVEL "EpsilonLevel"
60#define STR_LIMITBBDEPTH "LimitBBDepth"
61#define STR_NONLINEARTEST "NonLinearTest"
61
62// -----------------------------------------------------------------------
63// Resources from tools are used for translated strings
64
65static ResMgr* pSolverResMgr = NULL;
66
67OUString lcl_GetResourceString( sal_uInt32 nId )
68{

--- 8 unchanged lines hidden (view full) ---

77namespace
78{
79 enum
80 {
81 PROP_NONNEGATIVE,
82 PROP_INTEGER,
83 PROP_TIMEOUT,
84 PROP_EPSILONLEVEL,
62
63// -----------------------------------------------------------------------
64// Resources from tools are used for translated strings
65
66static ResMgr* pSolverResMgr = NULL;
67
68OUString lcl_GetResourceString( sal_uInt32 nId )
69{

--- 8 unchanged lines hidden (view full) ---

78namespace
79{
80 enum
81 {
82 PROP_NONNEGATIVE,
83 PROP_INTEGER,
84 PROP_TIMEOUT,
85 PROP_EPSILONLEVEL,
85 PROP_LIMITBBDEPTH
86 PROP_LIMITBBDEPTH,
87 PROP_NONLINEARTEST
86 };
87}
88
89// -----------------------------------------------------------------------
90
91// hash map for the coefficients of a dependent cell (objective or constraint)
92// The size of each vector is the number of columns (variable cells) plus one, first entry is initial value.
93

--- 47 unchanged lines hidden (view full) ---

141SolverComponent::SolverComponent( const uno::Reference<uno::XComponentContext>& /* rSMgr */ ) :
142 OPropertyContainer( GetBroadcastHelper() ),
143 mbMaximize( sal_True ),
144 mbNonNegative( sal_False ),
145 mbInteger( sal_False ),
146 mnTimeout( 120 ),
147 mnEpsilonLevel( 0 ),
148 mbLimitBBDepth( sal_True ),
88 };
89}
90
91// -----------------------------------------------------------------------
92
93// hash map for the coefficients of a dependent cell (objective or constraint)
94// The size of each vector is the number of columns (variable cells) plus one, first entry is initial value.
95

--- 47 unchanged lines hidden (view full) ---

143SolverComponent::SolverComponent( const uno::Reference<uno::XComponentContext>& /* rSMgr */ ) :
144 OPropertyContainer( GetBroadcastHelper() ),
145 mbMaximize( sal_True ),
146 mbNonNegative( sal_False ),
147 mbInteger( sal_False ),
148 mnTimeout( 120 ),
149 mnEpsilonLevel( 0 ),
150 mbLimitBBDepth( sal_True ),
151 mbNonLinearTest( sal_True ),
149 mbSuccess( sal_False ),
150 mfResultValue( 0.0 )
151{
152 // for XPropertySet implementation:
153 registerProperty( C2U(STR_NONNEGATIVE), PROP_NONNEGATIVE, 0, &mbNonNegative, getCppuType( &mbNonNegative ) );
154 registerProperty( C2U(STR_INTEGER), PROP_INTEGER, 0, &mbInteger, getCppuType( &mbInteger ) );
155 registerProperty( C2U(STR_TIMEOUT), PROP_TIMEOUT, 0, &mnTimeout, getCppuType( &mnTimeout ) );
156 registerProperty( C2U(STR_EPSILONLEVEL), PROP_EPSILONLEVEL, 0, &mnEpsilonLevel, getCppuType( &mnEpsilonLevel ) );
157 registerProperty( C2U(STR_LIMITBBDEPTH), PROP_LIMITBBDEPTH, 0, &mbLimitBBDepth, getCppuType( &mbLimitBBDepth ) );
152 mbSuccess( sal_False ),
153 mfResultValue( 0.0 )
154{
155 // for XPropertySet implementation:
156 registerProperty( C2U(STR_NONNEGATIVE), PROP_NONNEGATIVE, 0, &mbNonNegative, getCppuType( &mbNonNegative ) );
157 registerProperty( C2U(STR_INTEGER), PROP_INTEGER, 0, &mbInteger, getCppuType( &mbInteger ) );
158 registerProperty( C2U(STR_TIMEOUT), PROP_TIMEOUT, 0, &mnTimeout, getCppuType( &mnTimeout ) );
159 registerProperty( C2U(STR_EPSILONLEVEL), PROP_EPSILONLEVEL, 0, &mnEpsilonLevel, getCppuType( &mnEpsilonLevel ) );
160 registerProperty( C2U(STR_LIMITBBDEPTH), PROP_LIMITBBDEPTH, 0, &mbLimitBBDepth, getCppuType( &mbLimitBBDepth ) );
161 registerProperty( C2U(STR_NONLINEARTEST), PROP_NONLINEARTEST, 0, &mbNonLinearTest, getCppuType( &mbNonLinearTest ) );
158}
159
160SolverComponent::~SolverComponent()
161{
162}
163
164IMPLEMENT_FORWARD_XINTERFACE2( SolverComponent, SolverComponent_Base, OPropertyContainer )
165IMPLEMENT_FORWARD_XTYPEPROVIDER2( SolverComponent, SolverComponent_Base, OPropertyContainer )

--- 43 unchanged lines hidden (view full) ---

209 nResId = RID_PROPERTY_TIMEOUT;
210 break;
211 case PROP_EPSILONLEVEL:
212 nResId = RID_PROPERTY_EPSILONLEVEL;
213 break;
214 case PROP_LIMITBBDEPTH:
215 nResId = RID_PROPERTY_LIMITBBDEPTH;
216 break;
162}
163
164SolverComponent::~SolverComponent()
165{
166}
167
168IMPLEMENT_FORWARD_XINTERFACE2( SolverComponent, SolverComponent_Base, OPropertyContainer )
169IMPLEMENT_FORWARD_XTYPEPROVIDER2( SolverComponent, SolverComponent_Base, OPropertyContainer )

--- 43 unchanged lines hidden (view full) ---

213 nResId = RID_PROPERTY_TIMEOUT;
214 break;
215 case PROP_EPSILONLEVEL:
216 nResId = RID_PROPERTY_EPSILONLEVEL;
217 break;
218 case PROP_LIMITBBDEPTH:
219 nResId = RID_PROPERTY_LIMITBBDEPTH;
220 break;
221 case PROP_NONLINEARTEST:
222 nResId = RID_PROPERTY_NONLINEARTEST;
223 break;
217 default:
218 {
219 // unknown - leave empty
220 }
221 }
222 OUString aRet;
223 if ( nResId )
224 aRet = lcl_GetResourceString( nResId );

--- 139 unchanged lines hidden (view full) ---

364
365 lcl_SetValue( mxDoc, *aVarIter, 2.0 ); // minimal test for linearity
366
367 for ( aCellsIter = aCellsHash.begin(); aCellsIter != aCellsHash.end(); ++aCellsIter )
368 {
369 double fInitial = aCellsIter->second.front();
370 double fCoeff = aCellsIter->second.back(); // last appended: coefficient for this variable
371 double fTwo = lcl_GetValue( mxDoc, aCellsIter->first );
224 default:
225 {
226 // unknown - leave empty
227 }
228 }
229 OUString aRet;
230 if ( nResId )
231 aRet = lcl_GetResourceString( nResId );

--- 139 unchanged lines hidden (view full) ---

371
372 lcl_SetValue( mxDoc, *aVarIter, 2.0 ); // minimal test for linearity
373
374 for ( aCellsIter = aCellsHash.begin(); aCellsIter != aCellsHash.end(); ++aCellsIter )
375 {
376 double fInitial = aCellsIter->second.front();
377 double fCoeff = aCellsIter->second.back(); // last appended: coefficient for this variable
378 double fTwo = lcl_GetValue( mxDoc, aCellsIter->first );
379
380 if ( mbNonLinearTest )
381 {
382 bool bLinear ( sal_True );
383 bLinear = rtl::math::approxEqual( fTwo, fInitial + 2.0 * fCoeff ) ||
384 rtl::math::approxEqual( fInitial, fTwo - 2.0 * fCoeff );
385 // second comparison is needed in case fTwo is zero
386 if ( !bLinear )
387 maStatus = lcl_GetResourceString( RID_ERROR_NONLINEAR );
388 }
372 }
373
374 lcl_SetValue( mxDoc, *aVarIter, 0.0 ); // set back to zero for examining next variable
375 }
376
377 xModel->unlockControllers();
378
379 if ( maStatus.getLength() )

--- 279 unchanged lines hidden ---
389 }
390
391 lcl_SetValue( mxDoc, *aVarIter, 0.0 ); // set back to zero for examining next variable
392 }
393
394 xModel->unlockControllers();
395
396 if ( maStatus.getLength() )

--- 279 unchanged lines hidden ---