diff options
Diffstat (limited to 'sccomp')
-rw-r--r-- | sccomp/source/solver/CoinMPSolver.cxx | 36 | ||||
-rw-r--r-- | sccomp/source/solver/LpsolveSolver.cxx | 36 |
2 files changed, 34 insertions, 38 deletions
diff --git a/sccomp/source/solver/CoinMPSolver.cxx b/sccomp/source/solver/CoinMPSolver.cxx index dbd19a4d9f43..d227e48d5f0f 100644 --- a/sccomp/source/solver/CoinMPSolver.cxx +++ b/sccomp/source/solver/CoinMPSolver.cxx @@ -86,40 +86,38 @@ void SAL_CALL CoinMPSolver::solve() // set all variables to zero //! store old values? //! use old values as initial values? - std::vector<table::CellAddress>::const_iterator aVarIter; - for ( aVarIter = aVariableCells.begin(); aVarIter != aVariableCells.end(); ++aVarIter ) + for ( const auto& rVarCell : aVariableCells ) { - SolverComponent::SetValue( mxDoc, *aVarIter, 0.0 ); + SolverComponent::SetValue( mxDoc, rVarCell, 0.0 ); } // read initial values from all dependent cells - ScSolverCellHashMap::iterator aCellsIter; - for ( aCellsIter = aCellsHash.begin(); aCellsIter != aCellsHash.end(); ++aCellsIter ) + for ( auto& rEntry : aCellsHash ) { - double fValue = SolverComponent::GetValue( mxDoc, aCellsIter->first ); - aCellsIter->second.push_back( fValue ); // store as first element, as-is + double fValue = SolverComponent::GetValue( mxDoc, rEntry.first ); + rEntry.second.push_back( fValue ); // store as first element, as-is } // loop through variables - for ( aVarIter = aVariableCells.begin(); aVarIter != aVariableCells.end(); ++aVarIter ) + for ( const auto& rVarCell : aVariableCells ) { - SolverComponent::SetValue( mxDoc, *aVarIter, 1.0 ); // set to 1 to examine influence + SolverComponent::SetValue( mxDoc, rVarCell, 1.0 ); // set to 1 to examine influence // read value change from all dependent cells - for ( aCellsIter = aCellsHash.begin(); aCellsIter != aCellsHash.end(); ++aCellsIter ) + for ( auto& rEntry : aCellsHash ) { - double fChanged = SolverComponent::GetValue( mxDoc, aCellsIter->first ); - double fInitial = aCellsIter->second.front(); - aCellsIter->second.push_back( fChanged - fInitial ); + double fChanged = SolverComponent::GetValue( mxDoc, rEntry.first ); + double fInitial = rEntry.second.front(); + rEntry.second.push_back( fChanged - fInitial ); } - SolverComponent::SetValue( mxDoc, *aVarIter, 2.0 ); // minimal test for linearity + SolverComponent::SetValue( mxDoc, rVarCell, 2.0 ); // minimal test for linearity - for ( aCellsIter = aCellsHash.begin(); aCellsIter != aCellsHash.end(); ++aCellsIter ) + for ( const auto& rEntry : aCellsHash ) { - double fInitial = aCellsIter->second.front(); - double fCoeff = aCellsIter->second.back(); // last appended: coefficient for this variable - double fTwo = SolverComponent::GetValue( mxDoc, aCellsIter->first ); + double fInitial = rEntry.second.front(); + double fCoeff = rEntry.second.back(); // last appended: coefficient for this variable + double fTwo = SolverComponent::GetValue( mxDoc, rEntry.first ); bool bLinear = rtl::math::approxEqual( fTwo, fInitial + 2.0 * fCoeff ) || rtl::math::approxEqual( fInitial, fTwo - 2.0 * fCoeff ); @@ -128,7 +126,7 @@ void SAL_CALL CoinMPSolver::solve() maStatus = SolverComponent::GetResourceString( RID_ERROR_NONLINEAR ); } - SolverComponent::SetValue( mxDoc, *aVarIter, 0.0 ); // set back to zero for examining next variable + SolverComponent::SetValue( mxDoc, rVarCell, 0.0 ); // set back to zero for examining next variable } xModel->unlockControllers(); diff --git a/sccomp/source/solver/LpsolveSolver.cxx b/sccomp/source/solver/LpsolveSolver.cxx index 08b56ff1f9e9..0eb7d08dafd6 100644 --- a/sccomp/source/solver/LpsolveSolver.cxx +++ b/sccomp/source/solver/LpsolveSolver.cxx @@ -123,40 +123,38 @@ void SAL_CALL LpsolveSolver::solve() // set all variables to zero //! store old values? //! use old values as initial values? - std::vector<table::CellAddress>::const_iterator aVarIter; - for ( aVarIter = aVariableCells.begin(); aVarIter != aVariableCells.end(); ++aVarIter ) + for ( const auto& rVarCell : aVariableCells ) { - SolverComponent::SetValue( mxDoc, *aVarIter, 0.0 ); + SolverComponent::SetValue( mxDoc, rVarCell, 0.0 ); } // read initial values from all dependent cells - ScSolverCellHashMap::iterator aCellsIter; - for ( aCellsIter = aCellsHash.begin(); aCellsIter != aCellsHash.end(); ++aCellsIter ) + for ( auto& rEntry : aCellsHash ) { - double fValue = SolverComponent::GetValue( mxDoc, aCellsIter->first ); - aCellsIter->second.push_back( fValue ); // store as first element, as-is + double fValue = SolverComponent::GetValue( mxDoc, rEntry.first ); + rEntry.second.push_back( fValue ); // store as first element, as-is } // loop through variables - for ( aVarIter = aVariableCells.begin(); aVarIter != aVariableCells.end(); ++aVarIter ) + for ( const auto& rVarCell : aVariableCells ) { - SolverComponent::SetValue( mxDoc, *aVarIter, 1.0 ); // set to 1 to examine influence + SolverComponent::SetValue( mxDoc, rVarCell, 1.0 ); // set to 1 to examine influence // read value change from all dependent cells - for ( aCellsIter = aCellsHash.begin(); aCellsIter != aCellsHash.end(); ++aCellsIter ) + for ( auto& rEntry : aCellsHash ) { - double fChanged = SolverComponent::GetValue( mxDoc, aCellsIter->first ); - double fInitial = aCellsIter->second.front(); - aCellsIter->second.push_back( fChanged - fInitial ); + double fChanged = SolverComponent::GetValue( mxDoc, rEntry.first ); + double fInitial = rEntry.second.front(); + rEntry.second.push_back( fChanged - fInitial ); } - SolverComponent::SetValue( mxDoc, *aVarIter, 2.0 ); // minimal test for linearity + SolverComponent::SetValue( mxDoc, rVarCell, 2.0 ); // minimal test for linearity - for ( aCellsIter = aCellsHash.begin(); aCellsIter != aCellsHash.end(); ++aCellsIter ) + for ( const auto& rEntry : aCellsHash ) { - double fInitial = aCellsIter->second.front(); - double fCoeff = aCellsIter->second.back(); // last appended: coefficient for this variable - double fTwo = SolverComponent::GetValue( mxDoc, aCellsIter->first ); + double fInitial = rEntry.second.front(); + double fCoeff = rEntry.second.back(); // last appended: coefficient for this variable + double fTwo = SolverComponent::GetValue( mxDoc, rEntry.first ); bool bLinear = rtl::math::approxEqual( fTwo, fInitial + 2.0 * fCoeff ) || rtl::math::approxEqual( fInitial, fTwo - 2.0 * fCoeff ); @@ -165,7 +163,7 @@ void SAL_CALL LpsolveSolver::solve() maStatus = SolverComponent::GetResourceString( RID_ERROR_NONLINEAR ); } - SolverComponent::SetValue( mxDoc, *aVarIter, 0.0 ); // set back to zero for examining next variable + SolverComponent::SetValue( mxDoc, rVarCell, 0.0 ); // set back to zero for examining next variable } xModel->unlockControllers(); |