Class: Micro::Parameter
- Inherits:
-
Object
- Object
- Micro::Parameter
- 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
-
#change_func ⇒ Object
Takes a passed in block.
-
#depends_on ⇒ Object
Specifies which parameter’s this parameter is dependent on for it’s calculations.
-
#max ⇒ Object
Specifies an upper and lower bound on this parameter’s value.
-
#min ⇒ Object
Specifies an upper and lower bound on this parameter’s value.
-
#probability ⇒ Object
The probility that this parameter is updated.
-
#start_value ⇒ Object
The starting value of this parameter.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
-
#initialize {|_self| ... } ⇒ Parameter
constructor
A new instance of Parameter.
Constructor Details
#initialize {|_self| ... } ⇒ Parameter
Returns a new instance of Parameter.
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_func ⇒ Object
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_on ⇒ Object
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 |
#max ⇒ Object
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 |
#min ⇒ Object
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 |
#probability ⇒ Object
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_value ⇒ Object
The starting value of this parameter
132 133 134 |
# File 'lib/micro_agent.rb', line 132 def start_value @start_value end |
#value ⇒ Object
Returns the value of attribute value.
152 153 154 |
# File 'lib/micro_agent.rb', line 152 def value @value end |