@@ -2166,17 +2166,23 @@ function MOI.modify(
2166
2166
cols = Vector {Cint} (undef, nels)
2167
2167
coefs = Vector {Cdouble} (undef, nels)
2168
2168
for i in 1 : nels
2169
- row = Cint (_info (model, cis[i]). row)
2170
- col = column (model, changes[i]. variable)
2169
+ rows[i] = Cint (_info (model, cis[i]). row)
2170
+ cols[i] = column (model, changes[i]. variable)
2171
+ coefs[i] = changes[i]. new_coefficient
2172
+ end
2173
+ for row in unique (rows)
2171
2174
nnz = glp_get_mat_row (model, row, C_NULL , C_NULL )
2172
2175
indices, coefficients = zeros (Cint, nnz), zeros (Cdouble, nnz)
2173
2176
glp_get_mat_row (model, row, offset (indices), offset (coefficients))
2174
- index = something (findfirst (isequal (col), indices), 0 )
2175
- if index > 0
2176
- coefficients[index] = changes[i]. new_coefficient
2177
- else
2178
- push! (indices, cols[i])
2179
- push! (coefficients, changes[i]. new_coefficient)
2177
+ idxs_changed_in_row = findall (x -> x == row, rows)
2178
+ for i in idxs_changed_in_row
2179
+ index = something (findfirst (isequal (cols[i]), indices), 0 )
2180
+ if index > 0
2181
+ coefficients[index] = coefs[i]
2182
+ else
2183
+ push! (indices, cols[i])
2184
+ push! (coefficients, coefs[i])
2185
+ end
2180
2186
end
2181
2187
glp_set_mat_row (
2182
2188
model,
0 commit comments