GithubHelp home page GithubHelp logo

prasannamaddila / weakschurparallel Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 2.81 MB

Project to write parallel algorithms to compute weak schur numbers and weakly sum-free partitions

Python 37.66% Jupyter Notebook 62.34%

weakschurparallel's Introduction

Parallel Algorithms for Weak-Schur Numbers

This repo aims to provide code using simulated annealing (and potentially other genetic algorithms) to compute weakly sum-free partitions, over multiple processes and in parallel. The upshot is that there are also reasonably fast functions which verify partitions and compute the fitness score of a given potential partition, which are completely implemented in numpy for speed.

The proposal for the algorithm, and its motivations, have been detailed in Algorithm Proposal.

WeakSchur contains the explanation for the main code in greater detail.

verify_partition and fitness

Both algorithms are based on the same method of generating all unique pairs of numbers in a given color partition; the idea is to generate a meshgrid of all possible pairs, and then get the (strictly) upper triangular part of the returned matrices of meshgrid: say xx and yy. The performance of this implementation of verify_partition is as follows.

Performance

In each case, the X-axis represents the total number of iterations used by timeit, and the time is in seconds. As expected, the total time taken is linear in the number of iterations, but time taken per iteration remains fairly constant.

fitness simply counts the number of pairs a,b,c such that they violate the sum-free property of the partition i.e. a+b=c for distinct a,b,c. Since the code isn't too different, the performance is not expected to be very different either. The specific times (in seconds) are in the following table.

10 100 500 1000 2500 5000
0.00002689999999994086 0.00018969999999995935 0.0010127999999998138 0.0019521000000000122 0.00863309999999995 0.007054699999999858

algorithm

The idea of this algorithm is to be simple, and parallellizable. The steps are as follows:

  • Step 1 Get the number to add for the current iteration
  • Step 2 Sequentially add it to each subset in the partition, and evaluate the fitness
  • Step 3 Choose the solution that has the minimum fitness, or according to a choice algorithm like SimulatedAnnealing.

weakschurparallel's People

Contributors

prasannamaddila 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.