Skip to content

Commit

Permalink
readme, licence
Browse files Browse the repository at this point in the history
  • Loading branch information
SHoltzen committed Aug 23, 2019
1 parent 823587c commit 3bac086
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 29 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -114,3 +114,5 @@ dmypy.json

# Pyre type checker
.pyre/

.#*
19 changes: 19 additions & 0 deletions LICENCE
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Copyright 2019 Steven Holtzen

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

53 changes: 53 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# About

This repository contains the implementation that performed the experiments for the
research paper:

* Holtzen, Steven, Todd Millstein, and Guy Van den Broeck. ["Generating and
Sampling Orbits for Lifted Probabilistic
Inference."](https://arxiv.org/abs/1903.04672) Uncertainty in Artificial
Intelligence (UAI). 2019.

To cite, please use:

```
@inproceedings{HoltzenUAI19,
author = {Holtzen, Steven and Millstein, Todd and Van den Broeck, Guy},
title = {Generating and Sampling Orbits for Lifted Probabilistic Inference},
booktitle = {Proceedings of the 35th Conference on Uncertainty in Artificial Intelligence (UAI)},
month = {jul},
year = {2019},
}
```

# Disclaimer

This code is provided as-is. It is what was used to run the experiments in the
paper. It is typical research-ware; there are many improvements that could be
made, and it is definitely not ready for prime-time (i.e., production). Think of
it like extra-detailed documentation on how the algorithm described in the paper
works.

# Installation

While it may look like regular Python, this code must actually be run
using the [Sage math library](https://www.sagemath.org/library.html).
To use this library:

1. Install sage.
2. Install `bliss` by running `sage -i bliss` (if you want to hack the code to
remove this requirement, it is possible to do so, but it will be much slower)
3. Run `sage setup.py`

# Organization

* `factor.py` contains the most interesting code. It has a simple implementation of
a factor graph and the exact and approximate lifted inference algorithms
from the paper.
* `my_graphs.py` contains the example factor graphs that are generated
* `experiments.py` contains stubs for running the experiments from the paper
* `tests.py` contains some standard test cases that illustrate usage.

To execute these files, use `sage` (*not* the regular Python command). I.e.,
run `sage test.py`.

34 changes: 5 additions & 29 deletions experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,35 +14,6 @@
import itertools
import time

# holes pigeons, m holes
def mk_pigeonhole_fg(n, m, order=True):
w1 = 10000000
w2 = 100000
(g, (variables, factors)) = gen_pigeonhole_fg(n, m)
def potential(state):
total = 0.0
# to see every pigeon in exactly one hole
for p in range(0, n):
# check the holes for the pigeons
in_hole = False
for h in range(0, m):
if state[(p, h)]:
if in_hole:
return 0.000000001
else:
in_hole = True
if in_hole:
total += w1


# check to see no no hole has 2 pigeons
for h in range(0, m):
for (p1, p2) in findsubsets(range(0, n), 2):
if not state[(p1, h)] or not state[(p2, h)]:
total += w2

return total
return FactorGraph(g, variables, factors, potential)


### computes the total variation distance comparing different sampling methods
Expand Down Expand Up @@ -101,6 +72,11 @@ def pigeonhole_dtv():
model.total_variation(burnside, start, 100)


def pigeonhole_exact_lifted():
model = mk_pigeonhole_fg(2,5)
model.partition()


if __name__ == "__main__":
# run your test here if you want
pigeonhole_dtv()

0 comments on commit 3bac086

Please sign in to comment.