Solver results

Hi,
I wrote short macro solving simple linear optimization problem and I face strange behavior running it:

  1. If I choose NLPSolver (by calling ‘CreateUnoService(“com.sun.star.comp.Calc.NLPSolver.SCOSolverImpl”)’) model is solved and results are saved in sheet (value of objective cell, variables and constrants) – all works well.
  2. If I choose CoinMPSolver model is solved (I can retrive results from the Solver object), but cells in sheet are unattached - all variables, constraints and objective are set to 0.

So, the question is: what should I set in case of linear solver to have results stored in cells of sheet?

I use LO 6.1.5.2 Build ID: 1:6.1.5-1 on Debian 64.

Regards,
Marcin

Marcinie,
NLPSolver is usable (not in all problems). Please treat others as experimental.
If you may have found a specific community dedicated to calc solver development, please let me know. There is much to be done.
These problems are now recurring. Upgrading to Linux Mint 21 opened this issue from the beginning. As of today, I don’t have a macro script solver that works fine.
Antoni

See also

tdf#70399

https://ask.libreoffice.org/t/is-there-any-way-to-save-a-solver-model-in-calc-again/77249

https://ask.libreoffice.org/t/api-reference-com-sun-star-comp-calc/54686

We can do it like this:

' ---
  With oSolver
    .Solve()
    If .Success Then
      vars=.Variables
      solution=.Solution
      sheets=.Document.Sheets
      For i=0 To Ubound(vars)
        With vars(i)
          sheets.getCellByPosition(.Column, .Row, .Sheet).setValue solution(i)
        End With
      Next i
    End If      
  End With