Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
  • 2 commits
  • 4 files changed
  • 0 comments
  • 1 contributor

Showing 4 changed files with 7 additions and 27 deletions. Show diff stats Hide diff stats

  1. +6 6 README.markdown
  2. +0 1  fas.c
  3. +0 19 fas_tournament.c
  4. +1 1  tests.rb
12 README.markdown
Source Rendered
@@ -12,18 +12,18 @@ I would only give a fairly qualified recommendation in favour of it.
12 12
13 13 Features:
14 14
15   -* It does a pretty good job. Not great, but doing great is mathematically impossible. The test suite scores it on a variety of data, and it's usually within a few % of the best known value.
16   -* It's quite fast. For small numbers of items (<= 100) it completes in a few 100ms.
17   -* It's deterministic. There are theoretically better randomized algorithms for this but I wanted it to produce reproducable results.
  15 +* It does a pretty good job. The test suite requires that it gets within 5% of the best known result on a variety of data, and it beats that with a comfortable margin.
  16 +* It's quite fast. For small numbers of items (<= 100) it completes in a few 100ms, going up to a few seconds for thousands of items.
  17 +* It's deterministic. Most of the best-of-breed algorithms for this problem are randomized. Empirically, this seems to produce consistently better scores than they do (but that may be errors in my implementation of them)
18 18 * It respects condorcet partitions. That is, if you partition the candidates into two sets A and B such that W_ab > W_ba for any a in A and b in B, it will always put everything in A first
19   -* The result is locally optimal int he sense that no change which involves only moving a single element will improve the score
  19 +* The result is locally optimal in the sense that no change which involves only moving a single element will improve the score
20 20 * Everything runs clean under valgrind with all test data
21 21
22 22 Downsides:
23 23
24 24 * The theoretical bounds on how bad the error can be are extremely weak to non-existent
25   -* The performance is O(n^2) in the number of items.
26   -* The API for the library is extremely poorly thought out at present.
  25 +* The performance is O(n^2) in the number of items, even when far fewer than O(n^2) comparisons are present.
  26 +* The API for the library is fairly poorly thought out at present.
27 27 * The command line interface is terribly rudimentary
28 28
29 29 All that being said, it appears to work and work reasonably well.
1  fas.c
@@ -32,7 +32,6 @@ int main(int argc, char **argv){
32 32 size_t *items = optimal_ordering(t);
33 33
34 34 printf("Score: %f\n", score_fas_tournament(t, n, items));
35   - printf("Lower bound on best score: %f\n", best_score_lower_bound(t, n, items));
36 35 printf("Optimal ordering:");
37 36
38 37 size_t i = 0;
19 fas_tournament.c
@@ -375,25 +375,6 @@ size_t *integer_range(size_t n){
375 375 return results;
376 376 }
377 377
378   -double best_score_lower_bound(tournament *t, size_t n, size_t *items){
379   - double tot = 0.0;
380   - double vtot = 0.0;
381   -
382   - for(size_t i = 0; i < n; i++){
383   - for(size_t j = i+1; j < n; j++){
384   - double aij = tournament_get(t, items[i], items[j]);
385   - double aji = tournament_get(t, items[j], items[i]);
386   -
387   - tot += aij;
388   - tot += aji;
389   -
390   - vtot += (aij - aji) * (aij - aji);
391   - }
392   - }
393   -
394   - return 0.5 * tot + 0.5 * sqrt(vtot);
395   -}
396   -
397 378 void force_connectivity(tournament *t, size_t n, size_t *items){
398 379 if(!n) return;
399 380 for(size_t i = 0; i < n - 1; i++){
2  tests.rb
@@ -31,7 +31,7 @@ def fas(file)
31 31 end
32 32 valgrind_failed = $?.exitstatus != 0
33 33 runtime = Time.now - t
34   - score, lb, ordering = results.split("\n");
  34 + score, ordering = results.split("\n");
35 35
36 36 { :score => score.gsub(/Score: */, "").to_f,
37 37 :ordering => ordering.gsub(/^.+: */, "").gsub(/[^0-9 ]/, "").split.map{|x| x.to_i},

No commit comments for this range

Something went wrong with that request. Please try again.