annealing 0.1.0 → 0.2.0

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: f897b42e638f2f0f3d951ef0ad9c159352758d120d0978cc522867c2049c0e45
4
- data.tar.gz: de092114cab627c60484995e8c22f87a9eca73b5965bd90de57f0f177efebadb
3
+ metadata.gz: 53e5900add60de36b8e3bb441be9bce450f6dcb3cbd67552913684745e90a0c1
4
+ data.tar.gz: 00347f761988a73951ed950317c1fc6ebf6d1add2d2ab1889bf8cbe6eebabe36
5
5
  SHA512:
6
- metadata.gz: 5fc76aa32422d56ed36193cab617bafc6ffa0c72c6f3328dc5d48c691caf1385984e682fecde729b4c8c3f033a48b666b03ea9a4918ae9575ff6146f1382e157
7
- data.tar.gz: 0e21c28aa803232597f46cd26b6a5167df07ce044d77425e9caeba07181e1cfd4ac0de1709d895f7fe1acac5eeecde6e2eaabb805d11b6f84626a600001407a5
6
+ metadata.gz: ef3653ce209af0a76189157cdecbbac58613aa86845b0e8476a22407fc17b9edb75e879f1676497eb7f1d8b4f86549719f67825f7c48db134603ed784d2d5ef1
7
+ data.tar.gz: 022accd062db4cc155e50606d22ea7e51db7603a61ef9b40512625110d528975de275b1abbb5ea6604fa98162122ef8b5e143f474593536af4291089e4d3f229
data/README.md CHANGED
@@ -1,4 +1,5 @@
1
1
  # Annealing
2
+ [![Gem Version](https://badge.fury.io/rb/annealing.svg)](https://badge.fury.io/rb/annealing)
2
3
 
3
4
  Find the optimal solution in a complex problem through a simulated annealing implementation for enumerable objects. Where the energy of each object can be measured by a distance method between two elements or a lambda function where the total energy is calculated in the objects.
4
5
 
@@ -97,7 +98,7 @@ or in the simulator as a parameter
97
98
  calc = lambda do |enumerable|
98
99
  enumerable.each_cons(2).sum { |a, b| a.distance(b) }
99
100
  end
100
- solution = simulator.run(locations, energy_calculator: calc).collection
101
+ solution = simulator.run(locations, calc).collection
101
102
  [(20,40), (40,120), (100,120), (60,200), (180,200)]
102
103
  ```
103
104
 
@@ -5,7 +5,7 @@ module Annealing
5
5
  class Pool
6
6
  attr_reader :collection
7
7
 
8
- def initialize(collection, energy_calculator: nil)
8
+ def initialize(collection, energy_calculator = nil)
9
9
  @collection = collection.dup
10
10
  @energy_calculator = energy_calculator || Annealing.configuration.total_energy_calculator
11
11
  end
@@ -32,14 +32,14 @@ module Annealing
32
32
  format('%<energy>.4f:%<value>s', energy: energy, value: collection)
33
33
  end
34
34
 
35
+ def next
36
+ Pool.new(swap_collection, energy_calculator)
37
+ end
38
+
35
39
  private
36
40
 
37
41
  attr_reader :energy_calculator
38
42
 
39
- def next
40
- Pool.new(swap_collection, energy_calculator: energy_calculator)
41
- end
42
-
43
43
  def swap_collection
44
44
  swapped = collection.dup
45
45
  idx_a = rand(size)
@@ -14,8 +14,8 @@ module Annealing
14
14
  normalize_cooling_rate
15
15
  end
16
16
 
17
- def run(collection, energy_calculator: nil)
18
- best = current = Pool.new(collection.shuffle, energy_calculator: energy_calculator)
17
+ def run(collection, calculator = nil)
18
+ best = current = Pool.new(collection.shuffle, calculator)
19
19
  Annealing.logger.debug(" Original: #{current}")
20
20
  cool_down do |temp|
21
21
  current = current.solution_at(temp)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Annealing
4
- VERSION = '0.1.0'
4
+ VERSION = '0.2.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: annealing
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luis Ezcurdia Razo
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-06-17 00:00:00.000000000 Z
11
+ date: 2020-06-23 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Simulated Annealing algoritm implementation.
14
14
  email: