-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrun.rb
41 lines (27 loc) · 1022 Bytes
/
run.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
load 'init.rb'
log = File.new "foodbroker_#{SF}_#{FORMAT}.log", 'w'
log.puts "#{Time.now.strftime "%Y-%m-%d %H:%M:%S"} start"
load 'simulation/master_data.rb'
log.puts "#{Time.now.strftime "%Y-%m-%d %H:%M:%S"} #{DB.size} master data objects created"
conf = CONF['FoodBrokerage']
dates = (conf['Process']['date']['min']..conf['Process']['date']['max']).to_a
cases = (1..conf['Process']['growth']*SF).to_a
store = {
:mysql => FoodBroker2Sql.new,
:adlst => FoodBroker2AdjacencyList.new
}[FORMAT]
store.prepare!
cases.each do |i|
print "." if i%100 == 0
puts SF if i%10000 == 0
fb = FoodBrokerage.new dates[i*dates.size/cases.size]
store.record fb.tdos
cp = Complaints.new fb
store.record cp.tdos
log.puts "#{Time.now.strftime "%Y-%m-%d %H:%M:%S"} simulated #{i} cases" if i % (cases.last/10) == 0
end
store.record DB
log.puts "#{Time.now.strftime "%Y-%m-%d %H:%M:%S"} master data stored "
store.finish!
log.puts "#{Time.now.strftime "%Y-%m-%d %H:%M:%S"} end"
log.puts DomainData.stats