public void processMAXSAT() { HashSet<UGroundedSoftRule> remainingSoftRules = new HashSet<UGroundedSoftRule>(); remainingSoftRules.addAll(softRuleGroundings); double p = 0.63; steps = 0; TRUE_FACTS = 0; FALSE_FACTS = 0; // For each competitor set S_k, O(Sum_k|S_k|) for (UGroundedHardRule S_k : hardRuleGroundings) getProbabilityHardRule(S_k, p); // For each soft rule C_i, O(Sum_i|C_i|) for (UGroundedSoftRule C_i : softRuleGroundings) { double p_C_i = getProbabilitySoftRule(C_i); // W_t += C_i.getWeight() * p_C_i; if (p_C_i == 1.0) { // || p_C_i == 0.0) { // System.out.println("REMOVE: " + C_i); remainingSoftRules.remove(C_i); } steps++; } // For each competitor set S_k for (UGroundedHardRule S_k : hardRuleGroundings) { UFact f_max = null; double W_t0 = 0, W_tf, W_tf_max = 0; // System.out.println("REMAINING: " + remainingSoftRules.size()); if (remainingSoftRules.size() > 0) { // For each f in S_k for (UFact f : S_k) { W_tf = 0; for (UGroundedSoftRule C_i : invSoftRules.get(f)) { if (!remainingSoftRules.contains(C_i)) continue; W_tf += C_i.getWeight() * getProbabilitySoftRuleAllFalseExceptOne(C_i, S_k, f); // O(|C_i|) } if (W_tf > W_tf_max) { f_max = f; W_tf_max = W_tf; } } // For each f in S_k for (UFact f : S_k) { W_t0 = 0; for (UGroundedSoftRule C_i : invSoftRules.get(f)) { if (!remainingSoftRules.contains(C_i)) continue; W_t0 += C_i.getWeight() * getProbabilitySoftRuleAllFalse(C_i, S_k); // O(|C_i|) } } } for (UFact f : S_k) { if (f.getTruthValue() == UFact.UNKNOWN) { if (W_t0 >= W_tf_max || f != f_max) { f.setTruthValue(UFact.FALSE); // choose minimal model if undecided FALSE_FACTS++; } else { f.setTruthValue(UFact.TRUE); TRUE_FACTS++; } for (UGroundedSoftRule C_i : invSoftRules.get(f)) { if (C_i.isSatisfied() != UFact.UNKNOWN) remainingSoftRules.remove(C_i); } } steps++; } } }