Hi, all,
There is a simple programming with generalized constraints (min(…)), but the julia tells me errors as follows:
ERROR: LoadError: MethodError: no method matching isless(::AffExpr, ::AffExpr)
Closest candidates are:
isless(::Any, ::Missing) at missing.jl:88
isless(::Missing, ::Any) at missing.jl:87
The problem is can I use generalized constraints in JuMP naturally, and the codes are:
model = Model(Gurobi.Optimizer)
@variables(model, begin
s[1:8], Bin
z[1:8], Bin
d[1:8], Bin
o[1:8], Bin
end)
for t in 1:8
@constraint(model, o[t] == min((1 - s[t]) + z[t], 1 - d[t]))
end
@constraints(model, begin
s[1:3] .== 0
s[4:end] .== 1
z[1:5] .== 0
z[6:end] .== 1
d[1:2] .== 1
end)
optimize!(model)
value.(o)
And the expected output may be:
[0, 0, 1, 0, 0, 1, 1, 1]
I already know if I use the Gurobi solver, the codes above can use the following form (may with nonconvex optimizer in gurobi?)
model = Model(Gurobi.Optimizer)
@variables(model, begin
s[1:8], Bin
z[1:8], Bin
d[1:8], Bin
o[1:8], Bin
end)
for t in rg(8)
@constraint(model, o[t] == ((1 - s[t]) + z[t]) * (1 - d[t]))
end
@constraints(model, begin
s[1:3] .== 0
s[4:end] .== 1
z[1:5] .== 0
z[6:end] .== 1
d[1:2] .== 1
end)
optimize!(model)
value.(o)