Bug 128075 - Solver finds solutions for negative goals but "thinks" it has failed
Summary: Solver finds solutions for negative goals but "thinks" it has failed
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
6.1.6.3 release
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: Solver
  Show dependency treegraph
 
Reported: 2019-10-10 13:59 UTC by OfficeUser
Modified: 2024-05-09 20:06 UTC (History)
0 users

See Also:
Crash report or crash signature:


Attachments
issue_solver.ods (100.71 KB, application/vnd.oasis.opendocument.spreadsheet)
2019-10-10 13:59 UTC, OfficeUser
Details
Test file with missing values in the constraints range. (50.58 KB, application/vnd.oasis.opendocument.spreadsheet)
2021-08-08 09:28 UTC, Todor Balabanov
Details
Test setup screen 1. (421.84 KB, image/png)
2021-08-08 09:29 UTC, Todor Balabanov
Details
Test setup screen 2. (453.80 KB, image/png)
2021-08-08 09:30 UTC, Todor Balabanov
Details
Test setup screen 3. (506.03 KB, image/png)
2021-08-08 09:30 UTC, Todor Balabanov
Details
Test setup screen 4. (508.86 KB, image/png)
2021-08-08 09:31 UTC, Todor Balabanov
Details
Test setup screen 5. (472.21 KB, image/png)
2021-08-08 09:32 UTC, Todor Balabanov
Details
Test setup screen 6. (426.63 KB, image/png)
2021-08-08 09:32 UTC, Todor Balabanov
Details
Test setup screen 7. (455.09 KB, image/png)
2021-08-08 09:33 UTC, Todor Balabanov
Details
Test setup screen 8. (497.57 KB, image/png)
2021-08-08 09:34 UTC, Todor Balabanov
Details
Test setup screen 9. (477.44 KB, image/png)
2021-08-08 09:34 UTC, Todor Balabanov
Details
Minimization of absolute difference. (100.89 KB, application/vnd.oasis.opendocument.spreadsheet)
2021-10-16 10:46 UTC, Georgi Banov
Details

Note You need to log in before you can comment on or make changes to this bug.
Description OfficeUser 2019-10-10 13:59:57 UTC
Created attachment 154900 [details]
issue_solver.ods

Please open the attached spreadsheet. It contains all steps...


Version: 6.3.2.2
Build-ID: 98b30e735bda24bc04ab42594c85f7fd8be07b9c
CPU-Threads: 8; BS: Linux 4.4; UI-Render: Standard; VCL: gtk2; 
Gebietsschema: de-DE (de_DE.UTF-8); UI-Sprache: de-DE
Calc: threaded
Comment 1 Katarina Behrens (Inactive) 2019-10-15 14:18:12 UTC
Yep, as described

Version: 6.1.6.3
Build ID: 6.1.6.3-4.fc29
CPU threads: 8; OS: Linux 5.2; UI render: default; VCL: kde4; 
Locale: en-US (en_US.UTF-8); Calc: group threaded
Comment 2 OfficeUser 2019-10-16 06:58:23 UTC
@Katarina: Thanks for confirming. I think a patch should NOT be very complicated...
Comment 3 Todor Balabanov 2021-08-05 12:18:27 UTC
The bug still exists. I have track it to two possible reasons:

m_success = (m_objectiveCell.getError() == 0 && checkConstraints());

The model has no constraints. It seems that some fake error appears in the objective cell.
Comment 4 Todor Balabanov 2021-08-08 09:28:30 UTC
Created attachment 174132 [details]
Test file with missing values in the constraints range.
Comment 5 Todor Balabanov 2021-08-08 09:29:37 UTC
Created attachment 174133 [details]
Test setup screen 1.
Comment 6 Todor Balabanov 2021-08-08 09:30:08 UTC
Created attachment 174134 [details]
Test setup screen 2.
Comment 7 Todor Balabanov 2021-08-08 09:30:50 UTC
Created attachment 174135 [details]
Test setup screen 3.
Comment 8 Todor Balabanov 2021-08-08 09:31:30 UTC
Created attachment 174136 [details]
Test setup screen 4.
Comment 9 Todor Balabanov 2021-08-08 09:32:13 UTC
Created attachment 174137 [details]
Test setup screen 5.
Comment 10 Todor Balabanov 2021-08-08 09:32:53 UTC
Created attachment 174138 [details]
Test setup screen 6.
Comment 11 Todor Balabanov 2021-08-08 09:33:38 UTC
Created attachment 174139 [details]
Test setup screen 7.
Comment 12 Todor Balabanov 2021-08-08 09:34:06 UTC
Created attachment 174140 [details]
Test setup screen 8.
Comment 13 Todor Balabanov 2021-08-08 09:34:35 UTC
Created attachment 174141 [details]
Test setup screen 9.
Comment 14 Georgi Banov 2021-10-16 10:44:58 UTC
I have checked the functions calls and the problem comes from the fact that the exact value is searched. 

https://github.com/LibreOffice/core/blob/2484de6728bd11bb7949003d112f1ece2223c7a1/sc/source/ui/miscdlgs/optsolver.cxx#L966

The equality target is converted to extra constraint, which gives not found solution after that.

    if ( m_xRbValue->get_active() )
    {
        // handle "value of" with an additional constraint (and then minimize)

        sheet::SolverConstraint aConstraint;
        aConstraint.Left     = aObjective;
        aConstraint.Operator = sheet::SolverConstraintOperator_EQUAL;

        OUString aValStr = m_xEdTargetValue->GetText();
        ScRange aRightRange;
        if ( ParseRef( aRightRange, aValStr, false ) )
            aConstraint.Right <<= table::CellAddress( aRightRange.aStart.Tab(),
                                                      aRightRange.aStart.Col(), aRightRange.aStart.Row() );
        else
        {
            sal_uInt32 nFormat = 0;     //! explicit language?
            double fValue = 0.0;
            if ( mrDoc.GetFormatTable()->IsNumberFormat( aValStr, nFormat, fValue ) )
                aConstraint.Right <<= fValue;
            else
            {
                ShowError( false, m_xEdTargetValue.get() );
                return false;
            }
        }

        aConstraints.realloc( nConstrPos + 1 );
        aConstraints[nConstrPos++] = aConstraint;
    }

The problem does not exists if target is converted to minimization of absolute difference.
Comment 15 Georgi Banov 2021-10-16 10:46:50 UTC
Created attachment 175778 [details]
Minimization of absolute difference.
Comment 16 QA Administrators 2023-10-17 03:13:54 UTC Comment hidden (obsolete)
Comment 17 Todor Balabanov 2024-05-09 20:06:22 UTC
The bug is still there.

Version: 24.8.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: 73229b441f0f0aa6ab4e3ae051f9d09f683361fc
CPU threads: 4; OS: Linux 6.5; UI render: default; VCL: gtk3
Locale: en-US (en_US.UTF-8); UI: en-US
Calc: CL threaded