Class: Musa::Darwin::Darwin::Measure Private
- Defined in:
- lib/musa-dsl/generative/darwin.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Measurement result for an object.
Contains features, dimensions, and viability status.
Instance Attribute Summary collapse
-
#dimensions ⇒ Hash{Symbol => Numeric}
readonly
private
raw dimension values.
-
#features ⇒ Hash{Symbol => Boolean}
readonly
private
feature flags.
-
#normalized_dimensions ⇒ Hash{Symbol => Float}
readonly
private
normalized (0-1) dimensions.
Instance Method Summary collapse
-
#died? ⇒ Boolean
private
Checks if object is non-viable.
-
#evaluate_weight(weights) ⇒ Float
private
Calculates weighted fitness score.
-
#initialize(features, dimensions, died) ⇒ Measure
constructor
private
A new instance of Measure.
- #inspect ⇒ Object (also: #to_s) private
Constructor Details
#initialize(features, dimensions, died) ⇒ Measure
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Measure.
284 285 286 287 288 289 290 |
# File 'lib/musa-dsl/generative/darwin.rb', line 284 def initialize(features, dimensions, died) @features = features @dimensions = dimensions @died = died @normalized_dimensions = {} end |
Instance Attribute Details
#dimensions ⇒ Hash{Symbol => Numeric} (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
raw dimension values
280 281 282 |
# File 'lib/musa-dsl/generative/darwin.rb', line 280 def dimensions @dimensions end |
#features ⇒ Hash{Symbol => Boolean} (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
feature flags
280 281 282 |
# File 'lib/musa-dsl/generative/darwin.rb', line 280 def features @features end |
#normalized_dimensions ⇒ Hash{Symbol => Float} (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
normalized (0-1) dimensions
280 281 282 |
# File 'lib/musa-dsl/generative/darwin.rb', line 280 def normalized_dimensions @normalized_dimensions end |
Instance Method Details
#died? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Checks if object is non-viable.
296 297 298 |
# File 'lib/musa-dsl/generative/darwin.rb', line 296 def died? @died end |
#evaluate_weight(weights) ⇒ Float
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Calculates weighted fitness score.
Sums weighted normalized dimensions and features.
309 310 311 312 313 314 315 316 317 318 319 320 |
# File 'lib/musa-dsl/generative/darwin.rb', line 309 def evaluate_weight(weights) total = 0.0 unless @died weights.each do |name, weight| total += @normalized_dimensions[name] * weight if @normalized_dimensions.key? name total += weight if @features[name] end end total end |
#inspect ⇒ Object Also known as: to_s
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
322 323 324 |
# File 'lib/musa-dsl/generative/darwin.rb', line 322 def inspect "Measure features=#{@features.collect { |k, _v| k }} dimensions=#{@normalized_dimensions.collect { |k, v| [k, [@dimensions[k].round(5), v.round(2)]] }.to_h}" end |