Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accelerate summation of variables #32

Open
TiloW opened this issue Jan 6, 2025 · 3 comments · May be fixed by #36
Open

Accelerate summation of variables #32

TiloW opened this issue Jan 6, 2025 · 3 comments · May be fixed by #36
Labels
enhancement New feature or request good first issue Good for newcomers
Milestone

Comments

@TiloW
Copy link
Collaborator

TiloW commented Jan 6, 2025

Summing up variables via linear expression's operator += takes a lot of runtime. It would be nice to have a method that quickly creates a sum from a range of variables.

@hedtke
Copy link
Collaborator

hedtke commented Jan 7, 2025

An idea is to add an additional c'tor so that multiple variables together create one linear expression. Just sketching:

LinExpr(const std::span<Var>& vars);
LinExpr(const std::span<Var>& vars, const std::span<double>& coeffs);

@hedtke hedtke added enhancement New feature or request good first issue Good for newcomers labels Jan 7, 2025
@hedtke
Copy link
Collaborator

hedtke commented Jan 7, 2025

This requires an update to C++20, and is a bit ugly, at least my first idea: see branch issue-32-speedup-linexpr

@hedtke hedtke added this to the 2.0.0 milestone Jan 7, 2025
@hedtke hedtke linked a pull request Jan 7, 2025 that will close this issue
@TonyCongqianWang
Copy link

I think spans are great, but moving to cxx 20 is a big change. Maybe it suffices to use iterator starts and ends?

@hedtke hedtke linked a pull request Jan 27, 2025 that will close this issue
@hedtke hedtke modified the milestones: 2.0.0, 1.3.0 Jan 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants