compiled-knowledge 4.0.0a13__tar.gz → 4.0.0a14__tar.gz
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.
- {compiled_knowledge-4.0.0a13/src/compiled_knowledge.egg-info → compiled_knowledge-4.0.0a14}/PKG-INFO +2 -2
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/README.md +1 -1
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/pyproject.toml +1 -1
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck/circuit_compiler/named_circuit_compilers.py +8 -8
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck/example/pathfinder.py +120 -47
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck/in_out/parse_ace_lmap.py +1 -1
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck/in_out/parse_ace_nnf.py +13 -3
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck/pgm_compiler/ace/ace.py +3 -6
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck/pgm_compiler/factor_elimination.py +3 -3
- compiled_knowledge-4.0.0a14/src/ck/pgm_compiler/named_pgm_compilers.py +63 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck/pgm_compiler/recursive_conditioning.py +1 -1
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck/pgm_compiler/support/factor_tables.py +34 -26
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck/pgm_compiler/variable_elimination.py +1 -1
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck_demos/pgm_compiler/compare_pgm_compilers.py +17 -6
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck_demos/utils/compare.py +36 -18
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14/src/compiled_knowledge.egg-info}/PKG-INFO +2 -2
- compiled_knowledge-4.0.0a13/src/ck/pgm_compiler/named_pgm_compilers.py +0 -63
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/LICENSE.txt +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/MANIFEST.in +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/setup.cfg +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/setup.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck/__init__.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck/circuit/__init__.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck/circuit/circuit.c +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck/circuit/circuit.pyx +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck/circuit/circuit_node.pyx +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck/circuit/circuit_py.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck/circuit/tmp_const.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck/circuit_compiler/__init__.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck/circuit_compiler/circuit_compiler.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck/circuit_compiler/cython_vm_compiler/__init__.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck/circuit_compiler/cython_vm_compiler/_compiler.c +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck/circuit_compiler/cython_vm_compiler/_compiler.pyx +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck/circuit_compiler/cython_vm_compiler/cython_vm_compiler.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck/circuit_compiler/interpret_compiler.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck/circuit_compiler/llvm_compiler.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck/circuit_compiler/llvm_vm_compiler.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck/circuit_compiler/support/__init__.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck/circuit_compiler/support/circuit_analyser.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck/circuit_compiler/support/input_vars.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck/circuit_compiler/support/llvm_ir_function.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck/example/__init__.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck/example/alarm.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck/example/asia.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck/example/binary_clique.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck/example/bow_tie.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck/example/cancer.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck/example/chain.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck/example/child.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck/example/clique.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck/example/cnf_pgm.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck/example/diamond_square.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck/example/earthquake.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck/example/empty.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck/example/hailfinder.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck/example/hepar2.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck/example/insurance.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck/example/loop.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck/example/mildew.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck/example/munin.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck/example/rain.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck/example/rectangle.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck/example/run.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck/example/sachs.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck/example/sprinkler.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck/example/star.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck/example/stress.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck/example/student.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck/example/survey.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck/example/triangle_square.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck/example/truss.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck/in_out/__init__.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck/in_out/parse_net.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck/in_out/parser_utils.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck/in_out/pgm_pickle.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck/in_out/pgm_python.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck/in_out/render_bugs.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck/in_out/render_net.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck/in_out/render_pomegranate.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck/pgm.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck/pgm_circuit/__init__.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck/pgm_circuit/marginals_program.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck/pgm_circuit/mpe_program.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck/pgm_circuit/pgm_circuit.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck/pgm_circuit/program_with_slotmap.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck/pgm_circuit/slot_map.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck/pgm_circuit/support/__init__.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck/pgm_circuit/support/compile_circuit.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck/pgm_circuit/target_marginals_program.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck/pgm_circuit/wmc_program.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck/pgm_compiler/__init__.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck/pgm_compiler/ace/__init__.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck/pgm_compiler/pgm_compiler.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck/pgm_compiler/support/__init__.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck/pgm_compiler/support/circuit_table/__init__.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck/pgm_compiler/support/circuit_table/circuit_table.c +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck/pgm_compiler/support/circuit_table/circuit_table.pyx +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck/pgm_compiler/support/circuit_table/circuit_table_py.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck/pgm_compiler/support/clusters.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck/pgm_compiler/support/join_tree.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck/pgm_compiler/support/named_compiler_maker.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck/probability/__init__.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck/probability/empirical_probability_space.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck/probability/pgm_probability_space.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck/probability/probability_space.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck/program/__init__.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck/program/program.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck/program/program_buffer.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck/program/raw_program.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck/sampling/__init__.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck/sampling/forward_sampler.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck/sampling/marginals_direct_sampler.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck/sampling/sampler.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck/sampling/sampler_support.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck/sampling/uniform_sampler.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck/sampling/wmc_direct_sampler.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck/sampling/wmc_gibbs_sampler.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck/sampling/wmc_metropolis_sampler.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck/sampling/wmc_rejection_sampler.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck/utils/__init__.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck/utils/iter_extras.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck/utils/map_list.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck/utils/map_set.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck/utils/np_extras.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck/utils/random_extras.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck/utils/tmp_dir.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck_demos/__init__.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck_demos/ace/__init__.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck_demos/ace/copy_ace_to_ck.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck_demos/ace/demo_ace.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck_demos/all_demos.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck_demos/circuit/__init__.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck_demos/circuit/demo_circuit_dump.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck_demos/circuit/demo_derivatives.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck_demos/circuit_compiler/__init__.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck_demos/circuit_compiler/compare_circuit_compilers.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck_demos/circuit_compiler/show_llvm_program.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck_demos/pgm/__init__.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck_demos/pgm/demo_pgm_dump.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck_demos/pgm/demo_pgm_dump_stress.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck_demos/pgm/demo_pgm_string_rendering.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck_demos/pgm/show_examples.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck_demos/pgm_compiler/__init__.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck_demos/pgm_compiler/demo_compiler_dump.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck_demos/pgm_compiler/demo_factor_elimination.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck_demos/pgm_compiler/demo_join_tree.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck_demos/pgm_compiler/demo_marginals_program.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck_demos/pgm_compiler/demo_mpe_program.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck_demos/pgm_compiler/demo_pgm_compiler.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck_demos/pgm_compiler/demo_recursive_conditioning.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck_demos/pgm_compiler/demo_variable_elimination.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck_demos/pgm_compiler/demo_wmc_program.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck_demos/pgm_inference/__init__.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck_demos/pgm_inference/demo_inferencing_basic.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck_demos/pgm_inference/demo_inferencing_mpe_cancer.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck_demos/pgm_inference/demo_inferencing_wmc_and_mpe_sprinkler.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck_demos/pgm_inference/demo_inferencing_wmc_student.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck_demos/programs/__init__.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck_demos/programs/demo_program_buffer.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck_demos/programs/demo_program_multi.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck_demos/programs/demo_program_none.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck_demos/programs/demo_program_single.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck_demos/programs/demo_raw_program_interpreted.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck_demos/programs/demo_raw_program_llvm.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck_demos/sampling/__init__.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck_demos/sampling/check_sampler.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck_demos/sampling/demo_marginal_direct_sampler.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck_demos/sampling/demo_uniform_sampler.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck_demos/sampling/demo_wmc_direct_sampler.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck_demos/utils/__init__.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck_demos/utils/convert_network.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck_demos/utils/sample_model.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/ck_demos/utils/stop_watch.py +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/compiled_knowledge.egg-info/SOURCES.txt +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/compiled_knowledge.egg-info/dependency_links.txt +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/compiled_knowledge.egg-info/requires.txt +0 -0
- {compiled_knowledge-4.0.0a13 → compiled_knowledge-4.0.0a14}/src/compiled_knowledge.egg-info/top_level.txt +0 -0
{compiled_knowledge-4.0.0a13/src/compiled_knowledge.egg-info → compiled_knowledge-4.0.0a14}/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: compiled-knowledge
|
|
3
|
-
Version: 4.0.
|
|
3
|
+
Version: 4.0.0a14
|
|
4
4
|
Summary: A Python package for compiling and querying discrete probabilistic graphical models.
|
|
5
5
|
Author-email: Barry Drake <barry@compiledknowledge.org>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -43,7 +43,7 @@ Refer to the project online documentation at
|
|
|
43
43
|
The primary repository for the project is
|
|
44
44
|
[github.com/ropeless/compiled_knowledge](https://github.com/ropeless/compiled_knowledge).
|
|
45
45
|
|
|
46
|
-
The Python package is available on
|
|
46
|
+
The Python package is available on PyPI, see
|
|
47
47
|
[pypi.org/project/compiled-knowledge](https://pypi.org/project/compiled-knowledge/).
|
|
48
48
|
|
|
49
49
|
For more information email
|
|
@@ -26,7 +26,7 @@ Refer to the project online documentation at
|
|
|
26
26
|
The primary repository for the project is
|
|
27
27
|
[github.com/ropeless/compiled_knowledge](https://github.com/ropeless/compiled_knowledge).
|
|
28
28
|
|
|
29
|
-
The Python package is available on
|
|
29
|
+
The Python package is available on PyPI, see
|
|
30
30
|
[pypi.org/project/compiled-knowledge](https://pypi.org/project/compiled-knowledge/).
|
|
31
31
|
|
|
32
32
|
For more information email
|
|
@@ -18,19 +18,19 @@ class NamedCircuitCompiler(Enum):
|
|
|
18
18
|
Each member itself is callable, conforming to the CircuitCompiler protocol, delegating to the compiler function.
|
|
19
19
|
"""
|
|
20
20
|
|
|
21
|
-
LLVM_STACK
|
|
22
|
-
LLVM_TMPS
|
|
23
|
-
LLVM_VM
|
|
24
|
-
CYTHON_VM
|
|
25
|
-
INTERPRET
|
|
21
|
+
LLVM_STACK = (partial(llvm_compiler.compile_circuit, flavour=Flavour.STACK),)
|
|
22
|
+
LLVM_TMPS = (partial(llvm_compiler.compile_circuit, flavour=Flavour.TMPS, opt=0),)
|
|
23
|
+
LLVM_VM = (llvm_vm_compiler.compile_circuit,)
|
|
24
|
+
CYTHON_VM = (cython_vm_compiler.compile_circuit,)
|
|
25
|
+
INTERPRET = (interpret_compiler.compile_circuit,)
|
|
26
26
|
|
|
27
|
-
# The following circuit compilers were experimental but are not really useful
|
|
27
|
+
# The following circuit compilers were experimental but are not really useful.
|
|
28
28
|
#
|
|
29
29
|
# Slow compile and execution:
|
|
30
|
-
# LLVM_FUNCS
|
|
30
|
+
# LLVM_FUNCS = (partial(llvm_compiler.compile_circuit, flavour=Flavour.FUNCS, opt=0),)
|
|
31
31
|
#
|
|
32
32
|
# Slow compile and same execution as LLVM_VM:
|
|
33
|
-
# LLVM_VM_COMPILED_ARRAYS
|
|
33
|
+
# LLVM_VM_COMPILED_ARRAYS = (partial(llvm_vm_compiler.compile_circuit, compile_arrays=True),)
|
|
34
34
|
|
|
35
35
|
def __call__(
|
|
36
36
|
self,
|
|
@@ -2,25 +2,33 @@ from ck.pgm import PGM
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
class Pathfinder(PGM):
|
|
5
|
+
"""
|
|
6
|
+
This implementation of the Pathfinder PGM has 93 states for the "Fault" random
|
|
7
|
+
variable, and its factor has been normalised to be a CPT.
|
|
8
|
+
"""
|
|
5
9
|
|
|
6
10
|
def __init__(self):
|
|
7
11
|
super().__init__(self.__class__.__name__)
|
|
8
12
|
|
|
9
13
|
pgm_rv0 = self.new_rv('Fault', (
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
14
|
+
'AIDS early', 'AILD', 'ALIP', 'Cat scratch disease', 'Dermatopathic laden', 'Florid follic hyperp',
|
|
15
|
+
'GLH hyaline vascular', 'GLH plasma cell', 'Granulomatous laden', 'Histiocytosis x', 'Infectious mono',
|
|
16
|
+
'Leprosy-lepromatous', 'Lymphangiographic', 'Mantle zone hyperpla', 'Necrotizing Kikuchi',
|
|
17
|
+
'Necrotiz non-Kikuchi', 'Rheumatoid arthritis', 'Sarcoidosis', 'SHML', 'Sinus histiocytosis', 'Syphilis',
|
|
18
|
+
'Toxoplasmosis', 'Tuberculosis', 'Viral NOS', "Whipple's disease", 'L&H nodular HD', 'L&H diffuse HD',
|
|
19
|
+
'Nodular sclerosis HD', 'Cellular phase NSHD', 'Syncytial NSHD', 'Mixed cellularity HD',
|
|
20
|
+
'Interfollicular HD',
|
|
21
|
+
'Diffuse fibrosis HD', 'Reticular-type HD', 'Small cleaved fol', 'Mixed fol', 'Large cell fol',
|
|
22
|
+
'Small noncleaved fol', 'Small lymphocytic', 'Plasmacytoid lyctic', 'Mantle zone lymphoma',
|
|
23
|
+
'Small cleaved dif',
|
|
24
|
+
'Mixed FCC dif', 'Large cell dif', 'B-immunoblastic', 'T-immunob mixed', 'AILD-like T-cell lym',
|
|
25
|
+
'Japanese ATL',
|
|
26
|
+
'Lymphoblastic', 'Small noncleaved dif', 'True histiocytic', 'Ki-1 LC anaplas T', 'Multiple myeloma',
|
|
27
|
+
'Mycosis fungoides', 'AML', 'Hairy cell leukemia', 'Carcinoma', 'Melanoma', 'EM plasmacytoma',
|
|
28
|
+
"Kaposi's sarcoma", 'Mast-cell disease', 'AIDS involutionary', 'T-immunob large', 'Monocytoid B-cell',
|
|
29
|
+
'Nasopharyngeal CA', 'Seminoma', 'SLE', 'Mycobact histiocytos', 'Mast-cell hyperplas', 'LGV',
|
|
30
|
+
'Histoplasmosis',
|
|
31
|
+
'Coccidioidomycosis', 'CMV', 'Brucellosis', 'Ki-1 LC anaplas B', 'Intermed lymphocytic'))
|
|
24
32
|
pgm_rv1 = self.new_rv('ACID', ('Negative', 'Positive'))
|
|
25
33
|
pgm_rv2 = self.new_rv('F_CSA', ('No follicles', 'Absent', 'Present'))
|
|
26
34
|
pgm_rv3 = self.new_rv('F_ISL', ('No follicles', 'Absent', 'Present'))
|
|
@@ -58,25 +66,27 @@ class Pathfinder(PGM):
|
|
|
58
66
|
('Absent [0]', 'Rare [1-5]', 'Few [6-25]', 'Many [26-100]', 'Striking [>100]'))
|
|
59
67
|
pgm_rv34 = self.new_rv('LH_NOD', ('Absent', 'Present'))
|
|
60
68
|
pgm_rv35 = self.new_rv('LACUN', (
|
|
61
|
-
|
|
69
|
+
'Absent [0]', 'Rare [1-5]', 'Few [6-25]', 'Many [26 - 100]', 'Striking [>100]',
|
|
70
|
+
'Sheets [>50pc of section]'))
|
|
62
71
|
pgm_rv36 = self.new_rv('LANG', ('Absent [0]', 'Present [1-5]', 'Prominent [>5]'))
|
|
63
72
|
pgm_rv37 = self.new_rv('LEUK', ('Absent', 'Present'))
|
|
64
73
|
pgm_rv38 = self.new_rv('LLC_CY', ('No LLCs', 'Scanty', 'Moderate-abundant clear', 'Moderate-abundant deep'))
|
|
65
74
|
pgm_rv39 = self.new_rv('LLC_NS', (
|
|
66
|
-
|
|
67
|
-
|
|
75
|
+
'No LLCs', 'Multilobated [some]', 'Cerebriform/Mulberry [some]', 'Convoluted [some]', 'Irregular [most]',
|
|
76
|
+
'Round/slightly irregular [most]'))
|
|
68
77
|
pgm_rv40 = self.new_rv('LLC', (
|
|
69
|
-
|
|
78
|
+
'Absent [0pc]', 'Sparse [<10pc]', 'Moderate [11-50pc]', 'Numerous [51-90pc]', 'Striking [>90pc]'))
|
|
70
79
|
pgm_rv41 = self.new_rv('F_POPU', (
|
|
71
|
-
|
|
80
|
+
'No follicles', '>80pc 6-12u', '>50pc 13-20u with nucleoli', '>50pc >20u with nucleoli', 'Other'))
|
|
72
81
|
pgm_rv42 = self.new_rv('MAST', ('Absent [0]', 'Present [1-50]', 'Prominent [>50]'))
|
|
73
82
|
pgm_rv43 = self.new_rv('MLC', (
|
|
74
|
-
|
|
83
|
+
'Absent [0pc]', 'Sparse [<10pc]', 'Moderate [11-50pc]', 'Numerous [51-90pc]', 'Striking [>90pc]'))
|
|
75
84
|
pgm_rv44 = self.new_rv('MELANOMA', ('Absent', 'Present'))
|
|
76
85
|
pgm_rv45 = self.new_rv('MF10HP', ('0-5', '6-15', '16-50', '>50'))
|
|
77
86
|
pgm_rv46 = self.new_rv('MLC_CY', ('No MLCs', 'Scanty', 'Moderate-abundant clear', 'Moderate-abundant deep'))
|
|
78
87
|
pgm_rv47 = self.new_rv('MLC_NS', (
|
|
79
|
-
|
|
88
|
+
'No MLCs', 'Cerebriform [some]', 'Convoluted [some]', 'Irregular [most]',
|
|
89
|
+
'Round/slightly irregular [most]'))
|
|
80
90
|
pgm_rv48 = self.new_rv('MLC_NI', ('No MLCs', 'Absent to rare', 'Large central', 'Peripheral', 'Other'))
|
|
81
91
|
pgm_rv49 = self.new_rv('MCC', ('Absent [0pc]', 'Present [<5pc]', 'Prominent [5-50pc]', 'Confluence [>50pc]'))
|
|
82
92
|
pgm_rv50 = self.new_rv('MONO', ('Absent [0]', 'Rare [1-2]', 'Present [3-20]', 'Many [>20]'))
|
|
@@ -90,7 +100,8 @@ class Pathfinder(PGM):
|
|
|
90
100
|
pgm_rv57 = self.new_rv('PAS', ('No', 'Yes'))
|
|
91
101
|
pgm_rv58 = self.new_rv('PI', ('Absent', 'Present', 'Prominent'))
|
|
92
102
|
pgm_rv59 = self.new_rv('PLASMA', (
|
|
93
|
-
|
|
103
|
+
'Absent [0pc]', 'Few [<5pc]', 'Moderate [6-20pc]', 'Marked [21-50pc]', 'Striking [51-90pc]',
|
|
104
|
+
'Sheets [>90pc]'))
|
|
94
105
|
pgm_rv60 = self.new_rv('PC_TP', ('No plasma cells', 'Mature', 'Immature', 'Blastic', 'Pleomorphic', 'Mixed'))
|
|
95
106
|
pgm_rv61 = self.new_rv('PLEO', ('Absent [0]', 'Rare [1-5]', 'Few [6-25]', 'Many [26-100]', 'Striking [>100]'))
|
|
96
107
|
pgm_rv62 = self.new_rv('PFP', ('Absent', 'Present'))
|
|
@@ -101,10 +112,10 @@ class Pathfinder(PGM):
|
|
|
101
112
|
pgm_rv67 = self.new_rv('S_RING', ('Absent', 'Present'))
|
|
102
113
|
pgm_rv68 = self.new_rv('SLC_CY', ('No SLCs', 'Scanty', 'Moderate-abundant clear', 'Moderate-abundant deep'))
|
|
103
114
|
pgm_rv69 = self.new_rv('SLC_NS', (
|
|
104
|
-
|
|
105
|
-
|
|
115
|
+
'No SLCs', 'Cerebriform [some]', 'Convoluted [some]', 'Moderate-mark irregular [most]',
|
|
116
|
+
'Round/slightly irregular [most]'))
|
|
106
117
|
pgm_rv70 = self.new_rv('SLC', (
|
|
107
|
-
|
|
118
|
+
'Absent [0pc]', 'Sparse [1-10pc]', 'Moderate [11-50pc]', 'Numerous [51-90pc]', 'Striking [>90pc]'))
|
|
108
119
|
pgm_rv71 = self.new_rv('SINUSES', ('Distended', 'Patent', 'Part-greatly obliterated', 'Completely obliterated'))
|
|
109
120
|
pgm_rv72 = self.new_rv('VASC_C', ('Absent', 'Present'))
|
|
110
121
|
pgm_rv73 = self.new_rv('VASC_NS', ('Absent', 'Slight', 'Moderate', 'Marked', 'Pronounced'))
|
|
@@ -123,11 +134,12 @@ class Pathfinder(PGM):
|
|
|
123
134
|
pgm_rv86 = self.new_rv('F_SS',
|
|
124
135
|
('No follicles', 'Absent [0]', 'Slight [1-15]', 'Moderate [16-30]', 'Marked [>30]'))
|
|
125
136
|
pgm_rv87 = self.new_rv('F_MZSTAT', (
|
|
126
|
-
|
|
127
|
-
|
|
137
|
+
'No follicles/no mantle zones', 'Mantle zones absent in most follicles',
|
|
138
|
+
'Most incompletely surround follicles',
|
|
139
|
+
'Most completely surround fol not thick', 'Most thick [>10 lymphocytes]'))
|
|
128
140
|
pgm_rv88 = self.new_rv('F_MZCM', ('No follicles/no mantle zones', 'Absent', 'Present'))
|
|
129
141
|
pgm_rv89 = self.new_rv('F_DEF', (
|
|
130
|
-
|
|
142
|
+
'No follicles', 'Almost all well defined', 'Both well and poor defined', 'Almost all poor defined'))
|
|
131
143
|
pgm_rv90 = self.new_rv('F_MITO', ('No follicles', '0-20', '21-50', '>50'))
|
|
132
144
|
pgm_rv91 = self.new_rv('F_MZ', ('No follicles', 'Absent', 'Present'))
|
|
133
145
|
pgm_rv92 = self.new_rv('F_CIO', ('No follicles', 'Most similar', 'Some similar', 'None similar'))
|
|
@@ -169,13 +181,14 @@ class Pathfinder(PGM):
|
|
|
169
181
|
pgm_rv128 = self.new_rv('TB', ('Absent', 'Present', 'Prominent'))
|
|
170
182
|
pgm_rv129 = self.new_rv('MELANIN', ('Absent to normal', 'Present', 'Prominent'))
|
|
171
183
|
pgm_rv130 = self.new_rv('MC_SL_NS', (
|
|
172
|
-
|
|
184
|
+
'No follicles/no mantle zones', 'Round', 'Slightly irregular', 'Moderately irregular',
|
|
185
|
+
'Markedly irregular'))
|
|
173
186
|
pgm_rv131 = self.new_rv('FMZ_FUS', (
|
|
174
|
-
|
|
187
|
+
'No thick mantle zones', 'No nodules no fusion', 'Nodules but no fusion', 'Fusion with or without nodules'))
|
|
175
188
|
pgm_rv132 = self.new_rv('BH_NOS_L', ('No NOS benign histiocytes', 'Mainly interfollicular', 'Mainly sinusoidal',
|
|
176
189
|
'Both interfollicular and sinusoidal'))
|
|
177
190
|
pgm_rv133 = self.new_rv('SLC_NI', (
|
|
178
|
-
|
|
191
|
+
'No SLCs', 'None identifiable', '1 or more peripheral small', '1 central medium to large', 'Other'))
|
|
179
192
|
pgm_rv134 = self.new_rv('HYALIN', ('Absent', 'Present', 'Prominent'))
|
|
180
193
|
pgm_factor0 = self.new_factor(pgm_rv0)
|
|
181
194
|
pgm_factor1 = self.new_factor(pgm_rv1, pgm_rv128)
|
|
@@ -315,22 +328,82 @@ class Pathfinder(PGM):
|
|
|
315
328
|
|
|
316
329
|
pgm_function0 = pgm_factor0.set_dense()
|
|
317
330
|
pgm_function0.set_flat(
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
0.
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
331
|
+
0.018279029,
|
|
332
|
+
0.001370927,
|
|
333
|
+
0.004569757,
|
|
334
|
+
0.004569757,
|
|
335
|
+
0.022848787,
|
|
336
|
+
0.022848787,
|
|
337
|
+
0.004569757,
|
|
338
|
+
0.004569757,
|
|
339
|
+
0.013709272,
|
|
340
|
+
0.003655806,
|
|
341
|
+
0.001827903,
|
|
342
|
+
0.001827903,
|
|
343
|
+
0.004569757,
|
|
344
|
+
0.011424393,
|
|
345
|
+
0.007311612,
|
|
346
|
+
0.011698579,
|
|
347
|
+
0.001827903,
|
|
348
|
+
0.001827903,
|
|
349
|
+
0.002741854,
|
|
350
|
+
0.018279029,
|
|
351
|
+
0.001827903,
|
|
352
|
+
0.004569757,
|
|
353
|
+
0.003655806,
|
|
354
|
+
0.013709272,
|
|
355
|
+
0.000456976,
|
|
356
|
+
0.013709272,
|
|
357
|
+
0.002284879,
|
|
358
|
+
0.082255632,
|
|
359
|
+
0.007311612,
|
|
360
|
+
0.007311612,
|
|
361
|
+
0.063976603,
|
|
362
|
+
0.004569757,
|
|
363
|
+
0.002741854,
|
|
364
|
+
0.002741854,
|
|
365
|
+
0.100534662,
|
|
366
|
+
0.050267331,
|
|
367
|
+
0.018279029,
|
|
368
|
+
0.004569757,
|
|
369
|
+
0.036558059,
|
|
370
|
+
0.007311612,
|
|
371
|
+
0.009139515,
|
|
372
|
+
0.004569757,
|
|
373
|
+
0.005483709,
|
|
374
|
+
0.100534662,
|
|
375
|
+
0.018279029,
|
|
376
|
+
0.018279029,
|
|
377
|
+
0.010967418,
|
|
378
|
+
0.001827903,
|
|
379
|
+
0.009139515,
|
|
380
|
+
0.073116118,
|
|
381
|
+
0.000913951,
|
|
382
|
+
0.013709272,
|
|
383
|
+
0.001827903,
|
|
384
|
+
0.002741854,
|
|
385
|
+
0.004569757,
|
|
386
|
+
9.13951E-05,
|
|
387
|
+
0.018279029,
|
|
388
|
+
0.007311612,
|
|
389
|
+
0.004569757,
|
|
390
|
+
0.007311612,
|
|
391
|
+
0.001827903,
|
|
392
|
+
0.018279029,
|
|
393
|
+
0.022848787,
|
|
394
|
+
0.018279029,
|
|
395
|
+
0.004569757,
|
|
396
|
+
0.001827903,
|
|
397
|
+
0.001827903,
|
|
398
|
+
0.001827903,
|
|
399
|
+
0.001827903,
|
|
400
|
+
0.001827903,
|
|
401
|
+
0.001827903,
|
|
402
|
+
0.001827903,
|
|
403
|
+
0.004569757,
|
|
404
|
+
0.000228488,
|
|
405
|
+
0.003655806,
|
|
406
|
+
0.007311612,
|
|
334
407
|
)
|
|
335
408
|
|
|
336
409
|
pgm_function1 = pgm_factor1.set_dense()
|
|
@@ -64,10 +64,20 @@ def read_nnf_with_literal_map(
|
|
|
64
64
|
check_header=check_header,
|
|
65
65
|
optimise_ops=optimise_ops,
|
|
66
66
|
)
|
|
67
|
+
circuit = top_node.circuit
|
|
68
|
+
|
|
69
|
+
# Build the slot map from indicator to slot.
|
|
70
|
+
# Some indicators may not be in `literal_slot_map` because they were not needed
|
|
71
|
+
# for the arithmetic circuit in the NNF file. For those indicators, we create
|
|
72
|
+
# dummy circuit vars.
|
|
73
|
+
def _get_slot(_literal_code: int) -> int:
|
|
74
|
+
_slot: Optional[int] = literal_slot_map.get(_literal_code)
|
|
75
|
+
if _slot is None:
|
|
76
|
+
_slot: int = circuit.new_var().idx
|
|
77
|
+
return _slot
|
|
67
78
|
|
|
68
|
-
# Build the slot map from indicator to slot
|
|
69
79
|
slot_map: Dict[SlotKey, int] = {
|
|
70
|
-
indicator:
|
|
80
|
+
indicator: _get_slot(literal_code)
|
|
71
81
|
for literal_code, indicator in literal_map.indicators.items()
|
|
72
82
|
}
|
|
73
83
|
|
|
@@ -193,7 +203,7 @@ class Parser(ABC):
|
|
|
193
203
|
except ParseError as e:
|
|
194
204
|
raise e
|
|
195
205
|
except Exception as e:
|
|
196
|
-
input_stream.raise_error(e)
|
|
206
|
+
input_stream.raise_error(str(e))
|
|
197
207
|
|
|
198
208
|
@abstractmethod
|
|
199
209
|
def comment(self, raise_f, message: str) -> None:
|
|
@@ -101,16 +101,13 @@ def compile_pgm(
|
|
|
101
101
|
node_names: List[str] = render_bayesian_network(pgm, file, check_structure_bayesian=False)
|
|
102
102
|
|
|
103
103
|
# Run Ace
|
|
104
|
-
ace_result: subprocess.CompletedProcess = subprocess.run(ace_cmd, capture_output=
|
|
105
|
-
if print_output:
|
|
106
|
-
print(ace_result.stdout)
|
|
107
|
-
print(ace_result.stderr)
|
|
104
|
+
ace_result: subprocess.CompletedProcess = subprocess.run(ace_cmd, capture_output=(not print_output), text=True)
|
|
108
105
|
if ace_result.returncode != 0:
|
|
109
106
|
raise subprocess.CalledProcessError(
|
|
110
107
|
returncode=ace_result.returncode,
|
|
111
108
|
cmd=' '.join(ace_cmd),
|
|
112
|
-
output=ace_result.stdout,
|
|
113
|
-
stderr=ace_result.stderr,
|
|
109
|
+
output=None if print_output else ace_result.stdout,
|
|
110
|
+
stderr=None if print_output else ace_result.stderr,
|
|
114
111
|
)
|
|
115
112
|
|
|
116
113
|
# Parse the literal map output from Ace
|
|
@@ -21,7 +21,7 @@ def compile_pgm(
|
|
|
21
21
|
*,
|
|
22
22
|
algorithm: JoinTreeAlgorithm = MIN_FILL_THEN_DEGREE,
|
|
23
23
|
limit_product_tree_search: int = DEFAULT_PRODUCT_SEARCH_LIMIT,
|
|
24
|
-
pre_prune_factor_tables: bool =
|
|
24
|
+
pre_prune_factor_tables: bool = False,
|
|
25
25
|
) -> PGMCircuit:
|
|
26
26
|
"""
|
|
27
27
|
Compile the PGM to an arithmetic circuit, using factor elimination.
|
|
@@ -60,7 +60,7 @@ def compile_pgm_best_jointree(
|
|
|
60
60
|
const_parameters: bool = True,
|
|
61
61
|
*,
|
|
62
62
|
limit_product_tree_search: int = DEFAULT_PRODUCT_SEARCH_LIMIT,
|
|
63
|
-
pre_prune_factor_tables: bool =
|
|
63
|
+
pre_prune_factor_tables: bool = False,
|
|
64
64
|
) -> PGMCircuit:
|
|
65
65
|
"""
|
|
66
66
|
Try multiple elimination heuristics, and use the join tree that has
|
|
@@ -114,7 +114,7 @@ def join_tree_to_circuit(
|
|
|
114
114
|
join_tree: JoinTree,
|
|
115
115
|
const_parameters: bool = True,
|
|
116
116
|
limit_product_tree_search: int = DEFAULT_PRODUCT_SEARCH_LIMIT,
|
|
117
|
-
pre_prune_factor_tables: bool =
|
|
117
|
+
pre_prune_factor_tables: bool = False,
|
|
118
118
|
) -> PGMCircuit:
|
|
119
119
|
"""
|
|
120
120
|
Construct a PGMCircuit from a join-tree.
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
from enum import Enum
|
|
2
|
+
|
|
3
|
+
from ck.pgm import PGM
|
|
4
|
+
from ck.pgm_circuit import PGMCircuit
|
|
5
|
+
from ck.pgm_compiler import variable_elimination, factor_elimination, recursive_conditioning, ace
|
|
6
|
+
from .pgm_compiler import PGMCompiler
|
|
7
|
+
from .support.named_compiler_maker import get_compiler_algorithm as _get_compiler_algorithm, \
|
|
8
|
+
get_compiler as _get_compiler
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class NamedPGMCompiler(Enum):
|
|
12
|
+
"""
|
|
13
|
+
A standard collection of named compiler functions.
|
|
14
|
+
|
|
15
|
+
The `value` of each enum member is tuple containing a compiler function (PGM -> PGMCircuit).
|
|
16
|
+
Wrapping in a tuple is needed otherwise Python erases the type of the member, which can cause problems.
|
|
17
|
+
Each member itself is callable, confirming to the PGMCompiler protocol, delegating to the compiler function.
|
|
18
|
+
"""
|
|
19
|
+
# @formatter:off
|
|
20
|
+
|
|
21
|
+
VE_MIN_DEGREE = _get_compiler_algorithm(variable_elimination, 'MIN_DEGREE')
|
|
22
|
+
VE_MIN_DEGREE_THEN_FILL = _get_compiler_algorithm(variable_elimination, 'MIN_DEGREE_THEN_FILL')
|
|
23
|
+
VE_MIN_FILL = _get_compiler_algorithm(variable_elimination, 'MIN_FILL')
|
|
24
|
+
VE_MIN_FILL_THEN_DEGREE = _get_compiler_algorithm(variable_elimination, 'MIN_FILL_THEN_DEGREE')
|
|
25
|
+
VE_MIN_WEIGHTED_DEGREE = _get_compiler_algorithm(variable_elimination, 'MIN_WEIGHTED_DEGREE')
|
|
26
|
+
VE_MIN_WEIGHTED_FILL = _get_compiler_algorithm(variable_elimination, 'MIN_WEIGHTED_FILL')
|
|
27
|
+
VE_MIN_TRADITIONAL_WEIGHTED_FILL = _get_compiler_algorithm(variable_elimination, 'MIN_TRADITIONAL_WEIGHTED_FILL')
|
|
28
|
+
|
|
29
|
+
FE_MIN_DEGREE = _get_compiler_algorithm(factor_elimination, 'MIN_DEGREE')
|
|
30
|
+
FE_MIN_DEGREE_THEN_FILL = _get_compiler_algorithm(factor_elimination, 'MIN_DEGREE_THEN_FILL')
|
|
31
|
+
FE_MIN_FILL = _get_compiler_algorithm(factor_elimination, 'MIN_FILL')
|
|
32
|
+
FE_MIN_FILL_THEN_DEGREE = _get_compiler_algorithm(factor_elimination, 'MIN_FILL_THEN_DEGREE')
|
|
33
|
+
FE_MIN_WEIGHTED_DEGREE = _get_compiler_algorithm(factor_elimination, 'MIN_WEIGHTED_DEGREE')
|
|
34
|
+
FE_MIN_WEIGHTED_FILL = _get_compiler_algorithm(factor_elimination, 'MIN_WEIGHTED_FILL')
|
|
35
|
+
FE_MIN_TRADITIONAL_WEIGHTED_FILL = _get_compiler_algorithm(factor_elimination, 'MIN_TRADITIONAL_WEIGHTED_FILL')
|
|
36
|
+
FE_BEST_JOINTREE = factor_elimination.compile_pgm_best_jointree,
|
|
37
|
+
|
|
38
|
+
RC_MIN_DEGREE = _get_compiler_algorithm(recursive_conditioning, 'MIN_DEGREE')
|
|
39
|
+
RC_MIN_DEGREE_THEN_FILL = _get_compiler_algorithm(recursive_conditioning, 'MIN_DEGREE_THEN_FILL')
|
|
40
|
+
RC_MIN_FILL = _get_compiler_algorithm(recursive_conditioning, 'MIN_FILL')
|
|
41
|
+
RC_MIN_FILL_THEN_DEGREE = _get_compiler_algorithm(recursive_conditioning, 'MIN_FILL_THEN_DEGREE')
|
|
42
|
+
RC_MIN_WEIGHTED_DEGREE = _get_compiler_algorithm(recursive_conditioning, 'MIN_WEIGHTED_DEGREE')
|
|
43
|
+
RC_MIN_WEIGHTED_FILL = _get_compiler_algorithm(recursive_conditioning, 'MIN_WEIGHTED_FILL')
|
|
44
|
+
RC_MIN_TRADITIONAL_WEIGHTED_FILL = _get_compiler_algorithm(recursive_conditioning, 'MIN_TRADITIONAL_WEIGHTED_FILL')
|
|
45
|
+
|
|
46
|
+
ACE = _get_compiler(ace)
|
|
47
|
+
|
|
48
|
+
# @formatter:on
|
|
49
|
+
|
|
50
|
+
def __call__(self, pgm: PGM, const_parameters: bool = True) -> PGMCircuit:
|
|
51
|
+
"""
|
|
52
|
+
Each member of the enum is a PGMCompiler function.
|
|
53
|
+
|
|
54
|
+
This implements the `PGMCompiler` protocol.
|
|
55
|
+
"""
|
|
56
|
+
return self.compiler(pgm, const_parameters=const_parameters)
|
|
57
|
+
|
|
58
|
+
@property
|
|
59
|
+
def compiler(self) -> PGMCompiler:
|
|
60
|
+
return self.value[0]
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
DEFAULT_PGM_COMPILER: NamedPGMCompiler = NamedPGMCompiler.FE_BEST_JOINTREE
|
|
@@ -28,7 +28,7 @@ def compile_pgm(
|
|
|
28
28
|
const_parameters: bool = True,
|
|
29
29
|
*,
|
|
30
30
|
algorithm: ClusterAlgorithm = MIN_FILL_THEN_DEGREE,
|
|
31
|
-
pre_prune_factor_tables: bool =
|
|
31
|
+
pre_prune_factor_tables: bool = False,
|
|
32
32
|
) -> PGMCircuit:
|
|
33
33
|
"""
|
|
34
34
|
Compile the PGM to an arithmetic circuit, using recursive conditioning.
|
|
@@ -269,40 +269,48 @@ def _pre_prune_factor_tables(factor_rows: Sequence[_FactorRows]) -> None:
|
|
|
269
269
|
will be formed, which may eliminate rows. This method identifies and removes
|
|
270
270
|
such rows.
|
|
271
271
|
"""
|
|
272
|
+
# Find all pairs of factors that have at least one common random variable.
|
|
272
273
|
pairs_to_check: List[_FactorPair] = [
|
|
273
274
|
_FactorPair(f1, f2)
|
|
274
275
|
for f1, f2 in pairs(factor_rows)
|
|
275
276
|
if not set(f1.rv_indexes).isdisjoint(f1.rv_indexes)
|
|
276
277
|
]
|
|
277
278
|
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
while len(pairs_to_check) > 0:
|
|
281
|
-
pair = pairs_to_check.pop()
|
|
282
|
-
x = pair.x
|
|
283
|
-
y = pair.y
|
|
284
|
-
|
|
285
|
-
x_size = len(x)
|
|
286
|
-
y_size = len(y)
|
|
279
|
+
# Simple version.
|
|
280
|
+
for pair in pairs_to_check:
|
|
287
281
|
pair.prune()
|
|
288
282
|
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
283
|
+
# Earlier version.
|
|
284
|
+
# This version re-checks processed pairs that may get benefit from a subsequent pruning.
|
|
285
|
+
# Unfortunately, this is computationally expensive, and provides no practical benefit.
|
|
286
|
+
#
|
|
287
|
+
# pairs_done: List[_FactorPair] = []
|
|
288
|
+
# while len(pairs_to_check) > 0:
|
|
289
|
+
# pair: _FactorPair = pairs_to_check.pop()
|
|
290
|
+
# x: _FactorRows = pair.x
|
|
291
|
+
# y: _FactorRows = pair.y
|
|
292
|
+
#
|
|
293
|
+
# x_size = len(x)
|
|
294
|
+
# y_size = len(y)
|
|
295
|
+
# pair.prune()
|
|
296
|
+
#
|
|
297
|
+
# # See if any pairs need re-checking
|
|
298
|
+
# rvs_affected: Set[int] = set()
|
|
299
|
+
# if x_size != len(x):
|
|
300
|
+
# rvs_affected.update(x.rv_indexes)
|
|
301
|
+
# if y_size != len(y):
|
|
302
|
+
# rvs_affected.update(y.rv_indexes)
|
|
303
|
+
# if len(rvs_affected) > 0:
|
|
304
|
+
# next_pairs_done: List[_FactorPair] = []
|
|
305
|
+
# for pair in pairs_done:
|
|
306
|
+
# if rvs_affected.isdisjoint(pair.all_rv_indexes):
|
|
307
|
+
# next_pairs_done.append(pair)
|
|
308
|
+
# else:
|
|
309
|
+
# pairs_to_check.append(pair)
|
|
310
|
+
# pairs_done = next_pairs_done
|
|
311
|
+
#
|
|
312
|
+
# # Mark the current pair as done.
|
|
313
|
+
# pairs_done.append(pair)
|
|
306
314
|
|
|
307
315
|
|
|
308
316
|
def _make_factor_table(
|
|
@@ -25,7 +25,7 @@ def compile_pgm(
|
|
|
25
25
|
const_parameters: bool = True,
|
|
26
26
|
*,
|
|
27
27
|
algorithm: ClusterAlgorithm = MIN_FILL_THEN_DEGREE,
|
|
28
|
-
pre_prune_factor_tables: bool =
|
|
28
|
+
pre_prune_factor_tables: bool = False,
|
|
29
29
|
) -> PGMCircuit:
|
|
30
30
|
"""
|
|
31
31
|
Compile the PGM to an arithmetic circuit, using variable elimination.
|
|
@@ -9,6 +9,14 @@ from ck_demos.utils.compare import compare
|
|
|
9
9
|
|
|
10
10
|
# @formatter:off
|
|
11
11
|
|
|
12
|
+
# =========================================
|
|
13
|
+
# Experiment configuration
|
|
14
|
+
# =========================================
|
|
15
|
+
|
|
16
|
+
CACHE_CIRCUITS: bool = True
|
|
17
|
+
BREAK_BETWEEN_PGMS: bool = True
|
|
18
|
+
COMMA_NUMBERS: bool = True
|
|
19
|
+
|
|
12
20
|
PGMS: Sequence[PGM] = [
|
|
13
21
|
example.Rain(),
|
|
14
22
|
example.Cancer(),
|
|
@@ -19,20 +27,20 @@ PGMS: Sequence[PGM] = [
|
|
|
19
27
|
example.Child(),
|
|
20
28
|
example.Alarm(),
|
|
21
29
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
30
|
+
example.Hailfinder(),
|
|
31
|
+
example.Insurance(),
|
|
32
|
+
example.Pathfinder(),
|
|
33
|
+
example.Mildew(),
|
|
26
34
|
]
|
|
27
35
|
|
|
28
|
-
CCT_COMPILERS: Sequence[NamedCircuitCompiler] = [DEFAULT_CIRCUIT_COMPILER]
|
|
29
|
-
|
|
30
36
|
PGM_COMPILERS: Sequence[NamedPGMCompiler] = [
|
|
31
37
|
named_compiler
|
|
32
38
|
for named_compiler in NamedPGMCompiler
|
|
33
39
|
if named_compiler.name.startswith('FE_') and 'WEIGHTED' not in named_compiler.name
|
|
34
40
|
] + [NamedPGMCompiler.ACE]
|
|
35
41
|
|
|
42
|
+
CCT_COMPILERS: Sequence[NamedCircuitCompiler] = [DEFAULT_CIRCUIT_COMPILER]
|
|
43
|
+
|
|
36
44
|
# @formatter:on
|
|
37
45
|
|
|
38
46
|
|
|
@@ -41,6 +49,9 @@ def main() -> None:
|
|
|
41
49
|
pgms=PGMS,
|
|
42
50
|
pgm_compilers=PGM_COMPILERS,
|
|
43
51
|
cct_compilers=CCT_COMPILERS,
|
|
52
|
+
cache_circuits=CACHE_CIRCUITS,
|
|
53
|
+
break_between_pgms=BREAK_BETWEEN_PGMS,
|
|
54
|
+
comma_numbers=COMMA_NUMBERS,
|
|
44
55
|
)
|
|
45
56
|
print()
|
|
46
57
|
print('Done.')
|