ERGO-Code / HiGHS

Linear optimization software
MIT License
935 stars 174 forks source link

Setting initial solution in highspy #1936

Open jajhall opened 5 days ago

jajhall commented 5 days ago

Discussed in https://github.com/ERGO-Code/HiGHS/discussions/1933

Originally posted by **Dimjoy** September 18, 2024 Hello! As far as I understand, currently there are two call signatures for `setSolution` method (according to _core.pyi file): ``` @overload def setSolution(self, arg0: HighsSolution) -> HighsStatus: ... @overload def setSolution(self, arg0: int, arg1: numpy.ndarray[numpy.int32], arg2: numpy.ndarray[numpy.float64]) -> HighsStatus: ... ``` Apparently, the second mimics `Highs_setSparseSolution` method from the C API. I am trying to use it for a simple LP-problem from the Examples section of the Guide (2 continuous variables and 2 constraints) with the following line of code: ``` h.setSolution(1, np.array([0]), np.array([3.1])) ``` which fails with the following error message: >TypeError: setSolution(): incompatible function arguments. The following argument types are supported: 1. (self: highspy._core._Highs, arg0: HighsSolution) -> highspy._core.HighsStatus Invoked with: , 1, array([0]), array([3.1]) Am I doing it wrong? Or setting partial solution is not supported right now in the Python API?
mathgeekcoder commented 1 day ago

FYI: I can reproduce this issue with the currently released version of highspy. However, it seems to work with the latest changes in #1942.