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>
9 lines
319 B
Plaintext
9 lines
319 B
Plaintext
# 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/.
|
|
|
|
com.sun.star.comp.Calc.CoinMPSolver
|
|
com.sun.star.comp.Calc.SLPSolver
|