compiled-knowledge 4.0.0a20__cp313-cp313-musllinux_1_2_x86_64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of compiled-knowledge might be problematic. Click here for more details.
- ck/__init__.py +0 -0
- ck/circuit/__init__.py +17 -0
- ck/circuit/_circuit_cy.c +37520 -0
- ck/circuit/_circuit_cy.cpython-313-x86_64-linux-musl.so +0 -0
- ck/circuit/_circuit_cy.pxd +32 -0
- ck/circuit/_circuit_cy.pyx +768 -0
- ck/circuit/_circuit_py.py +836 -0
- ck/circuit/tmp_const.py +74 -0
- ck/circuit_compiler/__init__.py +2 -0
- ck/circuit_compiler/circuit_compiler.py +26 -0
- ck/circuit_compiler/cython_vm_compiler/__init__.py +1 -0
- ck/circuit_compiler/cython_vm_compiler/_compiler.c +19821 -0
- ck/circuit_compiler/cython_vm_compiler/_compiler.cpython-313-x86_64-linux-musl.so +0 -0
- ck/circuit_compiler/cython_vm_compiler/_compiler.pyx +380 -0
- ck/circuit_compiler/cython_vm_compiler/cython_vm_compiler.py +121 -0
- ck/circuit_compiler/interpret_compiler.py +223 -0
- ck/circuit_compiler/llvm_compiler.py +388 -0
- ck/circuit_compiler/llvm_vm_compiler.py +546 -0
- ck/circuit_compiler/named_circuit_compilers.py +57 -0
- ck/circuit_compiler/support/__init__.py +0 -0
- ck/circuit_compiler/support/circuit_analyser/__init__.py +13 -0
- ck/circuit_compiler/support/circuit_analyser/_circuit_analyser_cy.c +10615 -0
- ck/circuit_compiler/support/circuit_analyser/_circuit_analyser_cy.cpython-313-x86_64-linux-musl.so +0 -0
- ck/circuit_compiler/support/circuit_analyser/_circuit_analyser_cy.pyx +98 -0
- ck/circuit_compiler/support/circuit_analyser/_circuit_analyser_py.py +93 -0
- ck/circuit_compiler/support/input_vars.py +148 -0
- ck/circuit_compiler/support/llvm_ir_function.py +234 -0
- ck/example/__init__.py +53 -0
- ck/example/alarm.py +366 -0
- ck/example/asia.py +28 -0
- ck/example/binary_clique.py +32 -0
- ck/example/bow_tie.py +33 -0
- ck/example/cancer.py +37 -0
- ck/example/chain.py +38 -0
- ck/example/child.py +199 -0
- ck/example/clique.py +33 -0
- ck/example/cnf_pgm.py +39 -0
- ck/example/diamond_square.py +68 -0
- ck/example/earthquake.py +36 -0
- ck/example/empty.py +10 -0
- ck/example/hailfinder.py +539 -0
- ck/example/hepar2.py +628 -0
- ck/example/insurance.py +504 -0
- ck/example/loop.py +40 -0
- ck/example/mildew.py +38161 -0
- ck/example/munin.py +22982 -0
- ck/example/pathfinder.py +53747 -0
- ck/example/rain.py +39 -0
- ck/example/rectangle.py +161 -0
- ck/example/run.py +30 -0
- ck/example/sachs.py +129 -0
- ck/example/sprinkler.py +30 -0
- ck/example/star.py +44 -0
- ck/example/stress.py +64 -0
- ck/example/student.py +43 -0
- ck/example/survey.py +46 -0
- ck/example/triangle_square.py +54 -0
- ck/example/truss.py +49 -0
- ck/in_out/__init__.py +3 -0
- ck/in_out/parse_ace_lmap.py +216 -0
- ck/in_out/parse_ace_nnf.py +322 -0
- ck/in_out/parse_net.py +480 -0
- ck/in_out/parser_utils.py +185 -0
- ck/in_out/pgm_pickle.py +42 -0
- ck/in_out/pgm_python.py +268 -0
- ck/in_out/render_bugs.py +111 -0
- ck/in_out/render_net.py +177 -0
- ck/in_out/render_pomegranate.py +184 -0
- ck/pgm.py +3475 -0
- ck/pgm_circuit/__init__.py +1 -0
- ck/pgm_circuit/marginals_program.py +352 -0
- ck/pgm_circuit/mpe_program.py +237 -0
- ck/pgm_circuit/pgm_circuit.py +79 -0
- ck/pgm_circuit/program_with_slotmap.py +236 -0
- ck/pgm_circuit/slot_map.py +35 -0
- ck/pgm_circuit/support/__init__.py +0 -0
- ck/pgm_circuit/support/compile_circuit.py +83 -0
- ck/pgm_circuit/target_marginals_program.py +103 -0
- ck/pgm_circuit/wmc_program.py +323 -0
- ck/pgm_compiler/__init__.py +2 -0
- ck/pgm_compiler/ace/__init__.py +1 -0
- ck/pgm_compiler/ace/ace.py +299 -0
- ck/pgm_compiler/factor_elimination.py +395 -0
- ck/pgm_compiler/named_pgm_compilers.py +63 -0
- ck/pgm_compiler/pgm_compiler.py +19 -0
- ck/pgm_compiler/recursive_conditioning.py +231 -0
- ck/pgm_compiler/support/__init__.py +0 -0
- ck/pgm_compiler/support/circuit_table/__init__.py +17 -0
- ck/pgm_compiler/support/circuit_table/_circuit_table_cy.c +16393 -0
- ck/pgm_compiler/support/circuit_table/_circuit_table_cy.cpython-313-x86_64-linux-musl.so +0 -0
- ck/pgm_compiler/support/circuit_table/_circuit_table_cy.pyx +332 -0
- ck/pgm_compiler/support/circuit_table/_circuit_table_py.py +304 -0
- ck/pgm_compiler/support/clusters.py +568 -0
- ck/pgm_compiler/support/factor_tables.py +406 -0
- ck/pgm_compiler/support/join_tree.py +332 -0
- ck/pgm_compiler/support/named_compiler_maker.py +43 -0
- ck/pgm_compiler/variable_elimination.py +91 -0
- ck/probability/__init__.py +0 -0
- ck/probability/empirical_probability_space.py +50 -0
- ck/probability/pgm_probability_space.py +32 -0
- ck/probability/probability_space.py +622 -0
- ck/program/__init__.py +3 -0
- ck/program/program.py +137 -0
- ck/program/program_buffer.py +180 -0
- ck/program/raw_program.py +67 -0
- ck/sampling/__init__.py +0 -0
- ck/sampling/forward_sampler.py +211 -0
- ck/sampling/marginals_direct_sampler.py +113 -0
- ck/sampling/sampler.py +62 -0
- ck/sampling/sampler_support.py +232 -0
- ck/sampling/uniform_sampler.py +72 -0
- ck/sampling/wmc_direct_sampler.py +171 -0
- ck/sampling/wmc_gibbs_sampler.py +153 -0
- ck/sampling/wmc_metropolis_sampler.py +165 -0
- ck/sampling/wmc_rejection_sampler.py +115 -0
- ck/utils/__init__.py +0 -0
- ck/utils/iter_extras.py +163 -0
- ck/utils/local_config.py +270 -0
- ck/utils/map_list.py +128 -0
- ck/utils/map_set.py +128 -0
- ck/utils/np_extras.py +51 -0
- ck/utils/random_extras.py +64 -0
- ck/utils/tmp_dir.py +94 -0
- ck_demos/__init__.py +0 -0
- ck_demos/ace/__init__.py +0 -0
- ck_demos/ace/copy_ace_to_ck.py +15 -0
- ck_demos/ace/demo_ace.py +49 -0
- ck_demos/all_demos.py +88 -0
- ck_demos/circuit/__init__.py +0 -0
- ck_demos/circuit/demo_circuit_dump.py +22 -0
- ck_demos/circuit/demo_derivatives.py +43 -0
- ck_demos/circuit_compiler/__init__.py +0 -0
- ck_demos/circuit_compiler/compare_circuit_compilers.py +32 -0
- ck_demos/circuit_compiler/show_llvm_program.py +26 -0
- ck_demos/pgm/__init__.py +0 -0
- ck_demos/pgm/demo_pgm_dump.py +18 -0
- ck_demos/pgm/demo_pgm_dump_stress.py +18 -0
- ck_demos/pgm/demo_pgm_string_rendering.py +15 -0
- ck_demos/pgm/show_examples.py +25 -0
- ck_demos/pgm_compiler/__init__.py +0 -0
- ck_demos/pgm_compiler/compare_pgm_compilers.py +63 -0
- ck_demos/pgm_compiler/demo_compiler_dump.py +60 -0
- ck_demos/pgm_compiler/demo_factor_elimination.py +47 -0
- ck_demos/pgm_compiler/demo_join_tree.py +25 -0
- ck_demos/pgm_compiler/demo_marginals_program.py +53 -0
- ck_demos/pgm_compiler/demo_mpe_program.py +55 -0
- ck_demos/pgm_compiler/demo_pgm_compiler.py +38 -0
- ck_demos/pgm_compiler/demo_recursive_conditioning.py +33 -0
- ck_demos/pgm_compiler/demo_variable_elimination.py +33 -0
- ck_demos/pgm_compiler/demo_wmc_program.py +29 -0
- ck_demos/pgm_compiler/time_fe_compiler.py +93 -0
- ck_demos/pgm_inference/__init__.py +0 -0
- ck_demos/pgm_inference/demo_inferencing_basic.py +188 -0
- ck_demos/pgm_inference/demo_inferencing_mpe_cancer.py +45 -0
- ck_demos/pgm_inference/demo_inferencing_wmc_and_mpe_sprinkler.py +154 -0
- ck_demos/pgm_inference/demo_inferencing_wmc_student.py +110 -0
- ck_demos/programs/__init__.py +0 -0
- ck_demos/programs/demo_program_buffer.py +24 -0
- ck_demos/programs/demo_program_multi.py +24 -0
- ck_demos/programs/demo_program_none.py +19 -0
- ck_demos/programs/demo_program_single.py +23 -0
- ck_demos/programs/demo_raw_program_interpreted.py +21 -0
- ck_demos/programs/demo_raw_program_llvm.py +21 -0
- ck_demos/sampling/__init__.py +0 -0
- ck_demos/sampling/check_sampler.py +71 -0
- ck_demos/sampling/demo_marginal_direct_sampler.py +40 -0
- ck_demos/sampling/demo_uniform_sampler.py +38 -0
- ck_demos/sampling/demo_wmc_direct_sampler.py +40 -0
- ck_demos/utils/__init__.py +0 -0
- ck_demos/utils/compare.py +120 -0
- ck_demos/utils/convert_network.py +45 -0
- ck_demos/utils/sample_model.py +216 -0
- ck_demos/utils/stop_watch.py +384 -0
- compiled_knowledge-4.0.0a20.dist-info/METADATA +50 -0
- compiled_knowledge-4.0.0a20.dist-info/RECORD +178 -0
- compiled_knowledge-4.0.0a20.dist-info/WHEEL +5 -0
- compiled_knowledge-4.0.0a20.dist-info/licenses/LICENSE.txt +21 -0
- compiled_knowledge-4.0.0a20.dist-info/top_level.txt +2 -0
ck/example/insurance.py
ADDED
|
@@ -0,0 +1,504 @@
|
|
|
1
|
+
from ck.pgm import PGM
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class Insurance(PGM):
|
|
5
|
+
"""
|
|
6
|
+
This PGM is the well known 'Insurance' Bayesian network.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
def __init__(self):
|
|
10
|
+
super().__init__(self.__class__.__name__)
|
|
11
|
+
|
|
12
|
+
GoodStudent = self.new_rv('GoodStudent', ('True', 'False'))
|
|
13
|
+
Age = self.new_rv('Age', ('Adolescent', 'Adult', 'Senior'))
|
|
14
|
+
SocioEcon = self.new_rv('SocioEcon', ('Prole', 'Middle', 'UpperMiddle', 'Wealthy'))
|
|
15
|
+
RiskAversion = self.new_rv('RiskAversion', ('Psychopath', 'Adventurous', 'Normal', 'Cautious'))
|
|
16
|
+
VehicleYear = self.new_rv('VehicleYear', ('Current', 'Older'))
|
|
17
|
+
ThisCarDam = self.new_rv('ThisCarDam', ('None', 'Mild', 'Moderate', 'Severe'))
|
|
18
|
+
RuggedAuto = self.new_rv('RuggedAuto', ('EggShell', 'Football', 'Tank'))
|
|
19
|
+
Accident = self.new_rv('Accident', ('None', 'Mild', 'Moderate', 'Severe'))
|
|
20
|
+
MakeModel = self.new_rv('MakeModel', ('SportsCar', 'Economy', 'FamilySedan', 'Luxury', 'SuperLuxury'))
|
|
21
|
+
DrivQuality = self.new_rv('DrivQuality', ('Poor', 'Normal', 'Excellent'))
|
|
22
|
+
Mileage = self.new_rv('Mileage', ('FiveThou', 'TwentyThou', 'FiftyThou', 'Domino'))
|
|
23
|
+
Antilock = self.new_rv('Antilock', ('True', 'False'))
|
|
24
|
+
DrivingSkill = self.new_rv('DrivingSkill', ('SubStandard', 'Normal', 'Expert'))
|
|
25
|
+
SeniorTrain = self.new_rv('SeniorTrain', ('True', 'False'))
|
|
26
|
+
ThisCarCost = self.new_rv('ThisCarCost', ('Thousand', 'TenThou', 'HundredThou', 'Million'))
|
|
27
|
+
Theft = self.new_rv('Theft', ('True', 'False'))
|
|
28
|
+
CarValue = self.new_rv('CarValue', ('FiveThou', 'TenThou', 'TwentyThou', 'FiftyThou', 'Million'))
|
|
29
|
+
HomeBase = self.new_rv('HomeBase', ('Secure', 'City', 'Suburb', 'Rural'))
|
|
30
|
+
AntiTheft = self.new_rv('AntiTheft', ('True', 'False'))
|
|
31
|
+
PropCost = self.new_rv('PropCost', ('Thousand', 'TenThou', 'HundredThou', 'Million'))
|
|
32
|
+
OtherCarCost = self.new_rv('OtherCarCost', ('Thousand', 'TenThou', 'HundredThou', 'Million'))
|
|
33
|
+
OtherCar = self.new_rv('OtherCar', ('True', 'False'))
|
|
34
|
+
MedCost = self.new_rv('MedCost', ('Thousand', 'TenThou', 'HundredThou', 'Million'))
|
|
35
|
+
Cushioning = self.new_rv('Cushioning', ('Poor', 'Fair', 'Good', 'Excellent'))
|
|
36
|
+
Airbag = self.new_rv('Airbag', ('True', 'False'))
|
|
37
|
+
ILiCost = self.new_rv('ILiCost', ('Thousand', 'TenThou', 'HundredThou', 'Million'))
|
|
38
|
+
DrivHist = self.new_rv('DrivHist', ('Zero', 'One', 'Many'))
|
|
39
|
+
|
|
40
|
+
pgm_factor0 = self.new_factor(GoodStudent, SocioEcon, Age)
|
|
41
|
+
pgm_function0 = pgm_factor0.set_cpt()
|
|
42
|
+
pgm_function0.set_cpd((0, 0), (0.1, 0.9))
|
|
43
|
+
pgm_function0.set_cpd((1, 0), (0.2, 0.8))
|
|
44
|
+
pgm_function0.set_cpd((2, 0), (0.5, 0.5))
|
|
45
|
+
pgm_function0.set_cpd((3, 0), (0.4, 0.6))
|
|
46
|
+
pgm_function0.set_cpd((0, 1), (0.0, 1.0))
|
|
47
|
+
pgm_function0.set_cpd((1, 1), (0.0, 1.0))
|
|
48
|
+
pgm_function0.set_cpd((2, 1), (0.0, 1.0))
|
|
49
|
+
pgm_function0.set_cpd((3, 1), (0.0, 1.0))
|
|
50
|
+
pgm_function0.set_cpd((0, 2), (0.0, 1.0))
|
|
51
|
+
pgm_function0.set_cpd((1, 2), (0.0, 1.0))
|
|
52
|
+
pgm_function0.set_cpd((2, 2), (0.0, 1.0))
|
|
53
|
+
pgm_function0.set_cpd((3, 2), (0.0, 1.0))
|
|
54
|
+
pgm_factor1 = self.new_factor(Age)
|
|
55
|
+
pgm_function1 = pgm_factor1.set_cpt()
|
|
56
|
+
pgm_function1.set_cpd((), (0.2, 0.6, 0.2))
|
|
57
|
+
pgm_factor2 = self.new_factor(SocioEcon, Age)
|
|
58
|
+
pgm_function2 = pgm_factor2.set_cpt()
|
|
59
|
+
pgm_function2.set_cpd((0,), (0.4, 0.4, 0.19, 0.01))
|
|
60
|
+
pgm_function2.set_cpd((1,), (0.4, 0.4, 0.19, 0.01))
|
|
61
|
+
pgm_function2.set_cpd((2,), (0.5, 0.2, 0.29, 0.01))
|
|
62
|
+
pgm_factor3 = self.new_factor(RiskAversion, Age, SocioEcon)
|
|
63
|
+
pgm_function3 = pgm_factor3.set_cpt()
|
|
64
|
+
pgm_function3.set_cpd((0, 0), (0.02, 0.58, 0.3, 0.1))
|
|
65
|
+
pgm_function3.set_cpd((1, 0), (0.015, 0.285, 0.5, 0.2))
|
|
66
|
+
pgm_function3.set_cpd((2, 0), (0.01, 0.09, 0.4, 0.5))
|
|
67
|
+
pgm_function3.set_cpd((0, 1), (0.02, 0.38, 0.5, 0.1))
|
|
68
|
+
pgm_function3.set_cpd((1, 1), (0.015, 0.185, 0.6, 0.2))
|
|
69
|
+
pgm_function3.set_cpd((2, 1), (0.01, 0.04, 0.35, 0.6))
|
|
70
|
+
pgm_function3.set_cpd((0, 2), (0.02, 0.48, 0.4, 0.1))
|
|
71
|
+
pgm_function3.set_cpd((1, 2), (0.015, 0.285, 0.5, 0.2))
|
|
72
|
+
pgm_function3.set_cpd((2, 2), (0.01, 0.09, 0.4, 0.5))
|
|
73
|
+
pgm_function3.set_cpd((0, 3), (0.02, 0.58, 0.3, 0.1))
|
|
74
|
+
pgm_function3.set_cpd((1, 3), (0.015, 0.285, 0.4, 0.3))
|
|
75
|
+
pgm_function3.set_cpd((2, 3), (0.01, 0.09, 0.4, 0.5))
|
|
76
|
+
pgm_factor4 = self.new_factor(VehicleYear, SocioEcon, RiskAversion)
|
|
77
|
+
pgm_function4 = pgm_factor4.set_cpt()
|
|
78
|
+
pgm_function4.set_cpd((0, 0), (0.15, 0.85))
|
|
79
|
+
pgm_function4.set_cpd((1, 0), (0.3, 0.7))
|
|
80
|
+
pgm_function4.set_cpd((2, 0), (0.8, 0.2))
|
|
81
|
+
pgm_function4.set_cpd((3, 0), (0.9, 0.1))
|
|
82
|
+
pgm_function4.set_cpd((0, 1), (0.15, 0.85))
|
|
83
|
+
pgm_function4.set_cpd((1, 1), (0.3, 0.7))
|
|
84
|
+
pgm_function4.set_cpd((2, 1), (0.8, 0.2))
|
|
85
|
+
pgm_function4.set_cpd((3, 1), (0.9, 0.1))
|
|
86
|
+
pgm_function4.set_cpd((0, 2), (0.15, 0.85))
|
|
87
|
+
pgm_function4.set_cpd((1, 2), (0.3, 0.7))
|
|
88
|
+
pgm_function4.set_cpd((2, 2), (0.8, 0.2))
|
|
89
|
+
pgm_function4.set_cpd((3, 2), (0.9, 0.1))
|
|
90
|
+
pgm_function4.set_cpd((0, 3), (0.15, 0.85))
|
|
91
|
+
pgm_function4.set_cpd((1, 3), (0.3, 0.7))
|
|
92
|
+
pgm_function4.set_cpd((2, 3), (0.8, 0.2))
|
|
93
|
+
pgm_function4.set_cpd((3, 3), (0.9, 0.1))
|
|
94
|
+
pgm_factor5 = self.new_factor(ThisCarDam, Accident, RuggedAuto)
|
|
95
|
+
pgm_function5 = pgm_factor5.set_cpt()
|
|
96
|
+
pgm_function5.set_cpd((0, 0), (1.0, 0.0, 0.0, 0.0))
|
|
97
|
+
pgm_function5.set_cpd((1, 0), (0.001, 0.9, 0.098, 0.001))
|
|
98
|
+
pgm_function5.set_cpd((2, 0), (1e-06, 0.000999, 0.7, 0.299))
|
|
99
|
+
pgm_function5.set_cpd((3, 0), (1e-06, 9e-06, 9e-05, 0.9999))
|
|
100
|
+
pgm_function5.set_cpd((0, 1), (1.0, 0.0, 0.0, 0.0))
|
|
101
|
+
pgm_function5.set_cpd((1, 1), (0.2, 0.75, 0.049999, 1e-06))
|
|
102
|
+
pgm_function5.set_cpd((2, 1), (0.001, 0.099, 0.8, 0.1))
|
|
103
|
+
pgm_function5.set_cpd((3, 1), (1e-06, 0.000999, 0.009, 0.99))
|
|
104
|
+
pgm_function5.set_cpd((0, 2), (1.0, 0.0, 0.0, 0.0))
|
|
105
|
+
pgm_function5.set_cpd((1, 2), (0.7, 0.29, 0.009999, 1e-06))
|
|
106
|
+
pgm_function5.set_cpd((2, 2), (0.05, 0.6, 0.3, 0.05))
|
|
107
|
+
pgm_function5.set_cpd((3, 2), (0.05, 0.2, 0.2, 0.55))
|
|
108
|
+
pgm_factor6 = self.new_factor(RuggedAuto, MakeModel, VehicleYear)
|
|
109
|
+
pgm_function6 = pgm_factor6.set_cpt()
|
|
110
|
+
pgm_function6.set_cpd((0, 0), (0.95, 0.04, 0.01))
|
|
111
|
+
pgm_function6.set_cpd((1, 0), (0.5, 0.5, 0.0))
|
|
112
|
+
pgm_function6.set_cpd((2, 0), (0.2, 0.6, 0.2))
|
|
113
|
+
pgm_function6.set_cpd((3, 0), (0.1, 0.6, 0.3))
|
|
114
|
+
pgm_function6.set_cpd((4, 0), (0.05, 0.55, 0.4))
|
|
115
|
+
pgm_function6.set_cpd((0, 1), (0.95, 0.04, 0.01))
|
|
116
|
+
pgm_function6.set_cpd((1, 1), (0.9, 0.1, 0.0))
|
|
117
|
+
pgm_function6.set_cpd((2, 1), (0.05, 0.55, 0.4))
|
|
118
|
+
pgm_function6.set_cpd((3, 1), (0.1, 0.6, 0.3))
|
|
119
|
+
pgm_function6.set_cpd((4, 1), (0.05, 0.55, 0.4))
|
|
120
|
+
pgm_factor7 = self.new_factor(Accident, Antilock, Mileage, DrivQuality)
|
|
121
|
+
pgm_function7 = pgm_factor7.set_cpt()
|
|
122
|
+
pgm_function7.set_cpd((0, 0, 0), (0.7, 0.2, 0.07, 0.03))
|
|
123
|
+
pgm_function7.set_cpd((1, 0, 0), (0.6, 0.2, 0.1, 0.1))
|
|
124
|
+
pgm_function7.set_cpd((0, 1, 0), (0.4, 0.3, 0.2, 0.1))
|
|
125
|
+
pgm_function7.set_cpd((1, 1, 0), (0.3, 0.2, 0.2, 0.3))
|
|
126
|
+
pgm_function7.set_cpd((0, 2, 0), (0.3, 0.3, 0.2, 0.2))
|
|
127
|
+
pgm_function7.set_cpd((1, 2, 0), (0.2, 0.2, 0.2, 0.4))
|
|
128
|
+
pgm_function7.set_cpd((0, 3, 0), (0.2, 0.2, 0.3, 0.3))
|
|
129
|
+
pgm_function7.set_cpd((1, 3, 0), (0.1, 0.1, 0.3, 0.5))
|
|
130
|
+
pgm_function7.set_cpd((0, 0, 1), (0.99, 0.007, 0.002, 0.001))
|
|
131
|
+
pgm_function7.set_cpd((1, 0, 1), (0.98, 0.01, 0.005, 0.005))
|
|
132
|
+
pgm_function7.set_cpd((0, 1, 1), (0.98, 0.01, 0.005, 0.005))
|
|
133
|
+
pgm_function7.set_cpd((1, 1, 1), (0.96, 0.02, 0.015, 0.005))
|
|
134
|
+
pgm_function7.set_cpd((0, 2, 1), (0.97, 0.02, 0.007, 0.003))
|
|
135
|
+
pgm_function7.set_cpd((1, 2, 1), (0.95, 0.03, 0.015, 0.005))
|
|
136
|
+
pgm_function7.set_cpd((0, 3, 1), (0.95, 0.03, 0.01, 0.01))
|
|
137
|
+
pgm_function7.set_cpd((1, 3, 1), (0.94, 0.03, 0.02, 0.01))
|
|
138
|
+
pgm_function7.set_cpd((0, 0, 2), (0.999, 0.0007, 0.0002, 0.0001))
|
|
139
|
+
pgm_function7.set_cpd((1, 0, 2), (0.995, 0.003, 0.001, 0.001))
|
|
140
|
+
pgm_function7.set_cpd((0, 1, 2), (0.995, 0.003, 0.001, 0.001))
|
|
141
|
+
pgm_function7.set_cpd((1, 1, 2), (0.99, 0.007, 0.002, 0.001))
|
|
142
|
+
pgm_function7.set_cpd((0, 2, 2), (0.99, 0.007, 0.002, 0.001))
|
|
143
|
+
pgm_function7.set_cpd((1, 2, 2), (0.98, 0.01, 0.005, 0.005))
|
|
144
|
+
pgm_function7.set_cpd((0, 3, 2), (0.985, 0.01, 0.003, 0.002))
|
|
145
|
+
pgm_function7.set_cpd((1, 3, 2), (0.98, 0.01, 0.007, 0.003))
|
|
146
|
+
pgm_factor8 = self.new_factor(MakeModel, SocioEcon, RiskAversion)
|
|
147
|
+
pgm_function8 = pgm_factor8.set_cpt()
|
|
148
|
+
pgm_function8.set_cpd((0, 0), (0.1, 0.7, 0.2, 0.0, 0.0))
|
|
149
|
+
pgm_function8.set_cpd((1, 0), (0.15, 0.2, 0.65, 0.0, 0.0))
|
|
150
|
+
pgm_function8.set_cpd((2, 0), (0.2, 0.05, 0.3, 0.45, 0.0))
|
|
151
|
+
pgm_function8.set_cpd((3, 0), (0.3, 0.01, 0.09, 0.4, 0.2))
|
|
152
|
+
pgm_function8.set_cpd((0, 1), (0.1, 0.7, 0.2, 0.0, 0.0))
|
|
153
|
+
pgm_function8.set_cpd((1, 1), (0.15, 0.2, 0.65, 0.0, 0.0))
|
|
154
|
+
pgm_function8.set_cpd((2, 1), (0.2, 0.05, 0.3, 0.45, 0.0))
|
|
155
|
+
pgm_function8.set_cpd((3, 1), (0.3, 0.01, 0.09, 0.4, 0.2))
|
|
156
|
+
pgm_function8.set_cpd((0, 2), (0.1, 0.7, 0.2, 0.0, 0.0))
|
|
157
|
+
pgm_function8.set_cpd((1, 2), (0.15, 0.2, 0.65, 0.0, 0.0))
|
|
158
|
+
pgm_function8.set_cpd((2, 2), (0.2, 0.05, 0.3, 0.45, 0.0))
|
|
159
|
+
pgm_function8.set_cpd((3, 2), (0.3, 0.01, 0.09, 0.4, 0.2))
|
|
160
|
+
pgm_function8.set_cpd((0, 3), (0.1, 0.7, 0.2, 0.0, 0.0))
|
|
161
|
+
pgm_function8.set_cpd((1, 3), (0.15, 0.2, 0.65, 0.0, 0.0))
|
|
162
|
+
pgm_function8.set_cpd((2, 3), (0.2, 0.05, 0.3, 0.45, 0.0))
|
|
163
|
+
pgm_function8.set_cpd((3, 3), (0.3, 0.01, 0.09, 0.4, 0.2))
|
|
164
|
+
pgm_factor9 = self.new_factor(DrivQuality, DrivingSkill, RiskAversion)
|
|
165
|
+
pgm_function9 = pgm_factor9.set_cpt()
|
|
166
|
+
pgm_function9.set_cpd((0, 0), (1.0, 0.0, 0.0))
|
|
167
|
+
pgm_function9.set_cpd((1, 0), (0.5, 0.2, 0.3))
|
|
168
|
+
pgm_function9.set_cpd((2, 0), (0.3, 0.2, 0.5))
|
|
169
|
+
pgm_function9.set_cpd((0, 1), (1.0, 0.0, 0.0))
|
|
170
|
+
pgm_function9.set_cpd((1, 1), (0.3, 0.4, 0.3))
|
|
171
|
+
pgm_function9.set_cpd((2, 1), (0.01, 0.01, 0.98))
|
|
172
|
+
pgm_function9.set_cpd((0, 2), (1.0, 0.0, 0.0))
|
|
173
|
+
pgm_function9.set_cpd((1, 2), (0.0, 1.0, 0.0))
|
|
174
|
+
pgm_function9.set_cpd((2, 2), (0.0, 0.0, 1.0))
|
|
175
|
+
pgm_function9.set_cpd((0, 3), (1.0, 0.0, 0.0))
|
|
176
|
+
pgm_function9.set_cpd((1, 3), (0.0, 0.8, 0.2))
|
|
177
|
+
pgm_function9.set_cpd((2, 3), (0.0, 0.0, 1.0))
|
|
178
|
+
pgm_factor10 = self.new_factor(Mileage)
|
|
179
|
+
pgm_function10 = pgm_factor10.set_cpt()
|
|
180
|
+
pgm_function10.set_cpd((), (0.1, 0.4, 0.4, 0.1))
|
|
181
|
+
pgm_factor11 = self.new_factor(Antilock, MakeModel, VehicleYear)
|
|
182
|
+
pgm_function11 = pgm_factor11.set_cpt()
|
|
183
|
+
pgm_function11.set_cpd((0, 0), (0.9, 0.1))
|
|
184
|
+
pgm_function11.set_cpd((1, 0), (0.001, 0.999))
|
|
185
|
+
pgm_function11.set_cpd((2, 0), (0.4, 0.6))
|
|
186
|
+
pgm_function11.set_cpd((3, 0), (0.99, 0.01))
|
|
187
|
+
pgm_function11.set_cpd((4, 0), (0.99, 0.01))
|
|
188
|
+
pgm_function11.set_cpd((0, 1), (0.1, 0.9))
|
|
189
|
+
pgm_function11.set_cpd((1, 1), (0.0, 1.0))
|
|
190
|
+
pgm_function11.set_cpd((2, 1), (0.0, 1.0))
|
|
191
|
+
pgm_function11.set_cpd((3, 1), (0.3, 0.7))
|
|
192
|
+
pgm_function11.set_cpd((4, 1), (0.15, 0.85))
|
|
193
|
+
pgm_factor12 = self.new_factor(DrivingSkill, Age, SeniorTrain)
|
|
194
|
+
pgm_function12 = pgm_factor12.set_cpt()
|
|
195
|
+
pgm_function12.set_cpd((0, 0), (0.5, 0.45, 0.05))
|
|
196
|
+
pgm_function12.set_cpd((1, 0), (0.3, 0.6, 0.1))
|
|
197
|
+
pgm_function12.set_cpd((2, 0), (0.1, 0.6, 0.3))
|
|
198
|
+
pgm_function12.set_cpd((0, 1), (0.5, 0.45, 0.05))
|
|
199
|
+
pgm_function12.set_cpd((1, 1), (0.3, 0.6, 0.1))
|
|
200
|
+
pgm_function12.set_cpd((2, 1), (0.4, 0.5, 0.1))
|
|
201
|
+
pgm_factor13 = self.new_factor(SeniorTrain, Age, RiskAversion)
|
|
202
|
+
pgm_function13 = pgm_factor13.set_cpt()
|
|
203
|
+
pgm_function13.set_cpd((0, 0), (0.0, 1.0))
|
|
204
|
+
pgm_function13.set_cpd((1, 0), (0.0, 1.0))
|
|
205
|
+
pgm_function13.set_cpd((2, 0), (1e-06, 0.999999))
|
|
206
|
+
pgm_function13.set_cpd((0, 1), (0.0, 1.0))
|
|
207
|
+
pgm_function13.set_cpd((1, 1), (0.0, 1.0))
|
|
208
|
+
pgm_function13.set_cpd((2, 1), (1e-06, 0.999999))
|
|
209
|
+
pgm_function13.set_cpd((0, 2), (0.0, 1.0))
|
|
210
|
+
pgm_function13.set_cpd((1, 2), (0.0, 1.0))
|
|
211
|
+
pgm_function13.set_cpd((2, 2), (0.3, 0.7))
|
|
212
|
+
pgm_function13.set_cpd((0, 3), (0.0, 1.0))
|
|
213
|
+
pgm_function13.set_cpd((1, 3), (0.0, 1.0))
|
|
214
|
+
pgm_function13.set_cpd((2, 3), (0.9, 0.1))
|
|
215
|
+
pgm_factor14 = self.new_factor(ThisCarCost, ThisCarDam, CarValue, Theft)
|
|
216
|
+
pgm_function14 = pgm_factor14.set_cpt()
|
|
217
|
+
pgm_function14.set_cpd((0, 0, 0), (0.2, 0.8, 0.0, 0.0))
|
|
218
|
+
pgm_function14.set_cpd((1, 0, 0), (0.15, 0.85, 0.0, 0.0))
|
|
219
|
+
pgm_function14.set_cpd((2, 0, 0), (0.05, 0.95, 0.0, 0.0))
|
|
220
|
+
pgm_function14.set_cpd((3, 0, 0), (0.03, 0.97, 0.0, 0.0))
|
|
221
|
+
pgm_function14.set_cpd((0, 1, 0), (0.05, 0.95, 0.0, 0.0))
|
|
222
|
+
pgm_function14.set_cpd((1, 1, 0), (0.03, 0.97, 0.0, 0.0))
|
|
223
|
+
pgm_function14.set_cpd((2, 1, 0), (0.01, 0.99, 0.0, 0.0))
|
|
224
|
+
pgm_function14.set_cpd((3, 1, 0), (1e-06, 0.999999, 0.0, 0.0))
|
|
225
|
+
pgm_function14.set_cpd((0, 2, 0), (0.04, 0.01, 0.95, 0.0))
|
|
226
|
+
pgm_function14.set_cpd((1, 2, 0), (0.03, 0.02, 0.95, 0.0))
|
|
227
|
+
pgm_function14.set_cpd((2, 2, 0), (0.001, 0.001, 0.998, 0.0))
|
|
228
|
+
pgm_function14.set_cpd((3, 2, 0), (1e-06, 1e-06, 0.999998, 0.0))
|
|
229
|
+
pgm_function14.set_cpd((0, 3, 0), (0.04, 0.01, 0.95, 0.0))
|
|
230
|
+
pgm_function14.set_cpd((1, 3, 0), (0.03, 0.02, 0.95, 0.0))
|
|
231
|
+
pgm_function14.set_cpd((2, 3, 0), (0.001, 0.001, 0.998, 0.0))
|
|
232
|
+
pgm_function14.set_cpd((3, 3, 0), (1e-06, 1e-06, 0.999998, 0.0))
|
|
233
|
+
pgm_function14.set_cpd((0, 4, 0), (0.04, 0.01, 0.2, 0.75))
|
|
234
|
+
pgm_function14.set_cpd((1, 4, 0), (0.02, 0.03, 0.25, 0.7))
|
|
235
|
+
pgm_function14.set_cpd((2, 4, 0), (0.001, 0.001, 0.018, 0.98))
|
|
236
|
+
pgm_function14.set_cpd((3, 4, 0), (1e-06, 1e-06, 0.009998, 0.99))
|
|
237
|
+
pgm_function14.set_cpd((0, 0, 1), (1.0, 0.0, 0.0, 0.0))
|
|
238
|
+
pgm_function14.set_cpd((1, 0, 1), (0.95, 0.05, 0.0, 0.0))
|
|
239
|
+
pgm_function14.set_cpd((2, 0, 1), (0.25, 0.75, 0.0, 0.0))
|
|
240
|
+
pgm_function14.set_cpd((3, 0, 1), (0.05, 0.95, 0.0, 0.0))
|
|
241
|
+
pgm_function14.set_cpd((0, 1, 1), (1.0, 0.0, 0.0, 0.0))
|
|
242
|
+
pgm_function14.set_cpd((1, 1, 1), (0.95, 0.05, 0.0, 0.0))
|
|
243
|
+
pgm_function14.set_cpd((2, 1, 1), (0.15, 0.85, 0.0, 0.0))
|
|
244
|
+
pgm_function14.set_cpd((3, 1, 1), (0.01, 0.99, 0.0, 0.0))
|
|
245
|
+
pgm_function14.set_cpd((0, 2, 1), (1.0, 0.0, 0.0, 0.0))
|
|
246
|
+
pgm_function14.set_cpd((1, 2, 1), (0.99, 0.01, 0.0, 0.0))
|
|
247
|
+
pgm_function14.set_cpd((2, 2, 1), (0.01, 0.01, 0.98, 0.0))
|
|
248
|
+
pgm_function14.set_cpd((3, 2, 1), (0.005, 0.005, 0.99, 0.0))
|
|
249
|
+
pgm_function14.set_cpd((0, 3, 1), (1.0, 0.0, 0.0, 0.0))
|
|
250
|
+
pgm_function14.set_cpd((1, 3, 1), (0.99, 0.01, 0.0, 0.0))
|
|
251
|
+
pgm_function14.set_cpd((2, 3, 1), (0.005, 0.005, 0.99, 0.0))
|
|
252
|
+
pgm_function14.set_cpd((3, 3, 1), (0.001, 0.001, 0.998, 0.0))
|
|
253
|
+
pgm_function14.set_cpd((0, 4, 1), (1.0, 0.0, 0.0, 0.0))
|
|
254
|
+
pgm_function14.set_cpd((1, 4, 1), (0.98, 0.01, 0.01, 0.0))
|
|
255
|
+
pgm_function14.set_cpd((2, 4, 1), (0.003, 0.003, 0.044, 0.95))
|
|
256
|
+
pgm_function14.set_cpd((3, 4, 1), (1e-06, 1e-06, 0.029998, 0.97))
|
|
257
|
+
pgm_factor15 = self.new_factor(Theft, AntiTheft, HomeBase, CarValue)
|
|
258
|
+
pgm_function15 = pgm_factor15.set_cpt()
|
|
259
|
+
pgm_function15.set_cpd((0, 0, 0), (1e-06, 0.999999))
|
|
260
|
+
pgm_function15.set_cpd((1, 0, 0), (1e-06, 0.999999))
|
|
261
|
+
pgm_function15.set_cpd((0, 1, 0), (0.0005, 0.9995))
|
|
262
|
+
pgm_function15.set_cpd((1, 1, 0), (0.001, 0.999))
|
|
263
|
+
pgm_function15.set_cpd((0, 2, 0), (1e-05, 0.99999))
|
|
264
|
+
pgm_function15.set_cpd((1, 2, 0), (1e-05, 0.99999))
|
|
265
|
+
pgm_function15.set_cpd((0, 3, 0), (1e-05, 0.99999))
|
|
266
|
+
pgm_function15.set_cpd((1, 3, 0), (1e-05, 0.99999))
|
|
267
|
+
pgm_function15.set_cpd((0, 0, 1), (2e-06, 0.999998))
|
|
268
|
+
pgm_function15.set_cpd((1, 0, 1), (2e-06, 0.999998))
|
|
269
|
+
pgm_function15.set_cpd((0, 1, 1), (0.002, 0.998))
|
|
270
|
+
pgm_function15.set_cpd((1, 1, 1), (0.005, 0.995))
|
|
271
|
+
pgm_function15.set_cpd((0, 2, 1), (0.0001, 0.9999))
|
|
272
|
+
pgm_function15.set_cpd((1, 2, 1), (0.0002, 0.9998))
|
|
273
|
+
pgm_function15.set_cpd((0, 3, 1), (2e-05, 0.99998))
|
|
274
|
+
pgm_function15.set_cpd((1, 3, 1), (0.0001, 0.9999))
|
|
275
|
+
pgm_function15.set_cpd((0, 0, 2), (3e-06, 0.999997))
|
|
276
|
+
pgm_function15.set_cpd((1, 0, 2), (3e-06, 0.999997))
|
|
277
|
+
pgm_function15.set_cpd((0, 1, 2), (0.005, 0.995))
|
|
278
|
+
pgm_function15.set_cpd((1, 1, 2), (0.01, 0.99))
|
|
279
|
+
pgm_function15.set_cpd((0, 2, 2), (0.0003, 0.9997))
|
|
280
|
+
pgm_function15.set_cpd((1, 2, 2), (0.0005, 0.9995))
|
|
281
|
+
pgm_function15.set_cpd((0, 3, 2), (5e-05, 0.99995))
|
|
282
|
+
pgm_function15.set_cpd((1, 3, 2), (0.0002, 0.9998))
|
|
283
|
+
pgm_function15.set_cpd((0, 0, 3), (2e-06, 0.999998))
|
|
284
|
+
pgm_function15.set_cpd((1, 0, 3), (2e-06, 0.999998))
|
|
285
|
+
pgm_function15.set_cpd((0, 1, 3), (0.005, 0.995))
|
|
286
|
+
pgm_function15.set_cpd((1, 1, 3), (0.01, 0.99))
|
|
287
|
+
pgm_function15.set_cpd((0, 2, 3), (0.0003, 0.9997))
|
|
288
|
+
pgm_function15.set_cpd((1, 2, 3), (0.0005, 0.9995))
|
|
289
|
+
pgm_function15.set_cpd((0, 3, 3), (5e-05, 0.99995))
|
|
290
|
+
pgm_function15.set_cpd((1, 3, 3), (0.0002, 0.9998))
|
|
291
|
+
pgm_function15.set_cpd((0, 0, 4), (1e-06, 0.999999))
|
|
292
|
+
pgm_function15.set_cpd((1, 0, 4), (1e-06, 0.999999))
|
|
293
|
+
pgm_function15.set_cpd((0, 1, 4), (1e-06, 0.999999))
|
|
294
|
+
pgm_function15.set_cpd((1, 1, 4), (1e-06, 0.999999))
|
|
295
|
+
pgm_function15.set_cpd((0, 2, 4), (1e-06, 0.999999))
|
|
296
|
+
pgm_function15.set_cpd((1, 2, 4), (1e-06, 0.999999))
|
|
297
|
+
pgm_function15.set_cpd((0, 3, 4), (1e-06, 0.999999))
|
|
298
|
+
pgm_function15.set_cpd((1, 3, 4), (1e-06, 0.999999))
|
|
299
|
+
pgm_factor16 = self.new_factor(CarValue, MakeModel, VehicleYear, Mileage)
|
|
300
|
+
pgm_function16 = pgm_factor16.set_cpt()
|
|
301
|
+
pgm_function16.set_cpd((0, 0, 0), (0.0, 0.1, 0.8, 0.09, 0.01))
|
|
302
|
+
pgm_function16.set_cpd((1, 0, 0), (0.1, 0.8, 0.1, 0.0, 0.0))
|
|
303
|
+
pgm_function16.set_cpd((2, 0, 0), (0.0, 0.1, 0.9, 0.0, 0.0))
|
|
304
|
+
pgm_function16.set_cpd((3, 0, 0), (0.0, 0.0, 0.0, 1.0, 0.0))
|
|
305
|
+
pgm_function16.set_cpd((4, 0, 0), (0.0, 0.0, 0.0, 0.0, 1.0))
|
|
306
|
+
pgm_function16.set_cpd((0, 1, 0), (0.03, 0.3, 0.6, 0.06, 0.01))
|
|
307
|
+
pgm_function16.set_cpd((1, 1, 0), (0.25, 0.7, 0.05, 0.0, 0.0))
|
|
308
|
+
pgm_function16.set_cpd((2, 1, 0), (0.2, 0.3, 0.5, 0.0, 0.0))
|
|
309
|
+
pgm_function16.set_cpd((3, 1, 0), (0.01, 0.09, 0.2, 0.7, 0.0))
|
|
310
|
+
pgm_function16.set_cpd((4, 1, 0), (1e-06, 1e-06, 1e-06, 1e-06, 0.999996))
|
|
311
|
+
pgm_function16.set_cpd((0, 0, 1), (0.0, 0.1, 0.8, 0.09, 0.01))
|
|
312
|
+
pgm_function16.set_cpd((1, 0, 1), (0.1, 0.8, 0.1, 0.0, 0.0))
|
|
313
|
+
pgm_function16.set_cpd((2, 0, 1), (0.0, 0.1, 0.9, 0.0, 0.0))
|
|
314
|
+
pgm_function16.set_cpd((3, 0, 1), (0.0, 0.0, 0.0, 1.0, 0.0))
|
|
315
|
+
pgm_function16.set_cpd((4, 0, 1), (0.0, 0.0, 0.0, 0.0, 1.0))
|
|
316
|
+
pgm_function16.set_cpd((0, 1, 1), (0.16, 0.5, 0.3, 0.03, 0.01))
|
|
317
|
+
pgm_function16.set_cpd((1, 1, 1), (0.7, 0.2999, 0.0001, 0.0, 0.0))
|
|
318
|
+
pgm_function16.set_cpd((2, 1, 1), (0.5, 0.3, 0.2, 0.0, 0.0))
|
|
319
|
+
pgm_function16.set_cpd((3, 1, 1), (0.05, 0.15, 0.3, 0.5, 0.0))
|
|
320
|
+
pgm_function16.set_cpd((4, 1, 1), (1e-06, 1e-06, 1e-06, 1e-06, 0.999996))
|
|
321
|
+
pgm_function16.set_cpd((0, 0, 2), (0.0, 0.1, 0.8, 0.09, 0.01))
|
|
322
|
+
pgm_function16.set_cpd((1, 0, 2), (0.1, 0.8, 0.1, 0.0, 0.0))
|
|
323
|
+
pgm_function16.set_cpd((2, 0, 2), (0.0, 0.1, 0.9, 0.0, 0.0))
|
|
324
|
+
pgm_function16.set_cpd((3, 0, 2), (0.0, 0.0, 0.0, 1.0, 0.0))
|
|
325
|
+
pgm_function16.set_cpd((4, 0, 2), (0.0, 0.0, 0.0, 0.0, 1.0))
|
|
326
|
+
pgm_function16.set_cpd((0, 1, 2), (0.4, 0.47, 0.1, 0.02, 0.01))
|
|
327
|
+
pgm_function16.set_cpd((1, 1, 2), (0.99, 0.009999, 1e-06, 0.0, 0.0))
|
|
328
|
+
pgm_function16.set_cpd((2, 1, 2), (0.7, 0.2, 0.1, 0.0, 0.0))
|
|
329
|
+
pgm_function16.set_cpd((3, 1, 2), (0.1, 0.3, 0.3, 0.3, 0.0))
|
|
330
|
+
pgm_function16.set_cpd((4, 1, 2), (1e-06, 1e-06, 1e-06, 1e-06, 0.999996))
|
|
331
|
+
pgm_function16.set_cpd((0, 0, 3), (0.0, 0.1, 0.8, 0.09, 0.01))
|
|
332
|
+
pgm_function16.set_cpd((1, 0, 3), (0.1, 0.8, 0.1, 0.0, 0.0))
|
|
333
|
+
pgm_function16.set_cpd((2, 0, 3), (0.0, 0.1, 0.9, 0.0, 0.0))
|
|
334
|
+
pgm_function16.set_cpd((3, 0, 3), (0.0, 0.0, 0.0, 1.0, 0.0))
|
|
335
|
+
pgm_function16.set_cpd((4, 0, 3), (0.0, 0.0, 0.0, 0.0, 1.0))
|
|
336
|
+
pgm_function16.set_cpd((0, 1, 3), (0.9, 0.06, 0.02, 0.01, 0.01))
|
|
337
|
+
pgm_function16.set_cpd((1, 1, 3), (0.999998, 1e-06, 1e-06, 0.0, 0.0))
|
|
338
|
+
pgm_function16.set_cpd((2, 1, 3), (0.99, 0.009999, 1e-06, 0.0, 0.0))
|
|
339
|
+
pgm_function16.set_cpd((3, 1, 3), (0.2, 0.2, 0.3, 0.3, 0.0))
|
|
340
|
+
pgm_function16.set_cpd((4, 1, 3), (1e-06, 1e-06, 1e-06, 1e-06, 0.999996))
|
|
341
|
+
pgm_factor17 = self.new_factor(HomeBase, RiskAversion, SocioEcon)
|
|
342
|
+
pgm_function17 = pgm_factor17.set_cpt()
|
|
343
|
+
pgm_function17.set_cpd((0, 0), (1e-06, 0.8, 0.049999, 0.15))
|
|
344
|
+
pgm_function17.set_cpd((1, 0), (1e-06, 0.8, 0.05, 0.149999))
|
|
345
|
+
pgm_function17.set_cpd((2, 0), (1e-06, 0.8, 0.05, 0.149999))
|
|
346
|
+
pgm_function17.set_cpd((3, 0), (1e-06, 0.8, 0.05, 0.149999))
|
|
347
|
+
pgm_function17.set_cpd((0, 1), (0.15, 0.8, 0.04, 0.01))
|
|
348
|
+
pgm_function17.set_cpd((1, 1), (0.01, 0.25, 0.6, 0.14))
|
|
349
|
+
pgm_function17.set_cpd((2, 1), (0.299999, 1e-06, 0.6, 0.1))
|
|
350
|
+
pgm_function17.set_cpd((3, 1), (0.95, 1e-06, 0.024445, 0.025554))
|
|
351
|
+
pgm_function17.set_cpd((0, 2), (0.35, 0.6, 0.04, 0.01))
|
|
352
|
+
pgm_function17.set_cpd((1, 2), (0.2, 0.4, 0.3, 0.1))
|
|
353
|
+
pgm_function17.set_cpd((2, 2), (0.5, 1e-06, 0.4, 0.099999))
|
|
354
|
+
pgm_function17.set_cpd((3, 2), (0.999997, 1e-06, 1e-06, 1e-06))
|
|
355
|
+
pgm_function17.set_cpd((0, 3), (0.489999, 0.5, 1e-06, 0.01))
|
|
356
|
+
pgm_function17.set_cpd((1, 3), (0.95, 1e-06, 1e-06, 0.049998))
|
|
357
|
+
pgm_function17.set_cpd((2, 3), (0.85, 1e-06, 0.001, 0.148999))
|
|
358
|
+
pgm_function17.set_cpd((3, 3), (0.999997, 1e-06, 1e-06, 1e-06))
|
|
359
|
+
pgm_factor18 = self.new_factor(AntiTheft, RiskAversion, SocioEcon)
|
|
360
|
+
pgm_function18 = pgm_factor18.set_cpt()
|
|
361
|
+
pgm_function18.set_cpd((0, 0), (1e-06, 0.999999))
|
|
362
|
+
pgm_function18.set_cpd((1, 0), (1e-06, 0.999999))
|
|
363
|
+
pgm_function18.set_cpd((2, 0), (0.1, 0.9))
|
|
364
|
+
pgm_function18.set_cpd((3, 0), (0.95, 0.05))
|
|
365
|
+
pgm_function18.set_cpd((0, 1), (1e-06, 0.999999))
|
|
366
|
+
pgm_function18.set_cpd((1, 1), (1e-06, 0.999999))
|
|
367
|
+
pgm_function18.set_cpd((2, 1), (0.3, 0.7))
|
|
368
|
+
pgm_function18.set_cpd((3, 1), (0.999999, 1e-06))
|
|
369
|
+
pgm_function18.set_cpd((0, 2), (0.05, 0.95))
|
|
370
|
+
pgm_function18.set_cpd((1, 2), (0.2, 0.8))
|
|
371
|
+
pgm_function18.set_cpd((2, 2), (0.9, 0.1))
|
|
372
|
+
pgm_function18.set_cpd((3, 2), (0.999999, 1e-06))
|
|
373
|
+
pgm_function18.set_cpd((0, 3), (0.5, 0.5))
|
|
374
|
+
pgm_function18.set_cpd((1, 3), (0.5, 0.5))
|
|
375
|
+
pgm_function18.set_cpd((2, 3), (0.8, 0.2))
|
|
376
|
+
pgm_function18.set_cpd((3, 3), (0.999999, 1e-06))
|
|
377
|
+
pgm_factor19 = self.new_factor(PropCost, OtherCarCost, ThisCarCost)
|
|
378
|
+
pgm_function19 = pgm_factor19.set_cpt()
|
|
379
|
+
pgm_function19.set_cpd((0, 0), (0.7, 0.3, 0.0, 0.0))
|
|
380
|
+
pgm_function19.set_cpd((1, 0), (0.0, 0.95, 0.05, 0.0))
|
|
381
|
+
pgm_function19.set_cpd((2, 0), (0.0, 0.0, 0.98, 0.02))
|
|
382
|
+
pgm_function19.set_cpd((3, 0), (0.0, 0.0, 0.0, 1.0))
|
|
383
|
+
pgm_function19.set_cpd((0, 1), (0.0, 0.95, 0.05, 0.0))
|
|
384
|
+
pgm_function19.set_cpd((1, 1), (0.0, 0.6, 0.4, 0.0))
|
|
385
|
+
pgm_function19.set_cpd((2, 1), (0.0, 0.0, 0.8, 0.2))
|
|
386
|
+
pgm_function19.set_cpd((3, 1), (0.0, 0.0, 0.0, 1.0))
|
|
387
|
+
pgm_function19.set_cpd((0, 2), (0.0, 0.0, 0.98, 0.02))
|
|
388
|
+
pgm_function19.set_cpd((1, 2), (0.0, 0.0, 0.95, 0.05))
|
|
389
|
+
pgm_function19.set_cpd((2, 2), (0.0, 0.0, 0.6, 0.4))
|
|
390
|
+
pgm_function19.set_cpd((3, 2), (0.0, 0.0, 0.0, 1.0))
|
|
391
|
+
pgm_function19.set_cpd((0, 3), (0.0, 0.0, 0.0, 1.0))
|
|
392
|
+
pgm_function19.set_cpd((1, 3), (0.0, 0.0, 0.0, 1.0))
|
|
393
|
+
pgm_function19.set_cpd((2, 3), (0.0, 0.0, 0.0, 1.0))
|
|
394
|
+
pgm_function19.set_cpd((3, 3), (0.0, 0.0, 0.0, 1.0))
|
|
395
|
+
pgm_factor20 = self.new_factor(OtherCarCost, Accident, RuggedAuto)
|
|
396
|
+
pgm_function20 = pgm_factor20.set_cpt()
|
|
397
|
+
pgm_function20.set_cpd((0, 0), (1.0, 0.0, 0.0, 0.0))
|
|
398
|
+
pgm_function20.set_cpd((1, 0), (0.99, 0.005, 0.00499, 1e-05))
|
|
399
|
+
pgm_function20.set_cpd((2, 0), (0.6, 0.2, 0.19998, 2e-05))
|
|
400
|
+
pgm_function20.set_cpd((3, 0), (0.2, 0.4, 0.39996, 4e-05))
|
|
401
|
+
pgm_function20.set_cpd((0, 1), (1.0, 0.0, 0.0, 0.0))
|
|
402
|
+
pgm_function20.set_cpd((1, 1), (0.9799657, 0.00999965, 0.009984651, 4.999825e-05))
|
|
403
|
+
pgm_function20.set_cpd((2, 1), (0.5, 0.2, 0.29997, 3e-05))
|
|
404
|
+
pgm_function20.set_cpd((3, 1), (0.1, 0.5, 0.39994, 6e-05))
|
|
405
|
+
pgm_function20.set_cpd((0, 2), (1.0, 0.0, 0.0, 0.0))
|
|
406
|
+
pgm_function20.set_cpd((1, 2), (0.95, 0.03, 0.01998, 2e-05))
|
|
407
|
+
pgm_function20.set_cpd((2, 2), (0.4, 0.3, 0.29996, 4e-05))
|
|
408
|
+
pgm_function20.set_cpd((3, 2), (0.005, 0.55, 0.4449, 0.0001))
|
|
409
|
+
pgm_factor21 = self.new_factor(OtherCar, SocioEcon)
|
|
410
|
+
pgm_function21 = pgm_factor21.set_cpt()
|
|
411
|
+
pgm_function21.set_cpd((0,), (0.5, 0.5))
|
|
412
|
+
pgm_function21.set_cpd((1,), (0.8, 0.2))
|
|
413
|
+
pgm_function21.set_cpd((2,), (0.9, 0.1))
|
|
414
|
+
pgm_function21.set_cpd((3,), (0.95, 0.05))
|
|
415
|
+
pgm_factor22 = self.new_factor(MedCost, Accident, Age, Cushioning)
|
|
416
|
+
pgm_function22 = pgm_factor22.set_cpt()
|
|
417
|
+
pgm_function22.set_cpd((0, 0, 0), (1.0, 0.0, 0.0, 0.0))
|
|
418
|
+
pgm_function22.set_cpd((1, 0, 0), (0.96, 0.03, 0.009, 0.001))
|
|
419
|
+
pgm_function22.set_cpd((2, 0, 0), (0.5, 0.2, 0.2, 0.1))
|
|
420
|
+
pgm_function22.set_cpd((3, 0, 0), (0.3, 0.3, 0.2, 0.2))
|
|
421
|
+
pgm_function22.set_cpd((0, 1, 0), (1.0, 0.0, 0.0, 0.0))
|
|
422
|
+
pgm_function22.set_cpd((1, 1, 0), (0.96, 0.03, 0.009, 0.001))
|
|
423
|
+
pgm_function22.set_cpd((2, 1, 0), (0.5, 0.2, 0.2, 0.1))
|
|
424
|
+
pgm_function22.set_cpd((3, 1, 0), (0.3, 0.3, 0.2, 0.2))
|
|
425
|
+
pgm_function22.set_cpd((0, 2, 0), (1.0, 0.0, 0.0, 0.0))
|
|
426
|
+
pgm_function22.set_cpd((1, 2, 0), (0.9, 0.07, 0.02, 0.01))
|
|
427
|
+
pgm_function22.set_cpd((2, 2, 0), (0.3, 0.3, 0.2, 0.2))
|
|
428
|
+
pgm_function22.set_cpd((3, 2, 0), (0.2, 0.2, 0.3, 0.3))
|
|
429
|
+
pgm_function22.set_cpd((0, 0, 1), (1.0, 0.0, 0.0, 0.0))
|
|
430
|
+
pgm_function22.set_cpd((1, 0, 1), (0.98, 0.019, 0.0009, 0.0001))
|
|
431
|
+
pgm_function22.set_cpd((2, 0, 1), (0.8, 0.15, 0.03, 0.02))
|
|
432
|
+
pgm_function22.set_cpd((3, 0, 1), (0.5, 0.2, 0.2, 0.1))
|
|
433
|
+
pgm_function22.set_cpd((0, 1, 1), (1.0, 0.0, 0.0, 0.0))
|
|
434
|
+
pgm_function22.set_cpd((1, 1, 1), (0.98, 0.019, 0.0009, 0.0001))
|
|
435
|
+
pgm_function22.set_cpd((2, 1, 1), (0.8, 0.15, 0.03, 0.02))
|
|
436
|
+
pgm_function22.set_cpd((3, 1, 1), (0.5, 0.2, 0.2, 0.1))
|
|
437
|
+
pgm_function22.set_cpd((0, 2, 1), (1.0, 0.0, 0.0, 0.0))
|
|
438
|
+
pgm_function22.set_cpd((1, 2, 1), (0.95, 0.04, 0.007, 0.003))
|
|
439
|
+
pgm_function22.set_cpd((2, 2, 1), (0.5, 0.2, 0.2, 0.1))
|
|
440
|
+
pgm_function22.set_cpd((3, 2, 1), (0.3, 0.3, 0.2, 0.2))
|
|
441
|
+
pgm_function22.set_cpd((0, 0, 2), (1.0, 0.0, 0.0, 0.0))
|
|
442
|
+
pgm_function22.set_cpd((1, 0, 2), (0.99, 0.0099, 9e-05, 1e-05))
|
|
443
|
+
pgm_function22.set_cpd((2, 0, 2), (0.95, 0.02, 0.02, 0.01))
|
|
444
|
+
pgm_function22.set_cpd((3, 0, 2), (0.9, 0.07, 0.02, 0.01))
|
|
445
|
+
pgm_function22.set_cpd((0, 1, 2), (1.0, 0.0, 0.0, 0.0))
|
|
446
|
+
pgm_function22.set_cpd((1, 1, 2), (0.99, 0.0099, 9e-05, 1e-05))
|
|
447
|
+
pgm_function22.set_cpd((2, 1, 2), (0.95, 0.02, 0.02, 0.01))
|
|
448
|
+
pgm_function22.set_cpd((3, 1, 2), (0.9, 0.07, 0.02, 0.01))
|
|
449
|
+
pgm_function22.set_cpd((0, 2, 2), (1.0, 0.0, 0.0, 0.0))
|
|
450
|
+
pgm_function22.set_cpd((1, 2, 2), (0.97, 0.025, 0.003, 0.002))
|
|
451
|
+
pgm_function22.set_cpd((2, 2, 2), (0.9, 0.07, 0.02, 0.01))
|
|
452
|
+
pgm_function22.set_cpd((3, 2, 2), (0.6, 0.3, 0.07, 0.03))
|
|
453
|
+
pgm_function22.set_cpd((0, 0, 3), (1.0, 0.0, 0.0, 0.0))
|
|
454
|
+
pgm_function22.set_cpd((1, 0, 3), (0.999, 0.00099, 9e-06, 1e-06))
|
|
455
|
+
pgm_function22.set_cpd((2, 0, 3), (0.99, 0.007, 0.002, 0.001))
|
|
456
|
+
pgm_function22.set_cpd((3, 0, 3), (0.95, 0.03, 0.01, 0.01))
|
|
457
|
+
pgm_function22.set_cpd((0, 1, 3), (1.0, 0.0, 0.0, 0.0))
|
|
458
|
+
pgm_function22.set_cpd((1, 1, 3), (0.999, 0.00099, 9e-06, 1e-06))
|
|
459
|
+
pgm_function22.set_cpd((2, 1, 3), (0.99, 0.007, 0.002, 0.001))
|
|
460
|
+
pgm_function22.set_cpd((3, 1, 3), (0.95, 0.03, 0.01, 0.01))
|
|
461
|
+
pgm_function22.set_cpd((0, 2, 3), (1.0, 0.0, 0.0, 0.0))
|
|
462
|
+
pgm_function22.set_cpd((1, 2, 3), (0.99, 0.007, 0.002, 0.001))
|
|
463
|
+
pgm_function22.set_cpd((2, 2, 3), (0.95, 0.03, 0.01, 0.01))
|
|
464
|
+
pgm_function22.set_cpd((3, 2, 3), (0.9, 0.05, 0.03, 0.02))
|
|
465
|
+
pgm_factor23 = self.new_factor(Cushioning, RuggedAuto, Airbag)
|
|
466
|
+
pgm_function23 = pgm_factor23.set_cpt()
|
|
467
|
+
pgm_function23.set_cpd((0, 0), (0.5, 0.3, 0.2, 0.0))
|
|
468
|
+
pgm_function23.set_cpd((1, 0), (0.0, 0.1, 0.6, 0.3))
|
|
469
|
+
pgm_function23.set_cpd((2, 0), (0.0, 0.0, 0.0, 1.0))
|
|
470
|
+
pgm_function23.set_cpd((0, 1), (0.7, 0.3, 0.0, 0.0))
|
|
471
|
+
pgm_function23.set_cpd((1, 1), (0.1, 0.6, 0.3, 0.0))
|
|
472
|
+
pgm_function23.set_cpd((2, 1), (0.0, 0.0, 0.7, 0.3))
|
|
473
|
+
pgm_factor24 = self.new_factor(Airbag, MakeModel, VehicleYear)
|
|
474
|
+
pgm_function24 = pgm_factor24.set_cpt()
|
|
475
|
+
pgm_function24.set_cpd((0, 0), (1.0, 0.0))
|
|
476
|
+
pgm_function24.set_cpd((1, 0), (1.0, 0.0))
|
|
477
|
+
pgm_function24.set_cpd((2, 0), (1.0, 0.0))
|
|
478
|
+
pgm_function24.set_cpd((3, 0), (1.0, 0.0))
|
|
479
|
+
pgm_function24.set_cpd((4, 0), (1.0, 0.0))
|
|
480
|
+
pgm_function24.set_cpd((0, 1), (0.1, 0.9))
|
|
481
|
+
pgm_function24.set_cpd((1, 1), (0.05, 0.95))
|
|
482
|
+
pgm_function24.set_cpd((2, 1), (0.2, 0.8))
|
|
483
|
+
pgm_function24.set_cpd((3, 1), (0.6, 0.4))
|
|
484
|
+
pgm_function24.set_cpd((4, 1), (0.1, 0.9))
|
|
485
|
+
pgm_factor25 = self.new_factor(ILiCost, Accident)
|
|
486
|
+
pgm_function25 = pgm_factor25.set_cpt()
|
|
487
|
+
pgm_function25.set_cpd((0,), (1.0, 0.0, 0.0, 0.0))
|
|
488
|
+
pgm_function25.set_cpd((1,), (0.999, 0.000998, 1e-06, 1e-06))
|
|
489
|
+
pgm_function25.set_cpd((2,), (0.9, 0.05, 0.03, 0.02))
|
|
490
|
+
pgm_function25.set_cpd((3,), (0.8, 0.1, 0.06, 0.04))
|
|
491
|
+
pgm_factor26 = self.new_factor(DrivHist, DrivingSkill, RiskAversion)
|
|
492
|
+
pgm_function26 = pgm_factor26.set_cpt()
|
|
493
|
+
pgm_function26.set_cpd((0, 0), (0.001, 0.004, 0.995))
|
|
494
|
+
pgm_function26.set_cpd((1, 0), (0.1, 0.3, 0.6))
|
|
495
|
+
pgm_function26.set_cpd((2, 0), (0.3, 0.3, 0.4))
|
|
496
|
+
pgm_function26.set_cpd((0, 1), (0.002, 0.008, 0.99))
|
|
497
|
+
pgm_function26.set_cpd((1, 1), (0.5, 0.3, 0.2))
|
|
498
|
+
pgm_function26.set_cpd((2, 1), (0.6, 0.3, 0.1))
|
|
499
|
+
pgm_function26.set_cpd((0, 2), (0.03, 0.15, 0.82))
|
|
500
|
+
pgm_function26.set_cpd((1, 2), (0.9, 0.07, 0.03))
|
|
501
|
+
pgm_function26.set_cpd((2, 2), (0.99, 0.009999, 1e-06))
|
|
502
|
+
pgm_function26.set_cpd((0, 3), (0.3, 0.3, 0.4))
|
|
503
|
+
pgm_function26.set_cpd((1, 3), (0.95, 0.04, 0.01))
|
|
504
|
+
pgm_function26.set_cpd((2, 3), (0.999998, 1e-06, 1e-06))
|
ck/example/loop.py
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import math
|
|
2
|
+
import random as _random
|
|
3
|
+
|
|
4
|
+
from ck.pgm import PGM
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class Loop(PGM):
|
|
8
|
+
"""
|
|
9
|
+
This PGM is the 'Loop' factor graph.
|
|
10
|
+
|
|
11
|
+
The Loop factor graph consists of a chain of random variables where
|
|
12
|
+
adjacent random variables in the chain are connected by a binary factor.
|
|
13
|
+
Random variables are named x0, x1, x2, ... .
|
|
14
|
+
If include_unaries then, also includes one unary factor per random variable.
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
def __init__(
|
|
18
|
+
self,
|
|
19
|
+
vars_per_loop: int = 20,
|
|
20
|
+
states_per_var: int = 20,
|
|
21
|
+
include_unaries: int = True,
|
|
22
|
+
random_seed: int = 123456,
|
|
23
|
+
):
|
|
24
|
+
params = (vars_per_loop, states_per_var, include_unaries)
|
|
25
|
+
super().__init__(f'{self.__class__.__name__}({",".join(str(param) for param in params)})')
|
|
26
|
+
|
|
27
|
+
scale = 1 + math.log2(vars_per_loop)
|
|
28
|
+
random_stream = _random.Random(random_seed).random
|
|
29
|
+
binary_iter = map(lambda x: x / scale, iter(random_stream, None))
|
|
30
|
+
unary_iter = iter(random_stream, None)
|
|
31
|
+
|
|
32
|
+
rvs = [self.new_rv(f'x{i}', states_per_var) for i in range(vars_per_loop)]
|
|
33
|
+
|
|
34
|
+
for i in range(1, len(rvs)):
|
|
35
|
+
self.new_factor(rvs[i], rvs[i - 1]).set_dense().set_iter(binary_iter)
|
|
36
|
+
self.new_factor(rvs[-1], rvs[0]).set_dense().set_iter(binary_iter)
|
|
37
|
+
|
|
38
|
+
if include_unaries:
|
|
39
|
+
for rv in rvs:
|
|
40
|
+
self.new_factor(rv).set_dense().set_iter(unary_iter)
|