Skip to content

Conversation

@odow
Copy link
Member

@odow odow commented Mar 5, 2025

#2553 got complicated to debug because of this 😄

Without this PR, this code:

scalars = MOI.Utilities.eachscalar(func)
t, x = scalars[1], scalars[2:end]
# Create f_new = [-x; x].
f_new = MOI.Utilities.operate(vcat, T, MOI.Utilities.operate(-, T, x), x)
# Add +t to each row of x
for i in 1:(2*(length(scalars)-1))
MOI.Utilities.operate_output_index!(+, T, i, f_new, t)
end

modifies the user's input function.

elseif a isa MOI.AbstractScalarFunction
push!(out, a)
else
append!(out, scalarize(a))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need to copy if it's the output of scalarize, I would rather copy in the two push! above

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need to copy if it's the output of scalarize

Ah but you do if you hit this method MOI.Utilities.scalarize(f::MOI.VectorNonlinearFunction) = f.rows.

The question of whether scalarize and vectorize are mutable hasn't really come up before, because they always produced unique objects.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😨

@odow odow merged commit f31be21 into master Mar 6, 2025
31 checks passed
@odow odow deleted the od/vcat branch March 6, 2025 01:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants