Bug 165802 - Linear Solver claims that "solving successfully finished" for a non-linear problem but the 'solution' violates a constraint
Summary: Linear Solver claims that "solving successfully finished" for a non-linear pr...
Status: RESOLVED NOTABUG
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
24.8.5.2 release
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: Solver
  Show dependency treegraph
 
Reported: 2025-03-18 11:37 UTC by pg_78
Modified: 2025-03-20 14:34 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments
Spreadsheet with a model that demonstrates the bug (10.06 KB, application/vnd.oasis.opendocument.spreadsheet)
2025-03-18 11:40 UTC, pg_78
Details

Note You need to log in before you can comment on or make changes to this bug.
Description pg_78 2025-03-18 11:37:51 UTC
Description:
The attached workbook demonstrates an optimisation problem with a non-linearity.

When using the "LibreOffice Linear Solver" on this problem, Calc reports that "solving successfully finished". But the "solution" violates the constraint that B14=0.

To be clear, the bug is not that a linear solver can't solve this problem. The bug is that Calc reports success - what it should do is to detect that the 'solution' violates a constraint, and report that.

Steps to Reproduce:
Open the attached spreadsheet, and run the model with the given Solver settings (i.e. maximise cell D12 by varying B10 and B11, subject to the constraint B14=0, assuming the variables are non-negative, using “LibreOffice Linear Solver”)

Actual Results:
Calc reports that “solving successfully finished”, but the “solution” violates the constraint that B14=0.

Expected Results:
Calc should report that no acceptable solution can be found. (Due to the non-linear dependence of B9 on B10, a linear algorithm is not expected to be able to find a solution - that's not a problem. The problem is that the solver reports that it has succeeded, when it hasn't.)


Reproducible: Always


User Profile Reset: No

Additional Info:
Version: 24.8.5.2 (X86_64)
Build ID: 480(Build:2)
CPU threads: 16; OS: Linux 6.12; UI render: default; VCL: kf6 (cairo+wayland)
Locale: en-CA (en_US.UTF-8); UI: en-US
Calc: threaded
Comment 1 pg_78 2025-03-18 11:40:14 UTC
Created attachment 199869 [details]
Spreadsheet with a model that demonstrates the bug
Comment 2 Olivier Hallot 2025-03-20 13:53:49 UTC
The issue begins with the a bad choice of the solver algorithm, a linear solver applied to a non-linear problem.

In logic, if the hypothesis is wrong the results are whatever. The solution could have converged, diverged, get multiple minima or maxima, no one knows.

Although I sympathize with the idea of warning user on his mistake, it will require an enormous amount of work/coding to detect a bad-formulated linear problem.
Comment 3 pg_78 2025-03-20 14:34:52 UTC
It would indeed take a lot of work to implement generalised logic that detects all cases where a linear solver is applied to a non-linear problem.

However, this bug is intended to be much more narrowly defined and tractable than that. The scope is specifically the situation where the "solution" to the problem violates an explicit constraint of the model. In the example attached, the model has a constraint B14=0, but the "solution" produced has B14!=0.

In this situation, before presenting the solution to the user and applying it to the sheet, it should be possible to do a final check that evaluates each constraint against the solution produced by the solver. If any constraint is violated, then reject the solution and advise the user that no solution could be found.