Code Monkey home page Code Monkey logo

albrecht's Introduction

Albrecht

Albrecht utilizes a fast evolutionary algorithm to generate random magic squares of any order.

Run

Albrecht is written in Java. To run it you'll need the Java Runtime Environment. This project uses Maven for its builds.

# execute inside Albrecht project directory
# generate default magic square of default order 30, saving results to the current directory
java -jar target/albrecht.jar 
# generate a magic square of order 35, saving results to directory tmp, with a status report every 15 secs
java -jar target/albrecht.jar --order 35 --dir /tmp --report 15

Arguments and Usage

java -jar target/albrecht.jar --help

usage: net.noisynarwhal.albrecht.Main
 -d,--dir <arg>      Output directory
 -h,--help           Display help
 -o,--order <arg>    Magic square order
 -r,--report <arg>   Report frequency in seconds

Algorithm

The evolution process starts with a square matrix with values arranged at random. Mutations are applied to the square retaining incremental improvements. Values are continually swapped at random until the matrix represents a semi-magic square. Subsequent changes are random row and column exchanges until a magic square is formed.

Benchmarks

The Albrecht algorithm is fundamentally stochastic, therefore individual runtimes will vary. Additionally, the application runs parallel processes dependent on the number of processors available to the environment. The following benchmarks were performed on a system with a 2.6 GHz Intel i7 and 6 cores.

Order Time to Complete
10 1/50 secs
15 1/8 secs
20 0.7 secs
25 3 secs
30 7 secs
35 14 secs
40 0.8 mins
45 1.25 mins
50 2 mins
60 5.2 mins

Results

Examples of discovered magic squares up to order 125 may be found in the folder examples.

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.