Class: Nsga2Individual
- Inherits:
-
Struct
- Object
- Struct
- Nsga2Individual
- Defined in:
- ../algorithm/nsga2.rb
Constant Summary
- @@uniq =
{}
Instance Attribute Summary (collapse)
-
- (Object) crowding
Returns the value of attribute crowding.
-
- (Object) depth
Returns the value of attribute depth.
-
- (Object) orig
Returns the value of attribute orig.
-
- (Object) uniq
Returns the value of attribute uniq.
Class Method Summary (collapse)
Instance Method Summary (collapse)
- - (Object) <=>(other)
- - (Object) cache_uniq
- - (Boolean) dominates?(other)
-
- (Nsga2Individual) initialize(orig, depth, crowding)
constructor
A new instance of Nsga2Individual.
Constructor Details
- (Nsga2Individual) initialize(orig, depth, crowding)
A new instance of Nsga2Individual
15 16 17 18 |
# File '../algorithm/nsga2.rb', line 15 def initialize( orig, depth, crowding ) super @@uniq[orig.genotype] += 1 end |
Instance Attribute Details
- (Object) crowding
Returns the value of attribute crowding
7 8 9 |
# File '../algorithm/nsga2.rb', line 7 def crowding @crowding end |
- (Object) depth
Returns the value of attribute depth
7 8 9 |
# File '../algorithm/nsga2.rb', line 7 def depth @depth end |
- (Object) orig
Returns the value of attribute orig
7 8 9 |
# File '../algorithm/nsga2.rb', line 7 def orig @orig end |
- (Object) uniq
Returns the value of attribute uniq
7 8 9 |
# File '../algorithm/nsga2.rb', line 7 def uniq @uniq end |
Class Method Details
+ (Object) uniq_clear
11 12 13 |
# File '../algorithm/nsga2.rb', line 11 def Nsga2Individual.uniq_clear @@uniq.clear end |
Instance Method Details
- (Object) <=>(other)
32 33 34 35 36 37 38 39 |
# File '../algorithm/nsga2.rb', line 32 def <=>(other) if dominates? other return -1 else return 1 if other.dominates? self return 0 end end |
- (Object) cache_uniq
20 21 22 |
# File '../algorithm/nsga2.rb', line 20 def cache_uniq self.uniq = @@uniq[orig.genotype] end |
- (Boolean) dominates?(other)
24 25 26 27 28 29 30 |
# File '../algorithm/nsga2.rb', line 24 def dominates? other return true if self.depth < other.depth return false if self.depth > other.depth return true if self.crowding > other.crowding return false if self.crowding < other.crowding return self.uniq < other.uniq end |