Skip to content

Python: vector/matrix APIs for adding variables/constraints on mathopt Model #5179

Description

@nardi-gradyent

What language and solver does this apply to?
Python, all solvers (mathopt interface).

Describe the problem you are trying to solve.
I have some large LPs/QPs (say ~50000 constraints) in a matrix form in my Python code (numpy/scipy arrays). I'd like to use MathOpt as a layer between my code and the actual solver, but the APIs on Model being scalar-only makes the overhead of constructing the Model quite large, even though the final representation should be close to what I already have.

Describe the solution you'd like
I see that Elemental already has vectorized APIs, e.g. both add_element and add_elements, so it seems logical to me that Model could similarly have add_variables that can be used to add a large number of variables at once, and the same for constraints.

Describe alternatives you've considered
I could use Elemental directly to build the proto describing the model, but at that point I'm basically building this interface myself :)

Additional context
I see that this issue has been raised before (#1020), though quite long ago and in the context of pywraplp.

Metadata

Metadata

Assignees

Labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions