-
Notifications
You must be signed in to change notification settings - Fork 1
/
chapter7_init.py
70 lines (54 loc) · 2.08 KB
/
chapter7_init.py
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# Decentralised water storage model: master file - Neal Hughes
# Chapter 7 model runs
from __future__ import division
import numpy as np
from para import Para
from model import Model
from results import chapter7
from results.chartbuilder import *
import sys
import multiprocessing
from multiprocessing.queues import Queue
from scipy.stats import truncnorm
home = '/home/nealbob'
folder = '/Dropbox/Model/results/chapter7/'
out = '/Dropbox/Thesis/IMG/chapter7/'
NCIhome = '/short/fr3/ndh401'
NCIfolder = '/chapter7/'
#==========================================
# NCI general case - initialisation
#==========================================
try:
arg1 = sys.argv[1]
except IndexError:
print "Provide arguments <runnum> <numofjobs> <scenario>"
para = Para()
para.central_case(N = 100)
para.randomize()
para.set_property_rights(scenario='CS')
run_no = int(arg1)
print '============================================================'
print 'Initialisation for run no: ' + str(run_no)
print '============================================================'
mod = Model(para, ch7=True, turn_off_env=True)
E_lambda = mod.chapter7_initialise()
print '============================================================'
print 'E_lambda: ' + str(E_lambda)
print '============================================================'
para.E_lambda_hat = E_lambda
#Truncated normal
E_lambda = truncnorm((0.01 - E_lambda) / 0.05, (0.99 - E_lambda) / 0.05, loc=E_lambda, scale=0.05).rvs()
print '============================================================'
print 'E_lambda: ' + str(E_lambda)
print '============================================================'
para.ch7['inflow_share'] = E_lambda
para.ch7['capacity_share'] = E_lambda
para.t_cost = para.t_cost/2.0
para.aproximate_shares_ch7()
print '============================================================'
print 'Lambda high: ' + str(para.Lambda_high)
print 'Lambda high HL: ' + str(para.Lambda_high_HL)
print '============================================================'
with open(NCIhome + NCIfolder + str(run_no) + '_para.pkl', 'wb') as f:
pickle.dump(para, f)
f.close()