Beispiel #1
0
 /**
  * Creates a new user/environment simulator.
  *
  * @param system the main dialogue system to which the simulator should connect
  * @param domain the dialogue domain for the simulator not be created
  */
 public Simulator(DialogueSystem system, Domain domain) {
   this.system = system;
   this.domain = domain;
   simulatorState = domain.getInitialState().copy();
   simulatorState.setParameters(domain.getParameters());
   this.system.changeSettings(domain.getSettings());
 }
Beispiel #2
0
  /**
   * Performs the dialogue turn in the simulator.
   *
   * @param systemAction the last system action. @
   */
  private synchronized boolean performTurn(Value systemAction) {

    boolean turnPerformed = false;
    simulatorState.setParameters(domain.getParameters());
    Assignment systemAssign = new Assignment(system.getSettings().systemOutput, systemAction);
    simulatorState.addToState(systemAssign);

    while (!simulatorState.getNewVariables().isEmpty()) {
      Set<String> toProcess = simulatorState.getNewVariables();
      simulatorState.reduce();

      for (Model model : domain.getModels()) {
        if (model.isTriggered(simulatorState, toProcess)) {
          boolean change = model.trigger(simulatorState);
          if (change && model.isBlocking()) {
            break;
          }
        }
      }

      if (!simulatorState.getUtilityNodeIds().isEmpty()) {
        double reward = simulatorState.queryUtil();
        String comment = "Reward: " + StringUtils.getShortForm(reward);
        system.displayComment(comment);
        system
            .getState()
            .addEvidence(new Assignment("R(" + systemAssign.addPrimes() + ")", reward));
        simulatorState.removeNodes(simulatorState.getUtilityNodeIds());
      }

      if (addNewObservations()) {
        turnPerformed = true;
      }

      simulatorState.addEvidence(simulatorState.getSample());
    }
    return turnPerformed;
  }