@Override
  public GMQueryResult computeProb(GMQuery query) {

    Set<RVariableValue> conditions = query.getConditionValues();
    RFConVariableValue rval =
        (RFConVariableValue) this.extractValueForVariableFromConditions(rewardRV, conditions);

    double p = 0.;
    boolean found = false;
    List<TaskProb> tps = this.feedbackAnalyzer.getPosteriors().getTaskProbs();
    for (TaskProb tp : tps) {
      if (tp.getTask().rf.equals(rval.rf)) {
        p = tp.getLikilhood();
        found = true;
        break;
      }
    }

    if (!found) {
      throw new RuntimeException(
          "No Matching probabiltiy associated with reward function: " + rval.rf.toString());
    }

    GMQueryResult result = new GMQueryResult(query, p);

    return result;
  }
예제 #2
0
  @Override
  public GMQueryResult computeProb(GMQuery query) {

    double p = 0.;
    RVariableValue qv = query.getSingleQueryVar();

    if (qv.isValueFor(propRV)) {
      p = this.computeProbForProp(query);
    }
    if (qv.isValueFor(wordRV)) {
      p = this.computeMNParamProb(qv, query.getConditionValues());
    }
    if (qv.isValueFor(commandRV)) {
      p = this.computeProbForCommand(query);
    }

    return new GMQueryResult(query, p);
  }
예제 #3
0
  public double computeProbForCommand(GMQuery query) {

    StringValue commandValue = (StringValue) query.getSingleQueryVar();

    Set<RVariableValue> conditions = query.getConditionValues();
    TaskDescriptionValue constraints =
        (TaskDescriptionValue) this.extractValueForVariableFromConditions(constraintRV, conditions);
    TaskDescriptionValue goals =
        (TaskDescriptionValue) this.extractValueForVariableFromConditions(goalRV, conditions);

    Map<StringValue, Integer> counts = getWordCounts(commandValue.s);
    Set<String> pfNames = this.getUniquePFNames(constraints, goals);

    double p = 1.;
    for (StringValue wVal : counts.keySet()) {
      p *= Math.pow(this.probWGivenProps(pfNames, wVal), counts.get(wVal));
    }

    return p;
  }
예제 #4
0
  public double computeProbForProp(GMQuery query) {

    StringValue propVal = (StringValue) query.getSingleQueryVar();

    Set<RVariableValue> conditions = query.getConditionValues();
    TaskDescriptionValue constraints =
        (TaskDescriptionValue) this.extractValueForVariableFromConditions(constraintRV, conditions);
    TaskDescriptionValue goals =
        (TaskDescriptionValue) this.extractValueForVariableFromConditions(goalRV, conditions);

    Set<String> pfNames = new HashSet<String>();
    boolean foundMatch = false;
    for (GroundedProp gp : constraints.props) {
      String pfName = gp.pf.getName();
      pfNames.add(pfName);
      if (!foundMatch && pfName.equals(propVal.s)) {
        foundMatch = true;
      }
    }
    for (GroundedProp gp : goals.props) {
      String pfName = gp.pf.getName();
      pfNames.add(pfName);
      if (!foundMatch && pfName.equals(propVal.s)) {
        foundMatch = true;
      }
    }

    if (!foundMatch && !propVal.s.equals(this.constantFeatureName)) {
      return 0.;
    }

    double n = pfNames.size();
    if (useConstantFeature) {
      n += 1.;
    }

    double p = 1. / n;

    return p;
  }