feldtruby 0.4.2 → 0.4.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3a76753a45218658033069292166e1f2a6632958
4
- data.tar.gz: f7885cd0eece07094aca1d27da9da38e9ddbf51f
3
+ metadata.gz: ad952a39bbe9677ec2b77ad2c6e31fc5f36bf0a1
4
+ data.tar.gz: b56013ccf611756359d1d5b693fd6fb2bbbad34b
5
5
  SHA512:
6
- metadata.gz: 96eef547a76262a695fc9480abf6b672b5536881953754ee5b8461de00fa08df05718c5b3e3e40894d4c4d65f527802cec3f11e695a4ca3e9d5b55ba24b2d9b8
7
- data.tar.gz: db581f0014c8252980e263db25eacc6804723022d8b08130678a2cdf0f1711baf1118fbb26e710101e9225b2ff6ea00fb526be987017e2539d6f403acee8d95a
6
+ metadata.gz: cb3b0858ec241137b537d803cd451a53266b0e19d41fe230b7e2372992cd1841b19e1b1f4b2eb1467f57852f3eeaca9fb20d19d7b5d6e8f0c9af9631dfd30309
7
+ data.tar.gz: 65bc21364e93321ed1f7f87d8d93225a7a390ae96efd0bd7912add8170500588e5deb9ab4d2af1c6df529bf150112823b85221f001a3eb6635af517e539246e0
@@ -261,6 +261,8 @@ class Objective
261
261
  min = @global_min_values_per_goal[index]
262
262
  max = @global_max_values_per_goal[index]
263
263
 
264
+ return unless qValue
265
+
264
266
  if qValue < min
265
267
 
266
268
  @global_min_values_per_goal[index] = qValue
@@ -1,3 +1,3 @@
1
1
  module FeldtRuby
2
- VERSION = "0.4.2"
2
+ VERSION = "0.4.3"
3
3
  end
@@ -49,11 +49,11 @@ describe "Sphere function" do
49
49
  time.must_be :<, 7.5
50
50
  end
51
51
 
52
- it 'can optimize the Sphere function in 30 dimensions' do
53
- best, obj, time = best_from_de_on_objective MinSphere.new, 30, 220_000
54
- time.must_be :<, 28.0
55
- # We don't test closeness since it might take very long for 30D to get close on all dimensions.
56
- end
52
+ # it 'can optimize the Sphere function in 30 dimensions' do
53
+ # best, obj, time = best_from_de_on_objective MinSphere.new, 30, 220_000
54
+ # time.must_be :<, 28.0
55
+ # # We don't test closeness since it might take very long for 30D to get close on all dimensions.
56
+ # end
57
57
  end
58
58
 
59
59
  describe "Levi13 function" do
@@ -76,9 +76,8 @@ describe "Easom function" do
76
76
  it 'can optimize the Easom function' do
77
77
  objective = MinEasom.new
78
78
  ss = objective.search_space
79
- # Why can't we do this in 25_000 evals anymore? We did it before. Repeatedly. Very strange.
80
79
  de = DEOptimizer.new(objective, ss, {:verbose => false,
81
- :maxNumSteps => 40_000, :printFrequency => 0.0,
80
+ :maxNumSteps => 30_000, :printFrequency => 0.0,
82
81
  :samplerRadius => 5})
83
82
  best = de.optimize().to_a
84
83
 
@@ -477,4 +477,24 @@ describe "Using MWGR for range-independent aggregate fitness calc" do
477
477
  @o.rank_candidates([i3,i1]).must_equal [i1,i3]
478
478
  @o.rank_candidates([i2,i3]).must_equal [i2,i3]
479
479
  end
480
+ end
481
+
482
+ class ObjectiveReturningNil < FeldtRuby::Optimize::Objective
483
+ def objective_min_sum(ary)
484
+ return nil if ary.length < 1
485
+ ary.sum
486
+ end
487
+ end
488
+
489
+ describe "Can handle objectives that return nil" do
490
+ it 'works' do
491
+ o = ObjectiveReturningNil.new
492
+ q1 = o.quality_of([1])
493
+ q1.sub_qualities.must_equal [1]
494
+ q1.value.must_equal 0.0 # Perfect score
495
+
496
+ q2 = o.quality_of([])
497
+ q2.sub_qualities.must_equal [nil]
498
+ q2.value.must_equal 1000.0 # Max penalty
499
+ end
480
500
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: feldtruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Feldt