Class: Micro::Parameter

Inherits:
Object
  • Object
show all
Defined in:
lib/micro_agent.rb

Overview

Represents an individual parameter of an agent. Parameters are updated with each call to #step_world. See the attributes below for a description of the properties that are possible on each parameter.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize {|_self| ... } ⇒ Parameter

Returns a new instance of Parameter.

Yields:

  • (_self)

Yield Parameters:



154
155
156
157
158
159
# File 'lib/micro_agent.rb', line 154

def initialize
  @depends_on = []
  @probability = 1.0
  yield self
  @value = @start_value
end

Instance Attribute Details

#change_funcObject

Takes a passed in block. The block is used to update this parameter’s value. The block is passed the current value of this parameter and then the value of any dependant parameter’s values (in the order they are specified in the depends_on property). This looks like:

:speed => Micro::Parameter.new do |p|
  p.start_value = 0
  p.depends_on  = :distance, :time
  p.change_func = lambda { |value, distance, time| distance / time }
end


144
145
146
# File 'lib/micro_agent.rb', line 144

def change_func
  @change_func
end

#depends_onObject

Specifies which parameter’s this parameter is dependent on for it’s calculations. See #change_func



147
148
149
# File 'lib/micro_agent.rb', line 147

def depends_on
  @depends_on
end

#maxObject

Specifies an upper and lower bound on this parameter’s value.



150
151
152
# File 'lib/micro_agent.rb', line 150

def max
  @max
end

#minObject

Specifies an upper and lower bound on this parameter’s value.



150
151
152
# File 'lib/micro_agent.rb', line 150

def min
  @min
end

#probabilityObject

The probility that this parameter is updated. Should be between 0.0 and 1.0.



129
130
131
# File 'lib/micro_agent.rb', line 129

def probability
  @probability
end

#start_valueObject

The starting value of this parameter



132
133
134
# File 'lib/micro_agent.rb', line 132

def start_value
  @start_value
end

#valueObject

Returns the value of attribute value.



152
153
154
# File 'lib/micro_agent.rb', line 152

def value
  @value
end