dylanbeadle / alchemy-2

Alchemy 2 - Inference and Learning in Markov Logic
Other
23 stars 11 forks source link

"social networks" example doesn't work. #8

Open ldltools opened 4 years ago

ldltools commented 4 years ago

Hi, I've just started trying alchemy-2 with the soc-net example in the tutorial (http://alchemy.cs.washington.edu/mlns/tutorial/soc-net/smoking.mln), but learnwts crashes after complaining "UNRECOVERABLE ERROR after parsing smoking.mln". It looks like the idx > 0 part of src/logic/clause.h causes the problem.

  Predicate* getPredicate(const int& idx) const {
    if (idx > 0 && idx < getNumPredicates()){
      return (*predicates_)[idx];
    }   
    else return NULL;

Replacing the expression with idx >= 0 seems to fix the problem. Is this a correct fix, or am I missing something?

JoeDumoulin commented 4 years ago

I looked at this today and I think I got a little too eager about "fixing" null pointer references a while back. I will be testing this evening and then get back to you. I think your solution is close to the right one though.

JoeDumoulin commented 4 years ago

I've created a pull request for your change. please give it a try and give us feedback.