Ejemplo n.º 1
0
  /**
   * Abbrechen der Auswertung.
   *
   * @throws ConnectionException
   */
  private void abort() throws ConnectionException {
    IEvaluation eval = fConnection.getEvaluation();

    int cnt = 0;
    eval.getConnection().getProtocolWriter().writeAbortRestart();
    eval.resetOutputState();
    while (eval.nextOutputLine() != null) {
      cnt++;
    }
    eval.getConnection().getProtocolReader().readSuccess();
  }
Ejemplo n.º 2
0
  /**
   * Ausfuehrung der Evaluierung. Jeder Ausdruck wird ueber die Verbindung ausgewertet und das
   * Ergebnis der Evaluierung wird dem {@link IBackgroundEvaluationListener} mitgeteilt.
   *
   * @param monitor - der ProgressMonitor
   * @see IBackgroundEvaluationListener
   * @sse {@link AbstractJob#run0(IProgressMonitor)}
   */
  @Override
  @SuppressWarnings("NP") // Rueckgabe von non-null Wert wird über Methoden-Contract geregelt
  protected IStatus run0(final IProgressMonitor monitor) throws Exception {
    monitor.subTask("Waiting for connection");
    acquireLock();

    ensureConnected(fConnection);
    callPrepare(fForms.size() > 1);

    monitor.beginTask(fJobName, (fForms.size() + 1) * 1000);

    if (monitor.isCanceled()) {
      return Status.CANCEL_STATUS;
    }

    for (int i = 0, n = fForms.size(); i < n; i++) {

      PackageBoundForm form = fForms.get(i);
      monitor.subTask("Starting evaluation " + i + "/" + fForms.size());
      IEvaluation eval = fConnection.getEvaluation();

      eval.evalStart(form.getPackage(), form.getForm());

      // Output Lesen
      readAllOutput(monitor);

      monitor.subTask("Reading result");
      IResult evalResult = eval.evalResult();

      boolean more = i != n - 1;
      IRestartSelection selection = callFormEvaluated(evalResult, more);

      monitor.worked(1000);

      if (evalResult.getTyp() == TResult.SUCCESS) { // Ergebnis ok
        continue; // alles ok mit ergebnis, mit naechstem weitermachen wenn vorhanden
      } else if (evalResult.getTyp()
          == TResult.READ_ERROR) { // Read error, es darf kein abort gesendet werden
        break;
      } else if (selection != null && selection.isAborted()) {
        abort(); // Ein Fehler, kann nur EVAL_ERROR sein, wurde abgebrochen
        break;
      } else { // EVAL_ERROR und es wurde ein Restart gewaehlt, bzw. war verfuegbar
        boolean abort = restart(monitor, selection, more); // eintritt rekursiver restart
        if (abort) { // restart abgebrochen
          abort(); // abort senden
          break; // und (bulk-)eval komplette beenden
        }
        continue; // restart war erfolgreich -> weiter mit naechstem im bulk
      }
    }

    return new Status(IStatus.OK, LispPluginActivator.ID, IStatus.OK, "Evaluation succeeded", null);
  }
Ejemplo n.º 3
0
 /**
  * evaluate with given customized Evaluation class
  *
  * @param evalMatrixs evaluation matrix
  * @param evalNames evaluation names
  * @param eval custom evaluator
  * @return eval information
  * @throws XGBoostError native error
  */
 public String evalSet(DMatrix[] evalMatrixs, String[] evalNames, IEvaluation eval)
     throws XGBoostError {
   String evalInfo = "";
   for (int i = 0; i < evalNames.length; i++) {
     String evalName = evalNames[i];
     DMatrix evalMat = evalMatrixs[i];
     float evalResult = eval.eval(predict(evalMat), evalMat);
     String evalMetric = eval.getMetric();
     evalInfo += String.format("\t%s-%s:%f", evalName, evalMetric, evalResult);
   }
   return evalInfo;
 }
  /**
   * Make an intelligent move given the board state, game logic, and player making the move.
   *
   * <p>If no move can be made (because the game is already DRAWN or the game has been won) then
   * null is returned. We can only look ahead 'ply' number of moves.
   *
   * @return the selected best move to make, or null if game is already won or drawn.
   */
  public IGameMove decideMove(IGameState gameState) {

    // nothing to do in these circumstances.
    if (gameState.isWin()) return null;
    if (gameState.isDraw()) return null;

    return algorithm.bestMove(gameState, this, opponent);
  }