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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 50e576d6e9e07d6580bae33577e1f87f36156ec3
4
- data.tar.gz: 5900588a4ae476efc19fd04d1f008f326a32e68b
3
+ metadata.gz: e375f73de29cf2973902fa32746da23ec5b3d04c
4
+ data.tar.gz: d0934babd6665c4c710be50b62991af2f0cb6385
5
5
  SHA512:
6
- metadata.gz: 54679f10f893985789178b46b602c460360c4154c3c24bba10458f07570c87b19813e5d910c525396bbc6d40e9f08cc7df78a595fb415f8c88af63c175d62e12
7
- data.tar.gz: ea6c142c97711282cf11b1718d9e33630488cde0133c5ed7491df0075f64e3000de40695b27a866cf9b055b8e715ce05f0b4ca533633f4285ddbebfaa7230828
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.3.jar"
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
- for(auto constraint = constraints.cbegin(); constraint != constraints.cend(); ++constraint) {
50
- if(violate_constraint(test_case, *constraint)) {
51
- return true;
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(count == constraint.size()) {
61
+ if(violate_constraints_(scratch)) {
72
62
  return true;
73
63
  }
74
- return false;
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(violate_constraints(test_case)) {
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 violate_constraint(const std::vector<param>& test_case, const std::vector<std::pair<std::size_t, dval>>& constraint);
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);
@@ -1,4 +1,4 @@
1
1
 
2
2
  module Dither
3
- VERSION = '0.2.0.rc4'
3
+ VERSION = '0.2.0.rc5'
4
4
  end
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].find(test_case[i]).first
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.3.jar'
100
+ require 'dither-0.1.4.jar'
101
101
 
102
102
  require 'dither/java_ext/dither'
103
103
  else
@@ -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 = [(0...2).to_a, (0...2).to_a, (0..3).to_a]
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 => [[0, 0, 0]]
74
+ :previously_tested => [[:a, 0, 0]]
75
75
  )
76
76
  results.each do |result|
77
- expect(result[0] == 0 && result[1] == 1 && result[2] == 0).to be false
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] == 0 && result[1] == 2).to be false
80
+ expect(result[0] == :a && result[1] == 2).to be false
81
81
  end
82
82
  results.each do |result|
83
- expect(result[0] == 0 && result[1] == 0 && result[2] == 0).to be false
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.rc4
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-10 00:00:00.000000000 Z
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.3.jar
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