예제 #1
0
파일: Knowledge2.java 프로젝트: ps7z/tetrad
  /**
   * Adds a knowledge group. Legacy method, replaced by setForbidden, setRequired with patterns.
   * Needed for the interface.
   */
  public void addKnowledgeGroup(KnowledgeGroup group) {
    this.knowledgeGroups.add(group);

    OrderedPair<Set<MyNode>> o = getGroupRule(group);
    knowledgeGroupRules.put(group, o);

    if (group.getType() == KnowledgeGroup.FORBIDDEN) {
      forbiddenRulesSpecs.add(o);
    } else if (group.getType() == KnowledgeGroup.REQUIRED) {
      requiredRulesSpecs.add(o);
    }
  }
예제 #2
0
파일: Knowledge2.java 프로젝트: ps7z/tetrad
  /** Legacy, do not use. */
  public void setKnowledgeGroup(int index, KnowledgeGroup group) {
    OrderedPair<Set<MyNode>> o = getGroupRule(group);
    OrderedPair<Set<MyNode>> old = knowledgeGroupRules.get(knowledgeGroups.get(index));

    forbiddenRulesSpecs.remove(old);
    requiredRulesSpecs.remove(old);

    if (group.getType() == KnowledgeGroup.FORBIDDEN) {
      forbiddenRulesSpecs.add(o);
    } else if (group.getType() == KnowledgeGroup.REQUIRED) {
      requiredRulesSpecs.add(o);
    }

    knowledgeGroups.set(index, group);
  }
예제 #3
0
파일: Knowledge2.java 프로젝트: ps7z/tetrad
  /** Legacy. */
  public final boolean isForbiddenByGroups(String var1, String var2) {
    Set<OrderedPair<Set<MyNode>>> s = new HashSet<>();

    for (KnowledgeGroup group : knowledgeGroups) {
      if (group.getType() == KnowledgeGroup.FORBIDDEN) {
        OrderedPair<Set<MyNode>> o = getGroupRule(group);
        s.add(o);
      }
    }

    for (OrderedPair<Set<MyNode>> rule : s) {
      if (rule.getFirst().contains(namesToVars.get(var1))) {
        if (rule.getSecond().contains(namesToVars.get(var2))) {
          return true;
        }
      }
    }

    return false;
  }
예제 #4
0
파일: Knowledge2.java 프로젝트: ps7z/tetrad
  /** Legacy. */
  public final boolean isRequiredByGroups(String var1, String var2) {
    Set<OrderedPair<Set<MyNode>>> s = new HashSet<>();

    for (KnowledgeGroup group : knowledgeGroups) {
      if (group.getType() == KnowledgeGroup.REQUIRED) {
        OrderedPair<Set<MyNode>> o = getGroupRule(group);
        s.add(o);
      }
    }

    for (OrderedPair<Set<MyNode>> rule : s) {
      if (rule.getFirst().contains(getVar(var1))) {
        if (rule.getSecond().contains(getVar(var2))) {
          return true;
        }
      }
    }

    return false;
  }