Efficiently extracting rows from VectorAffineFunction structs in MOI

The MOI.VectorAffineFunction type is used to define linear vector valued functions in MathOptInterface. I am trying to extract a row of such an object itself with type VectorAffineFunction, for example with f = MOI.VectorAffineFunction( [MOI.VectorAffineTerm(1, MOI.ScalarAffineTerm(1, y)), MOI.VectorAffineTerm(2, MOI.ScalarAffineTerm(1, x1)), MOI.VectorAffineTerm(2, MOI.ScalarAffineTerm(10, x2)), ], [0.0, 0.0], ) Is there a good way of doing this? I am trying to avoid messing around too much with loops over the output index for each term.

Loops over the output index are the way to go.

If f is a MOI.VectorAffineFunction and i is an integer between 1 and MOI.output_dimension(f) then MOI.Utilities.eachscalar(f)[i] gives a MOI.ScalarAffineFunction and MOI.Utilities.eachscalar(f)[[i]] gives a MOI.VectorAffineFunction


Ah, I keep forgetting about eachscalar.