Class: Nsga2Individual

Inherits:
Struct
  • Object
show all
Defined in:
../algorithm/nsga2.rb

Constant Summary

@@uniq =
{}

Instance Attribute Summary (collapse)

Class Method Summary (collapse)

Instance Method Summary (collapse)

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

Returns:

  • (Object)

    the current value of crowding



7
8
9
# File '../algorithm/nsga2.rb', line 7

def crowding
  @crowding
end

- (Object) depth

Returns the value of attribute depth

Returns:

  • (Object)

    the current value of depth



7
8
9
# File '../algorithm/nsga2.rb', line 7

def depth
  @depth
end

- (Object) orig

Returns the value of attribute orig

Returns:

  • (Object)

    the current value of orig



7
8
9
# File '../algorithm/nsga2.rb', line 7

def orig
  @orig
end

- (Object) uniq

Returns the value of attribute uniq

Returns:

  • (Object)

    the current value of 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)

Returns:

  • (Boolean)


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