Open timellemeet opened 7 months ago
In short, I don't know whether we can return anything other than native python lists when using pybind11
to create a Python interface. We're not pybind11
experts.
We're talking to the person who created the prototype of highspy
tomorrow, so I'll flag it up
This could be done on the c++ side by creating a new solution object for the python interface, but it would still require copying the std::vectors into arrays. That is probably faster than creating a python list and then converting it to a numpy array, but I'd be surprised if it was significantly faster. I can give it a go (probably in a couple of weeks).
Thank you! Even if it's not noticeably faster I would say it is a usability improvement.
Enchancement idea:
When using the python interface, calling
getSolution()
gives an object with native python lists instead of numpy arrays:I expect most users will after convert these to numpy arrays for further processing. In my use cases, column generation, this actually results in a small but noticeable performance decrease.
Considering during model construction we also pass numpy arrays, I think it would be both more consistent and desired to also get numpy arrays from these outputs.
Not sure if implementing it in highspy you can actually do it in a more efficient way then just doing np.array() though.