Class: FeldtRuby::Optimize::Objective::MeanWeigthedGlobalRatios

Inherits:
WeightedSumAggregator show all
Defined in:
lib/feldtruby/optimize/objective.rb

Overview

A SumOfWeightedGlobalRatios is very similar to Bentley’s SWGR multi-objective fitness mapping scheme as described in the paper:

P. J. Bentley and J. P. Wakefield, "Finding Acceptable Solutions in the 
Pareto-Optimal Range using Multiobjective Genetic Algorithms", 1997
http://eprints.hud.ac.uk/4052/1/PB_%26_JPW_1997_Finding_Acceptable_Solutions.htm

with the difference that lower values indicate better quality and we use mean instead of sum, and thus call it MWGR. It is the weighted sum of the ratios to the best so far for each goal. One of its benefits is that one need not sort individuals in relation to their peers; the aggregate fitness value is fully determined by the individual and the global min and max values for each objective.

Instance Attribute Summary

Attributes inherited from QualityAggregator

#objective

Instance Method Summary collapse

Instance Method Details

#aggregate_from_sub_qualities(subQualityValues, weights) ⇒ Object



394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
# File 'lib/feldtruby/optimize/objective.rb', line 394

def aggregate_from_sub_qualities subQualityValues, weights
  goal_mins = objective.global_min_values_per_goal
  goal_maxs = objective.global_max_values_per_goal

  ratios = subQualityValues.map_with_index do |v, i| 
    ratio i, v, goal_mins[i], goal_maxs[i]
  end

  # We cannot reuse the superclass in calculating the weighted sum since
  # we have already taken the signs into account in the ratio method.
  sum = 0.0
  ratios.each_with_index do |r, i|
    sum += (r * weights[i])
  end

  sum / weights.sum.to_f
end

#make_quality_value(subQvs, candidate, objective) ⇒ Object



380
381
382
# File 'lib/feldtruby/optimize/objective.rb', line 380

def make_quality_value(subQvs, candidate, objective)
  PercentageQualityValue.new subQvs, candidate, objective
end

#ratio(index, value, min, max) ⇒ Object



384
385
386
387
388
389
390
391
392
# File 'lib/feldtruby/optimize/objective.rb', line 384

def ratio(index, value, min, max)
  return 1000.0 if value == nil # We heavily penalize if one sub-quality could not be calculated. Max is otherwise 1.0.
  if objective.is_min_goal?(index)
    numerator = value - min
  else
    numerator = max - value
  end
  numerator.to_f.protected_division_with(max - min)
end