Wikunia / ConstraintSolver.jl

ConstraintSolver in Julia: Blog posts ->
https://opensourc.es/blog/constraint-solver-1
MIT License
136 stars 14 forks source link

Better bound using the constraints #69

Closed Wikunia closed 4 years ago

Wikunia commented 4 years ago

The best bound can be way too optimistic if we have <= constraints. I.e

    m = Model(with_optimizer(CS.Optimizer))
    @variable(m, 1 <= x[1:10] <= 9, Int)
    @constraint(m, sum(x) <= 25)
    @constraint(m, sum(x) >= 20)
    weights = [1,2,3,4,5,6,7,8,9,10]
    @objective(m, Max, sum(weights .* x))
    optimize!(m)

The objective is currently only considering one change but by limiting the sum to 25 this can be reduced by looking at the constraints when calculating the best bound. Otherwise this will take forever...

Wikunia commented 4 years ago

Works when a greedy knapsack approach can be used.