Skip to content

Commit 5192890

Browse files
authored
Use cliques for != (#188)
* use cliques for != * fixed bug: all different should return false if infeasible due to not enough values * using lp solver if specified * geqset constraint * use captured alldifferent constraint for pruning bounds * simplify several a >= b with same a to GeqSetConstraint * results2csvs for visualizing benchmarking * simplify as option
1 parent 23f8ce3 commit 5192890

25 files changed

+1328
-165
lines changed

CHANGELOG.md

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
# ConstrainSolver.jl - Changelog
22

3-
## v0.3.1
3+
## Unreleased
4+
- Use LP solver also for single variable objectives
5+
- Combine several `x != y` constraints into all different constraints
6+
- Combine several `a >= x` constraints with the same `a` into a vector constraints
7+
- used for better bounds using all different constraints
8+
9+
## v0.3.1 (16th of November 2020)
410
- Added `copy` function for constraint structs for latest JuMP/MOI versions
511

6-
## v0.3.0
12+
## v0.3.0 (11th of July 2020)
713
- Reified constraint [#171](https://github.com/Wikunia/ConstraintSolver.jl/pull/171)
814

915
## v0.2.2 (26th of June 2020)

Project.toml

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ version = "0.3.1"
77
Formatting = "59287772-0a20-5a39-b81b-1366585eb4c0"
88
JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
99
JuMP = "4076af6c-e467-56ae-b986-b466b2749572"
10+
LightGraphs = "093fc24a-ae57-5d10-9952-331d41423f4d"
1011
MathOptInterface = "b8f27783-ece8-5eb3-8dc8-9495eed66fee"
1112
MatrixNetworks = "4f449596-a032-5618-b826-5a251cb6dc11"
1213
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
@@ -15,6 +16,7 @@ Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
1516
Formatting = "^0.4.1"
1617
JSON = "~0.18, ~0.19, ~0.20, ~0.21"
1718
JuMP = "^0.21.3"
19+
LightGraphs = "1"
1820
MathOptInterface = "^0.9.11"
1921
MatrixNetworks = "^1"
2022
julia = "1"

benchmark/benchmarks.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,4 @@ SUITE["graph_coloring"]["US_8+equal"] = @benchmarkable solve_us_graph_coloring(;
5454
SUITE["graph_coloring"]["US_50colors+equal"] = @benchmarkable solve_us_graph_coloring(;num_colors=50, equality=true) seconds=5
5555
SUITE["graph_coloring"]["US_50colors"] = @benchmarkable solve_us_graph_coloring(;num_colors=50, equality=false) seconds=5
5656
SUITE["graph_coloring"]["queen7_7"] = @benchmarkable color_graph(joinpath(dir, "benchmark/graph_color/data/queen7_7.col"), 7) seconds=10
57-
SUITE["graph_coloring"]["le450_5d"] = @benchmarkable color_graph(joinpath(dir, "benchmark/graph_color/data/le450_5d.col"), 5) seconds=10
57+
SUITE["graph_coloring"]["le450_5d"] = @benchmarkable color_graph(joinpath(dir, "benchmark/graph_color/data/le450_5d.col"), 5) seconds=30

benchmark/graph_color/cs.jl

+10-5
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
1-
using ConstraintSolver, JuMP
1+
using ConstraintSolver, JuMP, GLPK
22
CS = ConstraintSolver
33

44
function main(filename; benchmark = false, time_limit=100)
5-
m = Model(optimizer_with_attributes(CS.Optimizer, "time_limit"=>time_limit))
5+
lp_optimizer = optimizer_with_attributes(GLPK.Optimizer, "msg_lev" => GLPK.GLP_MSG_OFF)
6+
m = Model(optimizer_with_attributes(CS.Optimizer, "time_limit"=>time_limit, "lp_optimizer" => lp_optimizer))
67

78
lines = readlines(filename)
89
num_colors = 0
910
x = nothing
1011
max_color = nothing
1112
degrees = nothing
1213
for line in lines
13-
parts = split(line, " ")
14+
isempty(line) && continue
15+
parts = split(line)
1416
if parts[1] == "p"
1517
num_colors = parse(Int, parts[3])
1618
@variable(m, 1 <= max_color <= num_colors, Int)
@@ -36,6 +38,9 @@ function main(filename; benchmark = false, time_limit=100)
3638
optimize!(m)
3739

3840
status = JuMP.termination_status(m)
39-
40-
print("$status, $(JuMP.objective_value(m)), $(JuMP.solve_time(m))")
41+
if status == MOI.OPTIMAL
42+
print("$status, $(JuMP.objective_value(m)), $(JuMP.solve_time(m))")
43+
else
44+
print("$status, NaN, $(time_limit)")
45+
end
4146
end

0 commit comments

Comments
 (0)