evolvable 1.0.1 → 1.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e9b226220f12cc98cfd94f14caf0f3898f0b1dab435bc4e8ce58696c053c8ea8
4
- data.tar.gz: d8f03fb093698fd25c24ee0038e813832caba6c80a802933c0d3cc97125e96b6
3
+ metadata.gz: c195de2ae7f05536ffa76f552733db479904aee34b83675624b1c68a4eba4128
4
+ data.tar.gz: fdca723c15870b73dce8aed5914f5d90d77d94a833ac0486ea929e41c31b63ef
5
5
  SHA512:
6
- metadata.gz: d25f4af589b828b4791c52b469e91f5814e5e06f372a331f4214cbfab6daf8d74dd2f7db777e6117c9b97fb04e55c9f007a612d31b6fba7b253784117df4edca
7
- data.tar.gz: ad7d7a46306d20512d199dc32eb688c0c2e8f03ff86358a9ef17e8f9e868117f40ebf5fe4cbafedf8ad843b8a055e722b1781bf145feaa9e51369889ee3131a5
6
+ metadata.gz: d4d9a4480c240285771f649462aa454444f37c35ef281df77d22902dba2725c620c8f63f0c5abb82ca2a3cf5ba023bb31b73b3b9491dcf66268abcd37f614e21
7
+ data.tar.gz: 24ab6bea46ec3eeaf555c1cdb02949a8be3177244430faa8232ae594e42b15f8a2015c3eff2013aa460f0f9b39777e058afc762b3ef41a55ae35574445670d68
data/CHANGELOG.md CHANGED
@@ -1,6 +1,14 @@
1
+ ## Unreleased
2
+
3
+ ## 1.0.2 - 2021-04-04
4
+
5
+ Features
6
+ * Make gene_key assignment a class level concern. Makes custom gene initialization simpler. https://github.com/mattruzicka/evolvable/pull/6
7
+
1
8
  ## 1.0.1
2
9
 
3
- Fix goal normalization in `Evolvable::Evaluation` when given an object
10
+ Bug fixes
11
+ * Fix goal normalization in `Evolvable::Evaluation` when given an object
4
12
 
5
13
  ## 1.0.0
6
14
 
