Ah. That explains it:
julia> using JuMP, LinearAlgebra
julia> model = Model();
julia> @variable(model, an[1:2], Bin);
julia> @variable(model, ACR[1:2, 1:2], Int);
julia> flows = ones(2, 2);
julia> @constraint(model, ACR .<= Diagonal(1 .- an) * flows)
ERROR: MethodError: Cannot `convert` an object of type QuadExpr to an object of type AffExpr
Closest candidates are:
convert(::Type{GenericAffExpr{T, V}}, ::GenericAffExpr{T, V}) where {T, V} at /Users/oscar/.julia/packages/JuMP/Y4piv/src/aff_expr.jl:521
convert(::Type{GenericAffExpr{T, V}}, ::GenericAffExpr{S, V}) where {S, T, V} at /Users/oscar/.julia/packages/JuMP/Y4piv/src/aff_expr.jl:528
convert(::Type{GenericAffExpr{T, V}}, ::Union{Number, UniformScaling}) where {T, V} at /Users/oscar/.julia/packages/JuMP/Y4piv/src/aff_expr.jl:517
...
Stacktrace:
[1] setindex!
@ ./array.jl:845 [inlined]
[2] setindex!
@ ./multidimensional.jl:645 [inlined]
[3] macro expansion
@ ./broadcast.jl:984 [inlined]
[4] macro expansion
@ ./simdloop.jl:77 [inlined]
[5] copyto!
@ ./broadcast.jl:983 [inlined]
[6] copyto!
@ ./broadcast.jl:936 [inlined]
[7] materialize!
@ ./broadcast.jl:894 [inlined]
[8] materialize!
@ ./broadcast.jl:891 [inlined]
[9] lmul!(D::Diagonal{AffExpr, Vector{AffExpr}}, B::Matrix{AffExpr})
@ LinearAlgebra /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.6/LinearAlgebra/src/diagonal.jl:212
[10] *(D::Diagonal{AffExpr, Vector{AffExpr}}, A::Matrix{Float64})
@ LinearAlgebra /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.6/LinearAlgebra/src/diagonal.jl:201
[11] macro expansion
@ ~/.julia/packages/MutableArithmetics/Lnlkl/src/rewrite.jl:294 [inlined]
[12] macro expansion
@ ~/.julia/packages/JuMP/Y4piv/src/macros.jl:823 [inlined]
[13] top-level scope
@ REPL[8]:1
This is another case of LinearAlgebra matrix types and expressions · Issue #66 · jump-dev/MutableArithmetics.jl · GitHub.
The work-around is to wrap Diagonal in Matrix:
julia> using JuMP, LinearAlgebra
julia> model = Model();
julia> @variable(model, an[1:2], Bin);
julia> @variable(model, ACR[1:2, 1:2], Int);
julia> flows = ones(2, 2);
julia> @constraint(model, ACR .<= Matrix(Diagonal(1 .- an)) * flows)
2×2 Matrix{ConstraintRef{Model, MathOptInterface.ConstraintIndex{MathOptInterface.ScalarAffineFunction{Float64}, MathOptInterface.LessThan{Float64}}, ScalarShape}}:
an[1] + ACR[1,1] ≤ 1.0 an[1] + ACR[1,2] ≤ 1.0
an[2] + ACR[2,1] ≤ 1.0 an[2] + ACR[2,2] ≤ 1.0