The solver components reached every cell through the spreadsheet UNO API: getSheets, then getByIndex for the sheet, then getCellByPosition, each with a QueryInterface. That indirection is cheap once but expensive when it runs for every variable on every evaluation. Now that the solvers live in sc, recover the ScDocument from the document through the UNO tunnel (ScModelObj) in setDocument and read and write cells directly with ScDocument::SetValue and GetValue. Automatic recalculation is turned on there as well, so writing the input cells and then reading the recalculated objective and constraint cells behaves exactly as before. Both the shared SolverComponent base (used by the CoinMP solver) and the standalone SwarmSolver are converted. The results are unchanged because the recalculation engine is the same. Only the cost of getting values in and out of the document drops. The swarm solver evaluates the objective for a whole population every generation, so this is its hot path: on a 100-variable model its evaluation loop runs about four times faster. CoinMP touches the cells only once, in a single pass that reads off the linear coefficients, so it gains less, about 1.7 times faster on the same model. Library_solver now links sc and includes sc/inc. SwarmSolver keeps the UNO cell lookup only for the uncommon case where a constraint's right-hand side is given as a cell address. Signed-off-by: Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> Change-Id: I03ccec74cdc4d6cde30c86e048bf4314c3ca1397 Reviewed-on: https://gerrit.collaboraoffice.com/c/online/+/4047 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Tomaž Vajngerl <tomaz.vajngerl@collabora.com> (cherry picked from commit 929c17cf8e51a1510c32399de4a94ba946bb9919) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/208281 Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org> Tested-by: Jenkins
58 lines
1.6 KiB
Makefile
58 lines
1.6 KiB
Makefile
# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
|
|
#
|
|
# This file is part of the LibreOffice project.
|
|
#
|
|
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
#
|
|
# This file incorporates work covered by the following license notice:
|
|
#
|
|
# Licensed to the Apache Software Foundation (ASF) under one or more
|
|
# contributor license agreements. See the NOTICE file distributed
|
|
# with this work for additional information regarding copyright
|
|
# ownership. The ASF licenses this file to you under the Apache
|
|
# License, Version 2.0 (the "License"); you may not use this file
|
|
# except in compliance with the License. You may obtain a copy of
|
|
# the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
#
|
|
|
|
$(eval $(call gb_Library_Library,solver))
|
|
|
|
$(eval $(call gb_Library_set_componentfile,solver,sc/source/solver/solver,services))
|
|
|
|
$(eval $(call gb_Library_add_componentimpls,solver, \
|
|
$(if $(ENABLE_COINMP),coinmp) \
|
|
))
|
|
|
|
$(eval $(call gb_Library_use_sdk_api,solver))
|
|
|
|
$(eval $(call gb_Library_set_include,solver,\
|
|
$$(INCLUDE) \
|
|
-I$(SRCDIR)/sc/inc \
|
|
-I$(SRCDIR)/sc/source/solver \
|
|
))
|
|
|
|
$(eval $(call gb_Library_use_libraries,solver,\
|
|
comphelper \
|
|
cppu \
|
|
cppuhelper \
|
|
sal \
|
|
sc \
|
|
utl \
|
|
i18nlangtag \
|
|
))
|
|
|
|
$(eval $(call gb_Library_use_externals,solver,\
|
|
boost_headers \
|
|
coinmp \
|
|
))
|
|
|
|
$(eval $(call gb_Library_add_exception_objects,solver,\
|
|
sc/source/solver/SwarmSolver \
|
|
sc/source/solver/SolverComponent \
|
|
$(if $(ENABLE_COINMP), sc/source/solver/CoinMPSolver) \
|
|
))
|
|
|
|
# vim: set noet sw=4 ts=4:
|