Skip to content

Commit

Permalink
Merge pull request #19 from ML-KULeuven/develop
Browse files Browse the repository at this point in the history
Mainly bugfixes, but we also changed the Term's hashing method. If this proofs to be worse, we may reconsider switching back later.

* Bugfix library/string.py::str2lst (public issue #84)
* Bugfix return exit code instead of result - only for probability task atm (public issue #82)
* Critical Bugfix in dSharp library (compiled CNF theory with too long clauses could yield wrong result)
* Bugfix in pypl related to lists (private issue #16)
* Minor improvements to LFI
* Changed Term's hashing method
  • Loading branch information
VincentDerk authored Jun 29, 2022
2 parents b719042 + d818f94 commit 7663525
Show file tree
Hide file tree
Showing 45 changed files with 75,275 additions and 186 deletions.
26 changes: 23 additions & 3 deletions INSTALL
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ For better performance you can also run ProbLog with PyPy:
http://pypy.org/download.html

ProbLog's evaluation is based on knowledge compilation tools.
By default it uses dsharp [https://bitbucket.org/haz/dsharp].
By default it uses dsharp [https://github.com/QuMuLab/dsharp/].

It also supports two other tools:
* C2D Compiler (NNF) [http://reasoning.cs.ucla.edu/c2d/]
Expand Down Expand Up @@ -88,10 +88,30 @@ C2D is automatically used instead of dsharp when detected.
Licenses of included third-party software
-----------------------------------------

DSharp [https://bitbucket.org/haz/dsharp]
DSharp [https://github.com/QuMuLab/dsharp/]
+++++++++++++++++++++++++++++++++++++++++

GPLv2
MIT License

Copyright (c) 2022 Christian Muise

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.

SDD [http://reasoning.cs.ucla.edu/sdd/]
+++++++++++++++++++++++++++++++++++++++
Expand Down
3 changes: 2 additions & 1 deletion KNOWN_ISSUES
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ There are two possible solutions:

- Use a different knowledge compiler that does not have this issue (c2d or SDD).

- Compile a dSharp 32-bit version (dSharp source: https://bitbucket.org/haz/dsharp/src/default/)
- Compile a dSharp 32-bit version (dSharp source: https://github.com/QuMuLab/dsharp/)
and replace the original dSharp file with it. The path can be found in the OSError message.
Alternatively, use the 32-bit version in this zip: https://github.com/ML-KULeuven/problog/files/3448011/dsharp.zip
Note: the .zip version is outdated and needs to be replaced (that binary has a limit on CNF clause length).
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@ tested on *Mac OSX*, *Linux* and *Windows*.

[![CircleCI](https://circleci.com/gh/ML-KULeuven/problog/tree/master.svg?style=svg)](https://circleci.com/gh/ML-KULeuven/problog/tree/master)
[![codecov](https://codecov.io/gh/ML-KULeuven/problog/branch/master/graph/badge.svg)](https://codecov.io/gh/ML-KULeuven/problog/branch/master)
dev:
[![CircleCI](https://circleci.com/gh/ML-KULeuven/problog/tree/develop.svg?style=svg)](https://circleci.com/gh/ML-KULeuven/problog/tree/develop)
[![codecov](https://codecov.io/gh/ML-KULeuven/problog/branch/develop/graph/badge.svg)](https://codecov.io/gh/ML-KULeuven/problog/branch/develop)


ProbLog supports optional components which can be installed separately.
See the file [INSTALL](https://github.com/ML-KULeuven/problog/blob/develop/INSTALL) for detailed installation instructions.
Expand Down
5 changes: 2 additions & 3 deletions conversions/bn2problog.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import sys
import os
import argparse
import itertools
import logging
import abc

Expand Down Expand Up @@ -77,13 +76,13 @@ def add_parser_arguments(parser):
"--valueinatomname",
action="store_false",
help="Add value to atom name instead as a term (this removes invalid characters, "
"be careful that clean values do not overlap)",
"be careful that clean values do not overlap)",
)
parser.add_argument(
"--adisfunction",
action="store_true",
help="Consider all ADs to represent functions of mutual exclusive conditions (like "
"in a Bayesian net)",
"in a Bayesian net)",
)
parser.add_argument("--compress", action="store_true", help="Compress tables")
parser.add_argument(
Expand Down
2 changes: 1 addition & 1 deletion conversions/pyparsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -872,7 +872,7 @@ def dump(self, indent="", depth=0):
def pprint(self, *args, **kwargs):
"""Pretty-printer for parsed results as a list, using the C{pprint} module.
Accepts additional positional or keyword args as defined for the
C{pprint.pprint} method. (U{http://docs.python.org/3/library/pprint.html#pprint.pprint})"""
C{pprint.pprint} method. (U{https://docs.python.org/3/library/pprint.html#pprint.pprint})"""
pprint.pprint(self.asList(), *args, **kwargs)

# add support for pickle protocol
Expand Down
2 changes: 1 addition & 1 deletion problog-cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
Expand Down
Binary file modified problog/bin/darwin/dsharp
Binary file not shown.
Binary file modified problog/bin/linux/dsharp
Binary file not shown.
Binary file modified problog/bin/windows/dsharp.exe
100755 → 100644
Binary file not shown.
13 changes: 9 additions & 4 deletions problog/clausedb.py
Original file line number Diff line number Diff line change
Expand Up @@ -875,13 +875,18 @@ def _create_alias(

def load_external_module(self, filename):
from .extern import problog_export
import imp

problog_export.database = self

module_name = os.path.splitext(os.path.split(filename)[-1])[0]
with open(filename, "r") as extfile:
imp.load_module(module_name, extfile, filename, (".py", "U", 1))

# Replaced deprecated imp.load_module()
# source: https://stackoverflow.com/a/19011259
import importlib.machinery
import importlib.util
loader = importlib.machinery.SourceFileLoader(module_name, filename)
module_spec = importlib.util.spec_from_loader(loader.name, loader)
new_module = importlib.util.module_from_spec(module_spec)
loader.exec_module(new_module)

return module_name, self.__extern[module_name]

Expand Down
24 changes: 18 additions & 6 deletions problog/dd_formula.py
Original file line number Diff line number Diff line change
Expand Up @@ -443,9 +443,13 @@ def _initialize(self, with_evidence=True):

def propagate(self):
self._initialize()
# if (
# type(self.semiring) == SemiringLogProbability
# or type(self.semiring) == SemiringProbability
# ):
if (
type(self.semiring) == SemiringLogProbability
or type(self.semiring) == SemiringProbability
isinstance(self.semiring, SemiringLogProbability)
or isinstance(self.semiring, SemiringProbability)
):
self.normalization = self._get_manager().wmc_true(
self.weights, self.semiring
Expand All @@ -462,9 +466,13 @@ def _evaluate_evidence(self, recompute=False):
constraint_inode, *evidence_nodes
)

# if (
# type(self.semiring) == SemiringLogProbability
# or type(self.semiring) == SemiringProbability
# ):
if (
type(self.semiring) == SemiringLogProbability
or type(self.semiring) == SemiringProbability
isinstance(self.semiring, SemiringLogProbability)
or isinstance(self.semiring, SemiringProbability)
):
result = self._get_manager().wmc(
self.evidence_inode, self.weights, self.semiring
Expand Down Expand Up @@ -499,9 +507,13 @@ def evaluate_evidence(self, recompute=False):
)

def evaluate(self, node):
# if (
# type(self.semiring) == SemiringLogProbability
# or type(self.semiring) == SemiringProbability
# ):
if (
type(self.semiring) == SemiringLogProbability
or type(self.semiring) == SemiringProbability
isinstance(self.semiring, SemiringLogProbability)
or isinstance(self.semiring, SemiringProbability)
):
return self.evaluate_standard(node)
else:
Expand Down
10 changes: 5 additions & 5 deletions problog/extern.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
Expand Down Expand Up @@ -142,8 +142,8 @@ def _wrapped_function(*args, **kwdargs):
)
converted_args = self._convert_inputs(args)

argspec = inspect.getargspec(func)
if argspec.keywords is not None:
argspec = inspect.getfullargspec(func)
if argspec.varkw is not None:
result = func(*converted_args, **kwdargs)
else:
result = func(*converted_args)
Expand Down Expand Up @@ -272,8 +272,8 @@ def _wrapped_function(*args, **kwdargs):
)
converted_args = self._convert_inputs(args)
results = []
argspec = inspect.getargspec(func)
if argspec.keywords is not None:
argspec = inspect.getfullargspec(func)
if argspec.varkw is not None:
func_result = func(*converted_args, **kwdargs)
else:
func_result = func(*converted_args)
Expand Down
Loading

0 comments on commit 7663525

Please sign in to comment.