data/Gemfile.lock CHANGED
@@ -1,38 +1,19 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- evolvable (1.0.0)
4
+ evolvable (1.0.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
- ast (2.4.1)
10
- byebug (11.1.3)
11
- jaro_winkler (1.5.4)
12
- parallel (1.19.2)
13
- parser (2.7.1.4)
14
- ast (~> 2.4.1)
15
- powerpack (0.1.2)
16
- rainbow (3.0.0)
17
- rubocop (0.64.0)
18
- jaro_winkler (~> 1.5.1)
19
- parallel (~> 1.10)
20
- parser (>= 2.5, != 2.5.1.1)
21
- powerpack (~> 0.1)
22
- rainbow (>= 2.2.2, < 4.0)
23
- ruby-progressbar (~> 1.7)
24
- unicode-display_width (~> 1.4.0)
25
- ruby-progressbar (1.10.1)
26
- unicode-display_width (1.4.1)
27
9
 
28
10
  PLATFORMS
29
11
  ruby
12
+ x86_64-darwin-18
30
13
 
31
14
  DEPENDENCIES
32
15
  bundler (~> 2.0)
33
- byebug (~> 11.0)
34
16
  evolvable!
35
- rubocop (~> 0.64.0)
36
17
 
37
18
  BUNDLED WITH
38
- 2.1.4
19
+ 2.2.0
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2020 Matt Ruzicka
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md CHANGED
@@ -1,4 +1,5 @@
1
1
  # Evolvable
2
+ [![Gem Version](https://badge.fury.io/rb/evolvable.svg)](https://badge.fury.io/rb/evolvable) [![Maintainability](https://api.codeclimate.com/v1/badges/7faf84a6d467718b33c0/maintainability)](https://codeclimate.com/github/mattruzicka/evolvable/maintainability)
2
3
 
3
4
  A framework for building evolutionary behaviors in Ruby.
4
5
 
data/evolvable.gemspec CHANGED
@@ -26,6 +26,4 @@ Gem::Specification.new do |spec|
26
26
  spec.require_paths = ['lib']
27
27
 
28
28
  spec.add_development_dependency 'bundler', '~> 2.0'
29
- spec.add_development_dependency 'byebug', '~> 11.0'
30
- spec.add_development_dependency 'rubocop', '~> 0.64.0'
31
29
  end
@@ -17,9 +17,9 @@ module Evolvable
17
17
  :mutation
18
18
 
19
19
  def call(population)
20
- @selection.call(population)
21
- @crossover.call(population)
22
- @mutation.call(population)
20
+ selection.call(population)
21
+ crossover.call(population)
22
+ mutation.call(population)
23
23
  population
24
24
  end
25
25
  end
@@ -3,11 +3,23 @@
3
3
  module Evolvable
4
4
  module Gene
5
5
  def self.included(base)
6
+ def base.key=(val)
7
+ @key = val
8
+ end
9
+
10
+ def base.key
11
+ @key
12
+ end
13
+
6
14
  def base.crossover(gene_a, gene_b)
7
15
  [gene_a, gene_b].sample
8
16
  end
9
17
  end
10
18
 
11
- attr_accessor :instance, :key
19
+ attr_accessor :instance
20
+
21
+ def key
22
+ self.class.key
23
+ end
12
24
  end
13
25
  end
@@ -16,10 +16,9 @@ module Evolvable
16
16
 
17
17
  def new_genes
18
18
  genes = []
19
- config.each do |gene_key, gene_config|
19
+ config.each do |_gene_key, gene_config|
20
20
  (gene_config[:count] || 1).times do
21
21
  gene = gene_config[:class].new
22
- gene.key = gene_key
23
22
  genes << gene
24
23
  end
25
24
  end
@@ -29,8 +28,12 @@ module Evolvable
29
28
  private
30
29
 
31
30
  def normalize_config(config)
32
- config.each do |_gene_key, gene_config|
33
- gene_config[:class] = Kernel.const_get(gene_config[:type]) if gene_config[:type]
31
+ config.each do |gene_key, gene_config|
32
+ next unless gene_config[:type]
33
+
34
+ gene_class = Kernel.const_get(gene_config[:type])
35
+ gene_class.key = gene_key
36
+ gene_config[:class] = gene_class
34
37
  end
35
38
  end
36
39
  end
@@ -35,7 +35,6 @@ module Evolvable
35
35
  def mutate_gene(instance, gene_index)
36
36
  gene = instance.genes[gene_index]
37
37
  mutant_gene = gene.class.new
38
- mutant_gene.key = gene.key
39
38
  instance.genes[gene_index] = mutant_gene
40
39
  end
41
40
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Evolvable
4
- VERSION = '1.0.1'
4
+ VERSION = '1.0.2'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: evolvable
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Ruzicka
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-09-13 00:00:00.000000000 Z
11
+ date: 2021-04-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -24,45 +24,17 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '2.0'
27
- - !ruby/object:Gem::Dependency
28
- name: byebug
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: '11.0'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: '11.0'
41
- - !ruby/object:Gem::Dependency
42
- name: rubocop
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: 0.64.0
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - "~>"
53
- - !ruby/object:Gem::Version
54
- version: 0.64.0
55
- description:
56
- email:
27
+ description:
28
+ email:
57
29
  executables: []
58
30
  extensions: []
59
31
  extra_rdoc_files: []
60
32
  files:
61
33
  - ".gitignore"
62
- - ".rubocop.yml"
63
34
  - CHANGELOG.md
64
35
  - Gemfile
65
36
  - Gemfile.lock
37
+ - LICENSE
66
38
  - README.md
67
39
  - bin/console
68
40
  - bin/setup
@@ -93,7 +65,7 @@ metadata:
93
65
  homepage_uri: https://github.com/mattruzicka/evolvable
94
66
  source_code_uri: https://github.com/mattruzicka/evolvable
95
67
  changelog_uri: https://github.com/mattruzicka/evolvable/blob/master/CHANGELOG.md
96
- post_install_message:
68
+ post_install_message:
97
69
  rdoc_options: []
98
70
  require_paths:
99
71
  - lib
@@ -108,8 +80,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
108
80
  - !ruby/object:Gem::Version
109
81
  version: '0'
110
82
  requirements: []
111
- rubygems_version: 3.1.2
112
- signing_key:
83
+ rubygems_version: 3.2.3
84
+ signing_key:
113
85
  specification_version: 4
114
86
  summary: Add evolutionary behavior to any Ruby object
115
87
  test_files: []
data/.rubocop.yml DELETED
@@ -1,20 +0,0 @@
1
- AllCops:
2
- TargetRubyVersion: 2.6.1
3
-
4
- Style/Documentation:
5
- Enabled: false
6
-
7
- Style/SymbolArray:
8
- Enabled: false
9
-
10
- Style/FrozenStringLiteralComment:
11
- Enabled: false
12
-
13
- Style/ClassAndModuleChildren:
14
- Enabled: false
15
-
16
- Naming/VariableNumber:
17
- EnforcedStyle: 'snake_case'
18
-
19
- Metrics/LineLength:
20
- Max: 90