Perhaps it is the right solution?
Does your formulation provide sensible results? Or is there something wrong with it?
I haven’t looked at your question in detail, but to the “simple context free” part of your question:
model = Model()
@variable(model, select[1:10], Bin)
@variable(model, 0 <= insert[1:10] <= 10, Int)
@variable(model, insert_zero[1:10], Bin)
# insert[i] == 0 if insert_zero[i] == 1
@constraint(model, [i=1:10], insert[i] <= 10 * insert_zero[i])
# Monotonicity of insert_zero
@constraint(model, [i=2:10], insert_zero[i] <= insert_zero[i-1])
# i > sum(select) + sum(insert) ⟹ insert_zero[i] == 0
# ⟺
# sum(select) + sum(insert) == sum(insert_zero)
@constraint(model, sum(select) + sum(insert) == sum(insert_zero))
A few JuMP/style points:
model = JuMP.Model(JuMP.with_optimizer(Cbc.Optimizer, loglevel=0))
You should update to the latest version of JuMP.
model = JuMP.Model(Cbc.Optimizer)
JuMP.set_silent(model)
select = JuMP.@variable(model, select[1:10], Bin)
No need for select = . JuMP.@variable(model, select[1:10], Bin) is the same by itself.
JuMP.@variable(model, insert[1:10], Int, upper_bound=maxins, lower_bound = 0)
JuMP.@variable(model, 0 <= insert[1:10] <= maxins, Int)
JuMP.@constraint(model, [i=2:10], 0 <= colast[i] - colast[i-1] <= 1)
This simplifies to
JuMP.@constraint(model, [i=2:10], colast[i] >= colast[i-1])