I wrote a very simple program
using JuMP
model=Model(Gurobi.Optimizer)
@variable(model,0<=w<=1,Int)
@variable(model,0<=x[1:2,1:2]<=10)
@constraint(model,w*x>=0)
@objective(model,Min,-x)
optimize!(model)
How to multiply a 0-1 variable with a matrix, you must also set the 0-1 variable into a matrix of the same dimension?
using JuMP
model=Model(Gurobi.Optimizer)
@variable(model,0<=w[1:2,1:2]<=1,Int)
@variable(model,0<=x[1:2,1:2]<=10)
@constraint(model,w.*x>=0)
@objective(model,Min,-x)
optimize!(model)
ERROR: LoadError: MethodError: promote_operation(::typeof(MutableArithmetics.sub_mul), ::Type{Array{GenericQuadExpr{Float64,VariableRef},2}}, ::Type{Int64}) is ambiguous. Candidates:
promote_operation(op::Union{typeof(+), typeof(-), typeof(MutableArithmetics.add_mul), typeof(MutableArithmetics.sub_mul)}, A::Type{#s13} where #s13<:Array, α::Type{#s12} where #s12<:Number) in MutableArithmetics at C:\Users\27990\.juliapro\JuliaPro_v1.4.2-1\packages\MutableArithmetics\NuiNA\src\interface.jl:33
promote_operation(op::Union{typeof(MutableArithmetics.add_mul), typeof(MutableArithmetics.sub_mul)}, T::Type, args::Vararg{Type,N}) where N in MutableArithmetics at C:\Users\27990\.juliapro\JuliaPro_v1.4.2-1\packages\MutableArithmetics\NuiNA\src\shortcuts.jl:59
Possible fix, define
promote_operation(::Union{typeof(MutableArithmetics.add_mul), typeof(MutableArithmetics.sub_mul)}, ::Type{#s13} where #s13<:Array, ::Type{#s12} where #s12<:Number)
Stacktrace:
[1] mutability(::Type{T} where T, ::Function, ::Type{T} where T, ::Type{T} where T) at C:\Users\27990\.juliapro\JuliaPro_v1.4.2-1\packages\MutableArithmetics\NuiNA\src\interface.jl:132
[2] mutability(::Array{GenericQuadExpr{Float64,VariableRef},2}, ::Function, ::Array{GenericQuadExpr{Float64,VariableRef},2}, ::Int64) at C:\Users\27990\.juliapro\JuliaPro_v1.4.2-1\packages\MutableArithmetics\NuiNA\src\interface.jl:138
[3] operate!(::typeof(MutableArithmetics.sub_mul), ::Array{GenericQuadExpr{Float64,VariableRef},2}, ::Int64) at C:\Users\27990\.juliapro\JuliaPro_v1.4.2-1\packages\MutableArithmetics\NuiNA\src\rewrite.jl:70
[4] top-level scope at C:\Users\27990\.juliapro\JuliaPro_v1.4.2-1\packages\MutableArithmetics\NuiNA\src\rewrite.jl:227
[5] top-level scope at C:\Users\27990\.juliapro\JuliaPro_v1.4.2-1\packages\JuMP\YXK4e\src\macros.jl:416
in expression starting at untitled-3ec2ea91018ab30b053bc78b8257bb1c:8
The result is that they can’t. they report the same error