-
Notifications
You must be signed in to change notification settings - Fork 1
/
JointMLEProfileLL.run
103 lines (86 loc) · 2.33 KB
/
JointMLEProfileLL.run
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# Load model and data
model "MarkovActv.mod";
data "MarkovActv.dat";
# include the simulated states and choices
data "DATA/jointMC.dat";
# read the estimates
data "DATA/jointMLE.dat";
# Is Cauchy distribution used ?
fix IS_CAUCHY := 1;
# logging options
let debug_log := 1;
# include the code that define the component state and choice set
include MDPStateAction.run
include JointMDPStateAction.run
# Define the composite MDP problem for the entire household
problem compositeMDP:
# Choose the objective function
likelihood0,
# List the variables
EW,
actvUtil,
sumActvUtil,
jointChoiceUtil,
jointChoiceProb,
Um, b, c, rho,
# List the constraints
Bellman_Joint,
Bellman_JointH;
fix {n in PERS, j in ACTV} Um[n,j] := Um_[n,j];
fix {n in PERS, j in ACTV} b[n,j] := b_[n,j];
fix {n in PERS, j in ACTV} c[n,j] := c_[n,j];
fix {j in ACTV} rho[j] := rho_[j];
# Specify KNITRO solver options:
option solver "C:\Ziena\KNITRO900\knitroampl\knitroampl.exe";
option knitro_options "alg=2 hessopt=1 outlev=1 maxit=100 xtol=0.0000000001 wantsol=1";
# Output commands
option display_round 6, display_width 120;
option solver_msg 0;
option show_stats 0;
# option log_file "DATA/LL.log";
# first, try all the possible values of rho[3]
set RHO := (0..10);
param ll_rho3 {RHO};
for {r in RHO} {
# set rho
fix rho[3] := r / 10.0;
# solve the problem
solve compositeMDP > DATA/jointLL.log;
# calculate likelihood
let ll_rho3[r] := likelihood_joint;
display r, ll_rho3[r], _solve_time;
}
# print likelihood values
printf "rho = [\n" > DATA/jointLL.m;
for {r in RHO} {
printf "%f\n", r> DATA/jointLL.m;
}
printf "];\n" > DATA/jointLL.m;
printf "ll_rho3 = [\n" > DATA/jointLL.m;
for {r in RHO} {
printf "%f\n", ll_rho3[r] > DATA/jointLL.m;
}
printf "];\n" > DATA/jointLL.m;
# then, try all the possible combinations of rho[1] and rho[3]
param ll_rho13 {RHO cross RHO};
for {r1 in RHO} {
for {r3 in RHO} {
# set rho
fix rho[1] := r1 / 10.0;
fix rho[3] := r3 / 10.0;
# solve the problem
solve compositeMDP > DATA/jointLL.log;
# calculate likelihood
let ll_rho13[r1,r3] := likelihood_joint;
display r1, r3, ll_rho13[r1,r3], _solve_time;
}
}
# print likelihood values
printf "ll_rho13 = [\n" > DATA/jointLL.m;
for {r1 in RHO} {
for {r3 in RHO} {
printf "%f\t", ll_rho13[r1,r3] > DATA/jointLL.m;
}
printf "\n" > DATA/jointLL.m;
}
printf "];\n" > DATA/jointLL.m;