This adds a second nonlinear solver alongside the swarm one. It treats the model as a black box and converges by repeated linearization, which suits smooth models and reuses the linear solver already shipped. SLPSolver linearizes with a private SampleAffineModel helper. Around a given point it approximates the objective and every constraint cell with an affine model: a constant plus a slope for each variable. It finds the slopes by nudging one variable at a time and measuring how the cell value changes. The result uses the layout the CoinMP helper expects: the constant term first (the value when all variables are zero), then the slope for each variable. SLPSolver runs the outer loop. Each iteration linearizes around the current point, bounds the step to a trust region scaled per variable, and solves that linear problem with the shared CoinMP helper. A merit function that adds a penalty for constraint violation decides whether to accept the step, and the trust radius grows or shrinks with how well the linear model predicted the real change. Success is reported only when the final point satisfies the constraints. The solver is registered as com.sun.star.comp.Calc.SLPSolver in the CoinMP component group, so it is present only when CoinMP is built. Tests: the solver solves a plain linear model, and minimizes a parabola held in a formula cell, converging to its known minimum. Signed-off-by: Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> Change-Id: I2f79961844abbdd1412a318f1e4116995ea35955 Reviewed-on: https://gerrit.collaboraoffice.com/c/online/+/4649 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Tomaž Vajngerl <tomaz.vajngerl@collabora.com> (cherry picked from commit a416cbede28604d2d7203113ce80d504aceb49f1) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/208338 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
60 lines
1.7 KiB
Makefile
60 lines
1.7 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) \
|
|
$(if $(ENABLE_COINMP), sc/source/solver/CoinMPModel) \
|
|
$(if $(ENABLE_COINMP), sc/source/solver/SlpSolver) \
|
|
))
|
|
|
|
# vim: set noet sw=4 ts=4:
|