Class: Symian::IncidentGenerator
- Inherits:
-
Object
- Object
- Symian::IncidentGenerator
- Defined in:
- lib/symian/generator.rb
Instance Method Summary collapse
- #generate ⇒ Object
-
#initialize(simulation, options = {}) ⇒ IncidentGenerator
constructor
A new instance of IncidentGenerator.
Constructor Details
#initialize(simulation, options = {}) ⇒ IncidentGenerator
Returns a new instance of IncidentGenerator.
10 11 12 13 14 15 16 17 18 |
# File 'lib/symian/generator.rb', line 10 def initialize(simulation, ={}) @simulation = simulation @arrival_times = Sequence.create() raise ArgumentError unless @arrival_times # NOTE: so far we support only sequential integer iids @next_iid = 0 end |
Instance Method Details
#generate ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/symian/generator.rb', line 21 def generate # get next incident arrival time next_arrival = @arrival_times.next # handle case where arrival times is limited source return nil unless next_arrival # increase @next_iid @next_iid += 1 # generate and return incident i = Incident.new(@next_iid, next_arrival, :category => 'normal', # not supported at the moment :priority => 0) # not supported at the moment @simulation.new_event(Event::ET_INCIDENT_ARRIVAL, i, next_arrival, nil) end |