SCIPpp icon indicating copy to clipboard operation
SCIPpp copied to clipboard

Accelerate summation of variables

Open TiloW opened this issue 1 year ago • 3 comments

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.

TiloW avatar Jan 06 '25 14:01 TiloW

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 avatar Jan 07 '25 11:01 hedtke

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

hedtke avatar Jan 07 '25 13:01 hedtke

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

TonyCongqianWang avatar Jan 07 '25 16:01 TonyCongqianWang