Skip to content

Overhead using highspy #1277

@jajhall

Description

@jajhall

I'm just calling your attention to a potential pitfall for users of highspy, which is that accessing solution.col_value[icol] is a quite slow operation, I guess because of some overhead in pybind11. Doing over 100k independent accesses to retrieve a solution takes a few minutes, but can be reduced to milliseconds by first converting to a Python list and accessing that instead.

I made the relevant change in PuLP recently since whoever wrote the interface had made that mistake which was obviously a massive and avoidable overhead.
coin-or/pulp#641

Perhaps it should remain the responsibility of consumers of highspy to be aware of and manage, but you could consider implementing something like a solution.col_values() function that returns a python list of values. Wouldn't even need to be cached as that introduces a risk of invalidation. I'd be happy to implement it and open a PR, but I wasn't sure what your policy would be on unsolicited feature PRs(?). In general I hope to be a contributor to HiGHS in the near future 🙂.

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions