Files
odfstudio/sc/CppunitTest_sc_swarmsolvertest.mk
Tomaž Vajngerl 67b9784801 SwarmSolver: fix PSO position and velocity handling
Three problems in the particle swarm code:

The best-position vectors were updated with insert at the front rather
than assign, so each improvement prepended another copy. The vectors
grew on every step and the returned solution ended up longer than the
number of variables.

The velocity was seeded from initializeVariables, which fills it with a
random position. The first step then moved each particle by a whole
coordinate. The velocity now starts at zero.

The result of clamping the velocity was thrown away, so the call did
nothing. Clamping the velocity to the position bounds would in fact be
wrong when the bounds do not straddle zero, so the dead call is removed
and a comment explains why the velocity is left alone.

Also drops a redundant second clamp of the position during setup.

Tests drive the algorithm through a small mock data provider so the
checks do not depend on the random seed: one asserts the result has one
value per variable, the other asserts setup calls initializeVariables
once per particle. The large-objective test now runs Particle Swarm
Optimization too.

Signed-off-by: Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>
Change-Id: I8197aa3368d20108c06bd3643ef1138ac6f2254a
Reviewed-on: https://gerrit.collaboraoffice.com/c/online/+/4050
Tested-by: Tomaž Vajngerl <tomaz.vajngerl@collabora.com>
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
(cherry picked from commit 9353efb6419c16f0bcb104e57c4eb08ddcb4da81)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/208435
Tested-by: Xisco Fauli <xiscofauli@libreoffice.org>
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
2026-07-22 21:51:22 +02:00

74 lines
1.5 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/.
#
$(eval $(call gb_CppunitTest_CppunitTest,sc_swarmsolvertest))
$(eval $(call gb_CppunitTest_add_exception_objects,sc_swarmsolvertest,\
sc/qa/unit/SwarmSolverTest \
))
$(eval $(call gb_CppunitTest_use_externals,sc_swarmsolvertest,\
libxml2 \
))
$(eval $(call gb_CppunitTest_use_libraries,sc_swarmsolvertest,\
basegfx \
comphelper \
cppu \
cppuhelper \
drawinglayer \
editeng \
for \
forui \
i18nlangtag \
msfilter \
oox \
sal \
salhelper \
sax \
sb \
sc \
scqahelper \
sfx \
sot \
subsequenttest \
svl \
svt \
svx \
svxcore \
test \
tk \
tl \
ucbhelper \
unotest \
utl \
$(call gb_Helper_optional,SCRIPTING, \
vbahelper) \
vcl \
xo \
$(gb_UWINAPI) \
))
$(eval $(call gb_CppunitTest_set_include,sc_swarmsolvertest,\
-I$(SRCDIR)/sc/inc \
-I$(SRCDIR)/sc/source/solver \
$$(INCLUDE) \
))
$(eval $(call gb_CppunitTest_use_sdk_api,sc_swarmsolvertest))
$(eval $(call gb_CppunitTest_use_ure,sc_swarmsolvertest))
$(eval $(call gb_CppunitTest_use_vcl,sc_swarmsolvertest))
$(eval $(call gb_CppunitTest_use_rdb,sc_swarmsolvertest,services))
$(eval $(call gb_CppunitTest_use_configuration,sc_swarmsolvertest))
# vim: set noet sw=4 ts=4: