ruby-cbc 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ruby-cbc/conflict_solver.rb +17 -11
- data/lib/ruby-cbc/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 123d2f19ca6c970f616b7fc8809132bb40a25e90
|
4
|
+
data.tar.gz: a757a87c2e76369d441fe123ec73d399b62e8177
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a77e3149e6f303cecf36e20a8cd75aa5c09a34aacaa56a2dc47af448c8b11df48069ce2c30e65d0e6970819c254a757a94dae906254d89fee283ff0030ed62a8
|
7
|
+
data.tar.gz: 5ee5d181c9554e2c6e66719cda6e9c6bec32ea4c3f8884d222d798e93ecb2920c8ac246c7226b1ddb1ad00d880424d0e52a0e10056bf5fa10cae26cb0ccb0cec
|
@@ -11,44 +11,50 @@ module Cbc
|
|
11
11
|
continuous = is_continuous_conflict?
|
12
12
|
conflict_set = []
|
13
13
|
all_constraints = @model.constraints.to_a
|
14
|
+
nb_constraints = all_constraints.count
|
14
15
|
loop do
|
15
16
|
m = Model.new
|
16
17
|
m.vars = @model.vars
|
17
18
|
m.enforce(conflict_set)
|
18
19
|
return conflict_set if infeasible?(m, continuous: continuous)
|
19
20
|
|
20
|
-
|
21
|
-
return conflict_set if !
|
21
|
+
constraint_idx = first_failing(conflict_set, all_constraints, nb_constraints, continuous: continuous)
|
22
|
+
return conflict_set if !constraint_idx
|
22
23
|
|
23
|
-
|
24
|
+
nb_constraints = constraint_idx
|
25
|
+
conflict_set << all_constraints[constraint_idx]
|
24
26
|
end
|
25
27
|
end
|
26
28
|
|
27
29
|
def is_continuous_conflict?
|
28
|
-
|
30
|
+
# Same model without objective
|
31
|
+
model = Model.new
|
32
|
+
model.vars = @model.vars
|
33
|
+
model.constraints = @model.constraints
|
34
|
+
infeasible?(model, continuous: true)
|
29
35
|
end
|
30
36
|
|
31
37
|
private
|
32
38
|
# finds the first constraint from constraints that makes the problem infeasible
|
33
|
-
def first_failing(conflict_set, constraints, continuous: false)
|
39
|
+
def first_failing(conflict_set, constraints, nb_constraints, continuous: false)
|
34
40
|
min_nb_constraints = 1
|
35
|
-
max_nb_constraints =
|
41
|
+
max_nb_constraints = nb_constraints + 1
|
36
42
|
|
37
43
|
loop do
|
38
44
|
m = Model.new
|
39
45
|
m.vars = @model.vars
|
40
46
|
m.enforce(conflict_set)
|
41
47
|
|
42
|
-
|
43
|
-
m.enforce(constraints.take(
|
48
|
+
half_constraints = (max_nb_constraints + min_nb_constraints) / 2
|
49
|
+
m.enforce(constraints.take(half_constraints))
|
44
50
|
if infeasible?(m, continuous: continuous)
|
45
|
-
max_nb_constraints =
|
51
|
+
max_nb_constraints = half_constraints
|
46
52
|
else
|
47
|
-
min_nb_constraints =
|
53
|
+
min_nb_constraints = half_constraints
|
48
54
|
end
|
49
55
|
if max_nb_constraints - min_nb_constraints <= 1
|
50
56
|
return nil if max_nb_constraints > constraints.count
|
51
|
-
return
|
57
|
+
return max_nb_constraints - 1
|
52
58
|
end
|
53
59
|
end
|
54
60
|
# Shouldn't come here if the whole problem is infeasible
|
data/lib/ruby-cbc/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-cbc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Guillaume Verger
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-01-
|
11
|
+
date: 2016-01-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|