Open cohnt opened 1 week ago
@cohnt Currently UpdateCoefficients
just copies the new coefficient vector to the internally held vector. I think you are suggesting something like this
LinearCost::UpdateCoefficientEntry(int i, double val) {
a_[i] = val;
}
I wonder why this "update-in-place" is more efficient than copying a vector?
That method would be perfect for what I need.
If we have a large vector and we only need to change one or two entries of it (as in the generic ConvexSet::IsBounded
method), I would think it's significantly faster to just modify the entry, rather than keeping an entirely separate vector around, changing the entry there, and then copying it in.
In scenarios where we're solving a sequence of similar mathematical programs (e.g. #22084), we have to copy over the entire coefficient vector to update the cost. It would be much more efficient if we could just modify the internally held coefficient vector in-place. I specifically care about LinearCost, but I imagine it would be applicable to other costs as well.
cc @AlexandreAmice