genetic_algorithms 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.travis.yml +4 -0
- data/README.md +41 -0
- data/lib/genetic_algorithms/version.rb +1 -1
- metadata +4 -3
- data/README.rdoc +0 -17
data/.travis.yml
ADDED
data/README.md
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
[](https://codeclimate.com/github/execdd17/genetic_algorithms) [](http://travis-ci.org)
|
2
|
+
|
3
|
+
## Description
|
4
|
+
|
5
|
+
This project contains my work in progress on Genetic Algorithms. The basic premise involves creating an initial random population of chromosomes and evolving them until they reach some ideal state.
|
6
|
+
|
7
|
+
A chromosome is a solution to a problem, and represented as a bit string. It is intentionally general in order to lend itself to multiple domains. The only thing linking it to a particular problem set is the fitness function. A fitness function evaluates a chromosome, that is, the effectiveness of a proposed solution.
|
8
|
+
|
9
|
+
## Usage
|
10
|
+
|
11
|
+
In the GeneticAlgorithms module, the Engine class encapsulates the entire evolution process. You can quickly use it with default values like this:
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
GeneticAlgorithms::Engine.new.start "AllOffSample"
|
15
|
+
```
|
16
|
+
And you'll see something like:
|
17
|
+
|
18
|
+
```ruby
|
19
|
+
{"1000000000"=>9}
|
20
|
+
```
|
21
|
+
|
22
|
+
This is a Hash containing the best chromosome found, and its score based on the fitness function. The argument to the start method is the name of a fitness function module. I have included a few with this project as a basic reference for creating your own. Here is an example fitness function where the best solution is where all bits are off:
|
23
|
+
|
24
|
+
```ruby
|
25
|
+
lambda do |chromosome|
|
26
|
+
chromosome.each_char.inject(0) do |accum, char|
|
27
|
+
accum += 1 if char == Chromosome::OFF
|
28
|
+
accum
|
29
|
+
end
|
30
|
+
end
|
31
|
+
```
|
32
|
+
|
33
|
+
The engine has three optional parameters that can be utilized during construction. The population size, chromosome length, and number of generations to evolve (in that order). You'll notice that modifying these values can have a tremendous effect on the algorithm itself, and that is one of the interesting characteristics of genetic algorithms. In the future I will be opening up more parameters as well; currently many of them are tightly coupled to their respective classes.
|
34
|
+
|
35
|
+
## Logging
|
36
|
+
|
37
|
+
The RouletteWheel, Population, and Chromosome classes have independent loggers. Currently, they are all showing debug level and above messages, and can be changed in lib/genetic_algorithms.rb. The output of the log is written in the root directory titled 'results.log'. It will display things like which chromosomes were chosen to mate, what happened in crossover and mutation, the highest score in a given population, etc. I plan to make the loggers more easily configurable in future releases.
|
38
|
+
|
39
|
+
## Feedback
|
40
|
+
|
41
|
+
If you have a questions, comments, or feature requests, please feel free to contact me.
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: genetic_algorithms
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-11-
|
12
|
+
date: 2012-11-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: logging
|
@@ -67,9 +67,10 @@ extra_rdoc_files: []
|
|
67
67
|
files:
|
68
68
|
- .gitignore
|
69
69
|
- .rvmrc
|
70
|
+
- .travis.yml
|
70
71
|
- Gemfile
|
71
72
|
- Gemfile.lock
|
72
|
-
- README.
|
73
|
+
- README.md
|
73
74
|
- genetic_algorithms.gemspec
|
74
75
|
- lib/genetic_algorithms.rb
|
75
76
|
- lib/genetic_algorithms/chromosome.rb
|
data/README.rdoc
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
{<img src="https://codeclimate.com/badge.png" />}[https://codeclimate.com/github/execdd17/genetic_algorithms]
|
2
|
-
|
3
|
-
== Description
|
4
|
-
|
5
|
-
This project contains my work in progress on Genetic Algorithms. The basic premise involves creating an initial random population of chromosomes and evolving them until they reach some ideal state.
|
6
|
-
|
7
|
-
== Usage
|
8
|
-
|
9
|
-
A chromosome is a solution to a problem, and represented as a bit string. It is intentionally general in order to lend itself to multiple domains. The only thing linking it to a particular problem set is the fitness function. A fitness function evaluates a chromosome, that is, the effectiveness of a proposed solution.
|
10
|
-
|
11
|
-
In my GeneticAlgorithms project, I use the engine to encapsulate the entire evolution process. You can quickly use it with default values like this:
|
12
|
-
|
13
|
-
<tt>GeneticAlgorithms::Engine.new.start "AllOffSample"</tt>
|
14
|
-
|
15
|
-
The argument to the start method is a fitness function. I have included a few with this project as a basic guide for creating your own.
|
16
|
-
|
17
|
-
The engine has three optional parameters that can be utilized during construction. The population size, chromosome length, and number of generations to evolve (in that order). You'll notice that modifying these values can have a tremendous effect on the algorithm itself, and that is one of the interesting characteristics of genetic algorithms. In the future I will be opening up more parameters as well; currently many of them are tightly coupled to their respective classes.
|