Skip to content

This repository contains the code to simulate a genetic algorithm that finds an optimal keyboard based on a purely distance metric.

License

Notifications You must be signed in to change notification settings

aniruddh-mishra/ultimate-keyboard

Repository files navigation

The Ultimate Keyboard Genetic Algorithm

This repository contains the code to simulate a genetic algorithm that finds an optimal keyboard based on a purely distance metric. It allows the user to configure the size of populations as well as the number of generations. The default text that it tests the keyboards with can also be manipulated. In addition, these keyboards can also use different typing styles to get various versions of a keyboard for similar sample data.

Table of Contents

  1. Install
  2. Introduction
  3. Usage
  4. Conclusion
  5. License

Install

First, clone the repository onto your computer with the following command:

git clone https://codeberg.org/Inventor853/ultimate-keyboard.git --depth 1

After cloning the repository, you will want to change directories to complete the install.

cd ultimate-keyboard

Now create a virtual environment for your working directory.

If not done so already, install venv with the package manager pip .

pip install virtualenv

Use venv to create a virtual environment in the folder venv.

python -m venv venv

Source into your virtual environment with the following command; it may be different for different shells.

source venv/bin/activate

Use the package manager pip to install the required libraries.

pip install -r requirements.txt

Introduction

Before experimenting with the genetic algorithm, you can build the presentation for a brief overview on the program's functionality. To complete the following steps, you must first insure that LaTeX is installed on your computer. Also confirm that you have latexmk installed to make the presentation.

cd presentation/
latexmk -xelatex presentation.tex 
latexmk -c

Usage

To run the genetic algorithm simply use the following command:

python main.py

For more information on how to configure the genetic algorithm use this command:

python main.py --help

Once the code has run it will print the name of the json file that contains all of the data from the run. This file will be stored under the outputs/ folder. These files can be visualized later with the following command:

python display.py <file-name> <display-mode>

In this command, <file-name> should be replaced with the relative path to the json file from the main repository directory. Additionally, <display-mode> should be replaced with a 0 for showing only the final results of the program or a 1 to show each generation of the program iteratively.

Conclusion

This program illustrates the ability of a genetic algorithm to tackle a seamingly complex topic into a generic stochastic approximation method. By defining a fitness test and a representation of a population, as well as the generation of a new generation with mutations, a genetic algorithm can search almost any defined set. In this case, the algorithm was simply a quicker way to search the set of all possible keyboards. This makes genetic algorithms a highly versatile tool for many topics. However, the main problem with them is that such approximation models are very highly based on chance. Since everything is random, one never knows when to stop the model, as a new mutation could trigger an advancement randomly.

License

This project uses a GNU General Public License v3. For more information, please look at the LICENSE file in this repository.

License: GPL v3


Neovim Python JSON Notion Arch

About

This repository contains the code to simulate a genetic algorithm that finds an optimal keyboard based on a purely distance metric.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages