dither 0.2.6-java → 0.2.7-java

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5451ba9a4cb0e3bb48ed5accc4551a170d721d0f
4
- data.tar.gz: 717a068e48067f82e382599dbb046f835b8a8f4d
3
+ metadata.gz: c6fe27a250e8719c615e1f020154efb39cfdb2df
4
+ data.tar.gz: ef2f4bb9a9bed51991c12fd06626b8d21e198bf0
5
5
  SHA512:
6
- metadata.gz: a0df5437c9c56ff572c2dd1a845810033c4a923b9762f13a2918f0542e9e4009184765a92d8e4f7a1ec11036d17f5883b2a2426d11287a21d4655327d3cb2c29
7
- data.tar.gz: 41289c4554624115fc351266c16aff0892de9cc69b19bfaa206ffdfc290a9b456771d233810cd3507962261873661c59295fed66ebb15718eece2c59a48f0e41
6
+ metadata.gz: fa1317fb2274cbe47c2113a25d81917c4ac1b284b585c002733ecc4dc5daf2fa960f7524f636365d5a1728bafb465d8909d9f92126c8e9bbb96868135122fc3e
7
+ data.tar.gz: 6331a0442c3dd2433d8356e2f295ff4df0c2f5e930b7ab92fa5edc705d73e75278209ee41ea1f1a6f1b7d9e9c323f9396f66e483e737f93af073d81961d31ecd
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
  Collection of combinatorial test generation strategies.
3
3
 
4
4
  # Requirements
5
- a c++ compiler is required when installing on mri.
5
+ a c++ compiler is required when installing on mri. tested on gcc 4.6, gcc 5.3, and clang 3.7.
6
6
 
7
7
  # Usage
8
8
 
data/ext/dither/ipog.cc CHANGED
@@ -122,19 +122,28 @@ void Ipog::run() {
122
122
 
123
123
  if (!case_covered) {
124
124
  bool is_merged = false;
125
-
126
- for (auto next = unbound_.begin(); next != unbound_.end(); ++next) {
125
+ auto prev = unbound_.before_begin();
126
+ auto next = unbound_.begin();
127
+ auto end = unbound_.end();
128
+ while (next != end) {
127
129
  const int merge_result = merge(k, *next, test_case);
128
130
 
129
- if (merge_result > 0) {
130
- dtest_case tmp = *next;
131
+ if (merge_result >= 0) {
131
132
  for (std::size_t i = 0; i < t_; i++) {
132
133
  const param *it = test_case[i];
133
- tmp[it->first] = it->second;
134
+ (*next)[it->first] = it->second;
134
135
  }
135
136
  is_merged = true;
137
+ }
138
+ if (merge_result == 0) {
139
+ bound_.push_front(*next);
140
+ unbound_.erase_after(prev);
141
+ break;
142
+ } else if (merge_result == 1) {
136
143
  break;
137
144
  }
145
+ ++prev;
146
+ ++next;
138
147
  }
139
148
 
140
149
  if (!is_merged) {
@@ -150,6 +159,7 @@ void Ipog::run() {
150
159
  }
151
160
  }
152
161
  }
162
+
153
163
  ground_solutions();
154
164
  }
155
165
 
@@ -206,32 +216,39 @@ inline bool Ipog::is_covered(const dtest_case &test_case,
206
216
  inline const int Ipog::maximize_coverage(const int k, dtest_case &test_case,
207
217
  std::forward_list<param **> &pi) {
208
218
  const std::vector<param> &param_range = param_cache_[k];
209
- int current_max = -1;
210
- param max_param = param_range[0];
211
- std::forward_list<std::forward_list<param **>::iterator> covered;
212
-
213
- for (auto it = param_range.cbegin(); it != param_range.cend(); ++it) {
214
- std::forward_list<std::forward_list<param **>::iterator> tmp_covered;
215
- const param current_param = *it;
216
-
217
- test_case[current_param.first] = current_param.second;
218
- if (!constraint_handler->violate_constraints(test_case)) {
219
- int count = 0;
220
- auto prev = pi.before_begin();
221
- for (auto params = pi.begin(); params != pi.end(); ++params, ++prev) {
222
- if (is_covered(test_case, *params)) {
223
- tmp_covered.push_front(prev);
224
- count++;
225
- }
226
- }
219
+ std::vector<std::forward_list<std::forward_list<param **>::iterator>> covered(
220
+ param_range.size());
221
+ std::vector<int> counts(param_range.size());
222
+ const std::size_t index = param_range[0].first;
223
+ std::vector<std::size_t> valid_indexes;
224
+ valid_indexes.reserve(counts.size());
225
+ for (std::size_t i = 0; i < counts.size(); i++) {
226
+ test_case[index] = param_range[i].second;
227
+ if (constraint_handler->violate_constraints(test_case)) {
228
+ counts[i] = -1;
229
+ } else {
230
+ valid_indexes.push_back(i);
231
+ }
232
+ }
227
233
 
228
- if (count > current_max) {
229
- current_max = count;
230
- max_param = current_param;
231
- covered = tmp_covered;
234
+ auto prev = pi.before_begin();
235
+ for (auto params = pi.begin(); params != pi.end(); ++params, ++prev) {
236
+ for (auto i : valid_indexes) {
237
+ test_case[index] = param_range[i].second;
238
+ if (is_covered(test_case, *params)) {
239
+ covered[i].push_front(prev);
240
+ ++counts[i];
232
241
  }
233
242
  }
234
- test_case[current_param.first] = -1;
243
+ }
244
+
245
+ int current_max = -1;
246
+ std::size_t max_index = 0;
247
+ for (auto i : valid_indexes) {
248
+ if (current_max < counts[i]) {
249
+ current_max = counts[i];
250
+ max_index = i;
251
+ }
235
252
  }
236
253
 
237
254
  if (current_max == -1) {
@@ -239,11 +256,12 @@ inline const int Ipog::maximize_coverage(const int k, dtest_case &test_case,
239
256
  }
240
257
 
241
258
  /* remove covered */
242
- for (auto it = covered.begin(); it != covered.end(); ++it) {
259
+ for (auto it = covered[max_index].begin(); it != covered[max_index].end();
260
+ ++it) {
243
261
  pi.erase_after(*it);
244
262
  }
245
263
 
246
- test_case[max_param.first] = max_param.second;
264
+ test_case[index] = param_range[max_index].second;
247
265
  return current_max;
248
266
  }
249
267
 
@@ -1,4 +1,4 @@
1
1
 
2
2
  module Dither
3
- VERSION = '0.2.6'
3
+ VERSION = '0.2.7'
4
4
  end
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.6
4
+ version: 0.2.7
5
5
  platform: java
6
6
  authors:
7
7
  - Jason Gowan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-17 00:00:00.000000000 Z
11
+ date: 2016-01-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec