dither 0.2.0.rc4-java → 0.2.0.rc5-java
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/dither.gemspec +1 -1
- data/ext/dither/simple_constraint_handler.cc +15 -28
- data/ext/dither/simple_constraint_handler.h +2 -1
- data/lib/dither/version.rb +1 -1
- data/lib/{dither-0.1.3.jar → dither-0.1.4.jar} +0 -0
- data/lib/dither.rb +2 -2
- data/spec/dither/dither_spec.rb +5 -5
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e375f73de29cf2973902fa32746da23ec5b3d04c
|
4
|
+
data.tar.gz: d0934babd6665c4c710be50b62991af2f0cb6385
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: da0bef56fb262a62bd17070f611523a5a389cfb24c23252a26790f3da8ee046379520062d4f6862c2201d51592d959d3756f48d34177ac90a58c38b4d7278aa5
|
7
|
+
data.tar.gz: cf8c34f22d78dac20e0e68961cf8b2f43c7b6409c54131ef62625ab269a90790e01d755ac558cba3abaabac72ec8cb39c4153f2e15b811330f2276b7591fc554
|
data/dither.gemspec
CHANGED
@@ -24,7 +24,7 @@ Gem::Specification.new do |s|
|
|
24
24
|
if RUBY_PLATFORM =~ /java/
|
25
25
|
s.platform = "java"
|
26
26
|
# compile dither-java on jdk 8
|
27
|
-
files << "lib/dither-0.1.
|
27
|
+
files << "lib/dither-0.1.4.jar"
|
28
28
|
files << "lib/choco-solver-3.3.1-with-dependencies.jar"
|
29
29
|
else
|
30
30
|
s.add_dependency "ffi", "~> 1.0"
|
@@ -12,7 +12,7 @@
|
|
12
12
|
|
13
13
|
namespace dither {
|
14
14
|
|
15
|
-
SimpleConstraintHandler::SimpleConstraintHandler(std::vector<dval>& ranges, std::vector<std::vector<dval>>& pconstraints) : params(ranges) {
|
15
|
+
SimpleConstraintHandler::SimpleConstraintHandler(std::vector<dval>& ranges, std::vector<std::vector<dval>>& pconstraints) : params(ranges), scratch(ranges.size(), -1) {
|
16
16
|
for(auto it = pconstraints.cbegin(); it != pconstraints.cend(); ++it) {
|
17
17
|
std::vector<std::pair<std::size_t, dval>> constraint;
|
18
18
|
std::size_t i = 0;
|
@@ -27,6 +27,14 @@ namespace dither {
|
|
27
27
|
}
|
28
28
|
|
29
29
|
bool SimpleConstraintHandler::violate_constraints(const dtest_case &test_case) {
|
30
|
+
if(violate_constraints_(test_case)) {
|
31
|
+
return true;
|
32
|
+
}
|
33
|
+
std::copy(test_case.cbegin(), test_case.cend(), scratch.begin());
|
34
|
+
return !ground(scratch);
|
35
|
+
}
|
36
|
+
|
37
|
+
inline bool SimpleConstraintHandler::violate_constraints_(const dtest_case &test_case) {
|
30
38
|
for(auto constraint = constraints.cbegin(); constraint != constraints.cend(); ++constraint) {
|
31
39
|
if(violate_constraint(test_case, *constraint)) {
|
32
40
|
return true;
|
@@ -46,32 +54,14 @@ namespace dither {
|
|
46
54
|
}
|
47
55
|
|
48
56
|
bool SimpleConstraintHandler::violate_constraints(const std::vector<param> &test_case) {
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
}
|
53
|
-
}
|
54
|
-
return false;
|
55
|
-
}
|
56
|
-
|
57
|
-
inline bool SimpleConstraintHandler::violate_constraint(const std::vector<param>& test_case, const std::vector<std::pair<std::size_t, dval>>& constraint) {
|
58
|
-
if(test_case.size() < constraint.size()) {
|
59
|
-
return false;
|
60
|
-
}
|
61
|
-
|
62
|
-
std::size_t count = 0;
|
63
|
-
for(auto it = constraint.cbegin(); it != constraint.cend(); ++it) {
|
64
|
-
for(auto iit = test_case.cbegin(); iit != test_case.cend(); ++iit) {
|
65
|
-
if((*iit).first == (*it).first && (*iit).second == (*it).second) {
|
66
|
-
count++;
|
67
|
-
break;
|
68
|
-
}
|
69
|
-
}
|
57
|
+
std::fill(scratch.begin(), scratch.end(), -1);
|
58
|
+
for(auto p : test_case) {
|
59
|
+
scratch[p.first] = p.second;
|
70
60
|
}
|
71
|
-
if(
|
61
|
+
if(violate_constraints_(scratch)) {
|
72
62
|
return true;
|
73
63
|
}
|
74
|
-
return
|
64
|
+
return !ground(scratch);
|
75
65
|
}
|
76
66
|
|
77
67
|
bool SimpleConstraintHandler::ground(dtest_case &test_case) {
|
@@ -84,9 +74,6 @@ namespace dither {
|
|
84
74
|
indexes.push_back(i);
|
85
75
|
}
|
86
76
|
}
|
87
|
-
if(indexes.size() == 0) {
|
88
|
-
return true;
|
89
|
-
}
|
90
77
|
std::vector<dval> bound_values(indexes.size(), -1);
|
91
78
|
i = 0;
|
92
79
|
|
@@ -95,7 +82,7 @@ LOOP:while(i < indexes.size()) {
|
|
95
82
|
const dval max = params[indexes[i]];
|
96
83
|
for(dval value = bound_values[i] + 1; value <= max; value++) {
|
97
84
|
test_case[indexes[i]] = value;
|
98
|
-
if(
|
85
|
+
if(violate_constraints_(test_case)) {
|
99
86
|
continue;
|
100
87
|
}
|
101
88
|
bound_values[i] = value;
|
@@ -22,9 +22,10 @@ namespace dither {
|
|
22
22
|
protected:
|
23
23
|
std::vector<std::vector<std::pair<std::size_t, dval>>> constraints;
|
24
24
|
std::vector<dval> params;
|
25
|
+
std::vector<dval> scratch;
|
25
26
|
|
26
27
|
inline bool violate_constraint(const dtest_case& test_case, const std::vector<std::pair<std::size_t, dval>>& constraint);
|
27
|
-
inline bool
|
28
|
+
inline bool violate_constraints_(const dtest_case &test_case);
|
28
29
|
|
29
30
|
public:
|
30
31
|
SimpleConstraintHandler(std::vector<dval>& ranges, std::vector<std::vector<dval>>& pconstraints);
|
data/lib/dither/version.rb
CHANGED
Binary file
|
data/lib/dither.rb
CHANGED
@@ -62,7 +62,7 @@ module Dither
|
|
62
62
|
end
|
63
63
|
arr = Array.new(params.size)
|
64
64
|
(0...params.size).each do |i|
|
65
|
-
arr[i] = params[i].
|
65
|
+
arr[i] = params[i].find_index(test_case[i])
|
66
66
|
end
|
67
67
|
tested_scratch.write_array_of_int(arr)
|
68
68
|
Dither::API.dither_ipog_add_previously_tested(pointer, tested_scratch, params.size)
|
@@ -97,7 +97,7 @@ require 'dither/graph'
|
|
97
97
|
if RUBY_PLATFORM =~ /java/
|
98
98
|
require 'java'
|
99
99
|
require 'choco-solver-3.3.1-with-dependencies.jar'
|
100
|
-
require 'dither-0.1.
|
100
|
+
require 'dither-0.1.4.jar'
|
101
101
|
|
102
102
|
require 'dither/java_ext/dither'
|
103
103
|
else
|
data/spec/dither/dither_spec.rb
CHANGED
@@ -63,7 +63,7 @@ describe Dither do
|
|
63
63
|
end
|
64
64
|
|
65
65
|
it 'can compute 3-way ipog with constraints' do
|
66
|
-
params = [
|
66
|
+
params = [[:a, :b], (0...2).to_a, (0..3).to_a]
|
67
67
|
results = Dither.ipog(params, :t => 3,
|
68
68
|
:constraints => [
|
69
69
|
{0 => 0,
|
@@ -71,16 +71,16 @@ describe Dither do
|
|
71
71
|
{0 => 0,
|
72
72
|
1 => 1,
|
73
73
|
2 => 0}],
|
74
|
-
:previously_tested => [[
|
74
|
+
:previously_tested => [[:a, 0, 0]]
|
75
75
|
)
|
76
76
|
results.each do |result|
|
77
|
-
expect(result[0] ==
|
77
|
+
expect(result[0] == :a && result[1] == 1 && result[2] == 0).to be false
|
78
78
|
end
|
79
79
|
results.each do |result|
|
80
|
-
expect(result[0] ==
|
80
|
+
expect(result[0] == :a && result[1] == 2).to be false
|
81
81
|
end
|
82
82
|
results.each do |result|
|
83
|
-
expect(result[0] ==
|
83
|
+
expect(result[0] == :a && result[1] == 0 && result[2] == 0).to be false
|
84
84
|
end
|
85
85
|
end
|
86
86
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dither
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.0.
|
4
|
+
version: 0.2.0.rc5
|
5
5
|
platform: java
|
6
6
|
authors:
|
7
7
|
- Jason Gowan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-12-
|
11
|
+
date: 2015-12-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
@@ -94,7 +94,7 @@ files:
|
|
94
94
|
- ext/dither/simple_constraint_handler.cc
|
95
95
|
- ext/dither/simple_constraint_handler.h
|
96
96
|
- lib/choco-solver-3.3.1-with-dependencies.jar
|
97
|
-
- lib/dither-0.1.
|
97
|
+
- lib/dither-0.1.4.jar
|
98
98
|
- lib/dither.rb
|
99
99
|
- lib/dither/aetg.rb
|
100
100
|
- lib/dither/aetg_pairwise.rb
|