Sparse path for the objective
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 52/100
- Issue type
- Feature
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- python
- Domain
- backend, performance
Research direction
Read Objective.expression in linopy/objective.py:174-198 and Model.add_objective in linopy/model.py:1503, then inspect the CSRConstraint.to_polars and to_matrix_with_rhs paths. Account for the separately filed sparse sum work in #756. Done means a CSR-backed objective avoids dense materialization and reaches matrices.c and io.objective_write with its flat coefficient and variable arrays.
Written by the indexing model from the issue text.
Description
[!NOTE]
The following content was generated by AI.
Describe the feature you'd like to see
Give the objective a sparse path. Child of #756.
There is none today. Objective.expression (linopy/objective.py:174-198) calls expr.sum() and then expr.const, both of which go through LinearExpression.data and materialise the dense rectangle, dropping any CSR backing. Model.add_objective (linopy/model.py:1503) has no CSR handling at all.
So even a model whose constraints stay sparse end to end pays a full densification for its objective. The objective is a single full contraction to a scalar-ish expression, which is the case the CSR kernel handles best.
Implementation ideas
Depends on sparse sum (filed separately). Once sum() over all dims keeps the backing, the objective setter needs to accept a CSR-backed expression and hand the flat coefficient and variable arrays to matrices.c and io.objective_write directly, in the same spirit as CSRConstraint.to_polars / to_matrix_with_rhs.
- Dominant language
- Python
- Stars
- 257
- Forks
- 87
- Avg merge
- 1d 8h
- Merged PRs (30d)
- 32
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from PyPSA/linopy
-
bug solver interface
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
performance sparse
Difficulty 5/5 Over a week Newbie friendliness 25/100
-
documentation sparse
Difficulty 3/5 1-2 days Newbie friendliness 68/100
-
enhancement sparse
Difficulty 4/5 3-5 days Newbie friendliness 48/100
-
Make the sparse path observable and controllable (.is_sparse, densify warning, per-call sparse=) Openenhancement sparse
Difficulty 5/5 Over a week Newbie friendliness 35/100
Similar issues
-
bug confirmed issue
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
open-webui/open-webui#30750 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
OpenwaterHealth/openmotion-bloodflow-app#604 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
good first issue
Difficulty 1/5 Under an hour Newbie friendliness 90/100