Hi, I have this simple model that tries to maximize theoretical demand for a product given some SKU level inventory constraints and a probability distribution for SKU demand. In the first constraint I’d like to compare the output of a multiplication of my variable d
multiplied by the given probability distribution p
for a SKU to the inventory constraint for that SKU. However, I’d like to apply either a ceil
or round
function to the multiplication since we can’t have partial units. I’ve set this up as an integer problem, but I don’t know how I can either specify integer constraints, or apply a type coercion/ceil/round function inside of the constraint. Sample code:
using JuMP, GLPK
p = [ .1, .15, .2, .25, .2, .1 ]
inventory = [ 10.0, 13.0, 22.0, 25.0, 20.0, 10.0 ];
m = Model(with_optimizer(GLPK.Optimizer))
@variable(m, d >= 0, Int)
@objective(m, Max, d/sum(inventory))
for i = 1:length(p)
@constraint(m, ceil(d * p[i]) <= inventory[i])
end
Error:
MethodError: no method matching ceil(::GenericAffExpr{Float64,VariableRef})
Closest candidates are:
ceil(!Matched::Type{BigInt}, !Matched::BigFloat) at mpfr.jl:314
ceil(!Matched::Missing) at missing.jl:112
ceil(!Matched::Missing, !Matched::Integer) at missing.jl:112
...
Is there a better way to ensure that the output of d * p[i]
gets coerced into an integer value?
Thanks!