Example #1
0
  public double getProbabilitySoftRuleAllFalseExceptOne(
      UGroundedSoftRule softRule, UGroundedHardRule hardRule, UFact fact) {

    double q_c = 1;
    for (USoftRulePartition partition : softRule.partitions) {
      if (partition.n > 1) {
        System.err.println("CLAUSE ALREADY SATISFIED!");
        return 1;
      }
      for (USignedFact literal : partition) {
        steps++;
        if ((literal.equals(fact) && literal.sign)
            || (!literal.equals(fact) && !literal.sign && hardRule.contains(literal.fact))) {
          return 1;
        }
      }
      if (partition.n == 1) partition.q_r = (1 - partition.p_i);
      else partition.q_r = partition.p_i;
      q_c *= (1 - partition.q_r);
      steps++;
    }

    // System.out.println("SOFTRULE-1: " + softRule + " -> " + (1 - q_c));
    return 1 - q_c;
  }
Example #2
0
  public double getProbabilitySoftRule(UGroundedSoftRule softRule) {
    if (softRule.partitions == null) softRule.partitions = getPartitions(softRule);

    double q_c = 1;
    for (USoftRulePartition partition : softRule.partitions) {
      steps++;
      if (partition.n > 1) {
        q_c = 0;
        break;
      } else if (partition.n == 1) partition.q_r = (1 - partition.p_i);
      else partition.q_r = partition.p_i;
      // System.out.println("  PART: " + partition + "  " + partition.p_i + "  " + partition.q_r);
      q_c *= (1 - partition.q_r);
      steps++;
    }

    // System.out.println("SOFTRULE: " + softRule + " -> " + (1 - q_c));
    return 1 - q_c;
  }