https://github.com/pvlbzn/evolutionary
Print "Hello, World!". Wicked way.
https://github.com/pvlbzn/evolutionary
Last synced: 8 months ago
JSON representation
Print "Hello, World!". Wicked way.
- Host: GitHub
- URL: https://github.com/pvlbzn/evolutionary
- Owner: pvlbzn
- Created: 2017-05-16T19:24:00.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-11-08T14:19:43.000Z (almost 8 years ago)
- Last Synced: 2025-01-11T17:51:29.158Z (9 months ago)
- Language: C++
- Homepage:
- Size: 208 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Unorthodox Hello World
This repository contains two strategies for printing `Hello, world!`:
1. Co-called *genetic algorithm*
2. Machine learning like approachBascially two approaches have a single input: randomly generated string
out of which each algorithm must derive target string, `Hello, world!`.## [Genetic* Approach](https://github.com/pvlbzn/evolutionary/blob/master/random_and_linear_transformation_hello_world.ipynb)
This algorithm described numerous times in various blogs and has different
flavours. Logic behind this algorithm is simple: get a *population* and mutate
it until *cost function* will output zero.This algorithm can get complex with all the mimicry to evolution processes.
In essense it mutates input string/strings unless in a way that cost function
gets better and better results.## [Machine Learning Like Approach](https://github.com/pvlbzn/evolutionary/blob/master/random_and_linear_transformation_hello_world.ipynb)
This approach relies on a *linear transformation*. Having a target and a random
input string, of the same length as the target, algorithm find such a linear
transformation (function) which converts the input string into the target string.Linear transformation can be found numerically via change in data representation.
String makes more sense in a shape of array of integers.
On this plot `target` represents a target string, `Hello, world!`, `sample` represents
a randomly generated string, subject to transform somehow into the target string.
Dashed line, `weights`, represents a vector. Using simple transformation function
`f(x, w) = x + w`
the sample string, `x`, will be transformed to `target` string via weight, `w`,
transformation.This idea can be seen clearly on the plot where `x = 2`. Sample at `x` is slightly
above target at `x`, and weights at `x` is equally slightly below zero line.
Therefore, after transformation sample at `x` will be equal to target at `x`.