GithubHelp home page GithubHelp logo

irfy / merging-triplets Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 136 KB

A set of files for solving the problem listed here: http://stackoverflow.com/questions/22222994/optimal-merging-of-triplets

Shell 11.39% Python 88.61%

merging-triplets's Introduction

merging-triplets

A set of files for solving the problem listed here: http://stackoverflow.com/questions/22222994/optimal-merging-of-triplets

Usage

merge_triplets.py

  • ./merge_triplets.py < triplets will merge triplets listed in the file triplets with lookahead 3 and output the size of the resulting set.
  • ./merge_triplets.py -v < triplets will output information on every step of the algorithm, visualizing recursion.
  • ./merge_triplets.py 0 < triplets will use zero lookahead, a.k.a. the blind algorithm as discussed on StackOverflow.
  • ./merge_triplets.py 1 < triplets will use the simple heuristic, a.k.a Level 1: Greedy.
  • ./merge_triplets.py 2 < triplets also for any argument larger than 1, this will use the recursive lookahead algorithm a.k.a. Level 2: Very greedy

random_triplets.py

  • ./random_triplets.py n will generate n triplets on stdout, with maximum element value about base-3 logarithm of n
  • ./random_triplets.py | ./merge_triplets.py is a convinient way of combining the two scripts

find_diff.sh

  • ./find_diff.sh n l1 l2 will repeatedly generate sets of n triplets, and compare the results of merges with lookaheads l1 and l2 to find differences. When a difference is found, the script prints details of the event as well as the triplets that caused it and exits. Default values for n, l1 and l2 are 10, 2 and 3 respectively.

stat_diff.sh

  • ./stat_diff.sh n l1 l2 will do the same thing as ./find_diff.sh n l1 l2 except that instead of exiting, it will keep track of differences and continue running with new datasets. Sending an interrupt (Ctrl-C) will cause the script to print the statistics so far and exit. The script will leave behind last_better[12]_triplets files (so long the corresponding datasets have been found) so that they can be analyzed after the script has finished.

proof* files

  • These files are examples of triplets which cause different results for different lookaheads, as found by the find_diff.sh script.

merging-triplets's People

Contributors

irfy avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.