public void printChildTopWords(int k, String childBetaFile) {
    try {
      System.out.println("child beta file");
      PrintWriter childBetaOut = new PrintWriter(new File(childBetaFile));

      for (int i = 0; i < m_childTopicTermProb.length; i++) {
        MyPriorityQueue<_RankItem> fVector = new MyPriorityQueue<_RankItem>(k);
        for (int j = 0; j < vocabulary_size; j++)
          fVector.add(new _RankItem(m_corpus.getFeature(j), m_childTopicTermProb[i][j]));

        childBetaOut.format("Topic %d(%.3f):\t", i, m_childSstat[i]);
        System.out.format("Topic %d(%.3f):\t", i, m_childSstat[i]);
        for (_RankItem it : fVector) {
          childBetaOut.format(
              "%s(%.3f)\t", it.m_name, m_logSpace ? Math.exp(it.m_value) : it.m_value);
          System.out.format(
              "%s(%.3f)\t", it.m_name, m_logSpace ? Math.exp(it.m_value) : it.m_value);
        }
        childBetaOut.println();
        System.out.println();
      }

      childBetaOut.flush();
      childBetaOut.close();
    } catch (Exception ex) {
      System.err.print("File Not Found");
    }
  }
Example #2
0
 public void print(PrintWriter out) {
   int x, y, z;
   for (z = size - 1; z >= 0; z--) {
     // print borders
     for (y = size - 1; y >= 0; y--) {
       out.print("    +");
       for (x = 0; x < size; x++) {
         out.print("---+");
       }
       out.println();
       // numbers
       out.format("%2d: |", y);
       // x's and o's
       for (x = 0; x < size; x++) {
         out.format(" %s |", isEmpty(x, y, z) ? " " : grid[x][y][z]);
       }
       out.println();
     }
     // bottom border
     out.print("    +");
     for (x = 0; x < size; x++) {
       out.print("---+");
     }
     out.println();
     // numbers on bottom
     out.print("     ");
     for (x = 0; x < size; x++) {
       out.format("%2d  ", x);
     }
     out.println();
   }
 }
Example #3
0
  @Override
  public void getInfo(PrintWriter pw) {
    pw.append(" CellDomainName   = ").println(getCellDomainName());
    pw.format(
        " I/O rcv=%d;asw=%d;frw=%d;rpy=%d;exc=%d\n",
        _packetsReceived, _packetsAnswered, _packetsForwarded, _packetsReplied, _exceptionCounter);
    long fm = _runtime.freeMemory();
    long tm = _runtime.totalMemory();

    pw.format(" Memory : tot=%d;free=%d;used=%d\n", tm, fm, tm - fm);
    pw.println(" Cells (Threads)");
    for (String name : _nucleus.getCellNames()) {
      pw.append(" ").append(name).append("(");
      Thread[] threads = _nucleus.getThreads(name);
      if (threads != null) {
        boolean first = true;
        for (Thread thread : threads) {
          pw.print(thread.getName());
          if (first) {
            first = false;
          } else {
            pw.print(",");
          }
        }
      }
      pw.println(")");
    }
  }
Example #4
0
  private void saveGizmo(IGizmo gizmo, String type) {
    String name = giveName(gizmo, type);
    fileOutput.format(GIZMO_FORMAT, type, name, gizmo.getX(), gizmo.getY());

    int orientation = gizmo.getOrientation();

    // right flippers are stored as left flippers rotated by one,
    // need to get rid of this before saving
    if (type.equals("RightFlipper")) orientation -= 1;

    for (int i = 0; i < orientation; i++) {
      fileOutput.format(ROTATE_FORMAT, name);
    }
  }
Example #5
0
 private void saveBoardConnections(Board board) {
   for (IGizmo gizmo : board.getGizmos()) {
     for (IBoardItem item : gizmo.getConnectedItems()) {
       fileOutput.format(CONNECT_FORMAT, getName(gizmo), getName(item));
     }
   }
 }
Example #6
0
  /**
   * Returns the unknown data as XML.
   *
   * @param elementName The element name
   * @return The unknown data as XML
   */
  public Element toXml(final String elementName) {
    Element element;
    StringWriter text;
    PrintWriter writer;

    element = XmlUtils.createElement(elementName);

    text = new StringWriter();
    writer = new PrintWriter(text);

    writer.println();
    writer.print("    ");
    for (int i = 0; i < this.bytes.length; i++) {
      if (i > 0) {
        if (i % 16 == 0) {
          writer.println();
        }
        if ((i < this.bytes.length) && (i % 4 == 0)) {
          writer.print("    ");
        } else {
          writer.print(" ");
        }
      }
      writer.format("%02x", new Object[] {this.bytes[i]});
    }
    writer.println();
    writer.print("  ");

    element.add(DocumentHelper.createText(text.toString()));

    return element;
  }
    private VisitorGeracaoCodigo geraInicializacaoVariaveisGlobais() throws ExcecaoVisitaASA {
      boolean excluiConstantes = true;
      List<NoDeclaracaoInicializavel> variaveisGlobais =
          getVariaveisGlobaisDeclaradas(asa, excluiConstantes);

      if (variaveisGlobais
          .isEmpty()) // não sobrescreve o método de inicialização se não houverem variáveis globais
      // que não são constantes
      {
        return this;
      }

      saida.append(Utils.geraIdentacao(nivelEscopo)).append("@Override").println();

      saida.append(Utils.geraIdentacao(nivelEscopo));
      saida
          .format("protected void inicializar() throws ErroExecucao, InterruptedException {")
          .println();

      inicializaVariaveisGlobaisNaoPassadasPorReferencia(variaveisGlobais);

      inicializaVariaveisGlobaisQueSaoPassadasPorReferencia();

      saida.append(Utils.geraIdentacao(nivelEscopo));
      saida.append("}").println();
      return this;
    }
Example #8
0
  private void otherAliases(
      AliasManager aliasManager, String thisAlias, String aliasClass, PrintWriter out)
      throws NoSuchAliasException {
    // NoSuchAliasException indicates a bug, and should be allowed to propagate.
    StringBuilder sb = new StringBuilder();

    for (String otherAlias : aliasManager.aliases()) {
      // exclude thisAlias from the output
      if (!otherAlias.equals(thisAlias)) {
        String otherAliasClass = aliasManager.getAliasClassName(otherAlias);
        // System.err.println("comparing '" + aliasClass + "' with '" + otherAliasClass + "'");
        if (aliasClass.equals(otherAliasClass)) {
          // we have found another alias for the same command
          if (sb.length() > 0) {
            sb.append(", ");
          }
          sb.append(otherAlias);
        }
      }
    }

    if (sb.length() > 0) {
      out.format(fmt_other_alias, sb);
    }
  }
  private static void benchmark(
      PrintWriter csvWriter,
      String dataName,
      String codecName,
      IntegerCODEC codec,
      int[][] data,
      int repeat) {
    PerformanceLogger logger = new PerformanceLogger();

    int maxLen = getMaxLen(data);
    int[] compressBuffer = new int[4 * maxLen + 1024];
    int[] decompressBuffer = new int[maxLen];

    for (int i = 0; i < repeat; ++i) {
      for (int[] array : data) {
        int compSize = compress(logger, codec, array, compressBuffer);
        int decompSize = decompress(logger, codec, compressBuffer, compSize, decompressBuffer);
        checkArray(array, decompressBuffer, decompSize, codec);
      }
    }

    if (csvWriter != null) {
      csvWriter.format(
          "\"%1$s\",\"%2$s\",%3$.2f,%4$.0f,%5$.0f\n",
          dataName,
          codecName,
          logger.getBitPerInt(),
          logger.getCompressSpeed(),
          logger.getDecompressSpeed());
    }
  }
    private void inicializaVariaveisGlobaisNaoPassadasPorReferencia(
        List<NoDeclaracaoInicializavel> variaveisGlobais) throws ExcecaoVisitaASA {
      for (NoDeclaracaoInicializavel variavel : variaveisGlobais) {
        if (variavel instanceof NoDeclaracaoVariavel) {
          if (((NoDeclaracaoVariavel) variavel).ehPassadaPorReferencia()) {
            continue; // variáveis globais que são passadas como referência não são declaradas como
            // atributo no código Java
          }
        }

        boolean ehVetor = variavel instanceof NoDeclaracaoVetor;
        boolean ehMatriz = variavel instanceof NoDeclaracaoMatriz;
        boolean variavelInicializada = variavel.temInicializacao();

        if (ehVetor || ehMatriz || variavelInicializada) {
          saida.append(Utils.geraIdentacao(nivelEscopo + 1));
          saida.format("%s = ", variavel.getNome());
          if (variavelInicializada) {
            variavel.getInicializacao().aceitar(this);
          } else // vetores e matrizes não inicializados precisam ser instanciados
          {
            if (ehVetor) {
              NoExpressao tamanho = ((NoDeclaracaoVetor) variavel).getTamanho();
              if (tamanho != null) {
                String nomeTipo = Utils.getNomeTipoJava(variavel.getTipoDado());
                saida.format("new %s[", nomeTipo);
                tamanho.aceitar(this);
                saida.append("]");
              }
            } else // é uma matriz
            {
              NoExpressao linhas = ((NoDeclaracaoMatriz) variavel).getNumeroLinhas();
              NoExpressao colunas = ((NoDeclaracaoMatriz) variavel).getNumeroColunas();
              if (linhas != null && colunas != null) {
                String nomeTipo = Utils.getNomeTipoJava(variavel.getTipoDado());
                saida.format("new %s[", nomeTipo);
                linhas.aceitar(this);
                saida.append("][");
                colunas.aceitar(this);
                saida.append("]");
              }
            }
          }
          saida.append(";").println();
        }
      }
    }
  public static void main(String[] args) throws IOException {

    Scanner sc = new Scanner(System.in);
    PrintWriter out = new PrintWriter(System.out);

    while (true) {
      String line = sc.next();
      if (line.equals("#")) break;
      StringTokenizer st = new StringTokenizer(line, ";");
      BitSet valid = new BitSet(26);
      adjList = new ArrayList[26];
      for (int i = 0; i < 26; ++i) adjList[i] = new ArrayList<Integer>();

      while (st.hasMoreTokens()) {
        String s = st.nextToken();
        int u = s.charAt(0) - 'A';
        valid.set(u);

        for (int j = 2; j < s.length(); ++j) {
          int v = s.charAt(j) - 'A';
          adjList[u].add(v);
          valid.set(v);
        }
      }
      V = valid.cardinality();
      int[] nodes = new int[V];
      for (int i = 0, j = 0; i < 26; ++i) if (valid.get(i)) nodes[j++] = i;
      Arrays.sort(nodes);
      int min = V;
      int[] ans = new int[V];
      do {
        int[] pos = new int[26];
        for (int i = 0; i < V; ++i) pos[nodes[i]] = i;
        int cur = 0;
        for (int u = 0; u < 26; ++u)
          for (int v : adjList[u]) cur = Math.max(cur, Math.abs(pos[u] - pos[v]));
        if (cur < min) {
          min = cur;
          ans = Arrays.copyOf(nodes, V);
        }
      } while (nextPermutation(nodes));
      for (int u : ans) out.format("%c ", (char) (u + 'A'));
      out.format("-> %d\n", min);
    }
    out.flush();
    out.close();
  }
Example #12
0
 public void render(Object obj, RenderContext context, PrintWriter writer) {
   RiotImage image = (RiotImage) obj;
   if (image != null) {
     writer.format(
         "<img src=\"%s\" width=\"%s\" height=\"%s\" />",
         context.getContextPath() + image.getUri(), image.getWidth(), image.getHeight());
   }
 }
Example #13
0
 public void dump(String[] busname, PrintWriter pw) {
   pw.println("ElimBus,EBNdx,Bself1,ElimFarBus,FBNdx,Bself2,Btrans/Bself");
   int n = _p.length;
   for (int i = 0; i < n; ++i) {
     int p = _p[i], q = _q[i];
     pw.format(
         "'%s',%d,%f,'%s',%d,%f,%f\n", busname[p], p, _bd[p], busname[q], q, _bd[q], _adjbo[i]);
   }
 }
Example #14
0
 private void saveBalls(Board board) {
   List<Ball> balls = board.getBalls();
   for (Ball ball : balls) {
     fileOutput.format(
         BALL_FORMAT,
         giveName(ball),
         ball.getX(),
         ball.getY(),
         ball.getXVelocity(),
         ball.getYVelocity());
   }
 }
Example #15
0
 void serialize(PrintWriter out) {
   Cave3DVector dp = p2.minus(p1);
   out.format(
       "S %d %d %d %d %d %.3f %.3f %.3f\n",
       mCnt,
       p1.mCnt,
       p2.mCnt,
       ((t1 == null) ? "-1" : t1.mCnt),
       ((t2 == null) ? "-1" : t2.mCnt),
       dp.x,
       dp.y,
       dp.z);
 }
Example #16
0
  @Override
  public void execute() throws Exception {
    PrintWriter out = getOutput().getPrintWriter();
    if (argLanguage.isSet()) {
      final String language = argLanguage.getValue();

      String country = (argCountry.isSet()) ? argCountry.getValue() : "";
      String variant = (argVariant.isSet()) ? argVariant.getValue() : "";

      Locale locale = findLocale(language, country, variant);
      if (locale == null) {
        getError().getPrintWriter().format(err_no_locale, language, country, variant);
        exit(1);
      }
      out.format(fmt_set, formatLocale(locale));
      Locale.setDefault(locale);
    } else if (argList.isSet()) {
      listLocales(out);
    } else {
      out.format(fmt_get, formatLocale(Locale.getDefault()));
    }
  }
  static RainbowTable generateRainbowTable() throws NoSuchAlgorithmException {
    final long bitmask = Utilities.bit20;
    long u = 1;
    long length = (long) Math.pow(2, 8);
    long rows = (long) Math.pow(2, 16);
    RainbowTable rainbow = new RainbowTable(u, rows, length, bitmask);
    HashMap<Long, Long> Definition_Map = new HashMap<Long, Long>();
    String filename = "ex17.data";
    try {
      outfile = new PrintWriter(new FileWriter(filename));
    } catch (IOException ex) {

      Logger.getLogger(Worksheet_17.class.getName()).log(Level.SEVERE, null, ex);
    }

    long collisions = 0;
    long start = System.currentTimeMillis();
    rainbow.rows = rows;
    rainbow.chainLength = length;

    long lastTime = System.currentTimeMillis();
    for (int i = 0; i < rows; i++) {
      long startValue = ran.nextInt() % bitmask;
      long accumulator = startValue;

      // Making a chain.
      for (int j = 0; j < length; j++) {
        long cipher = Utilities.MD5_Hash(accumulator, bitmask);

        long reducedCipher = Utilities.reductionFunction(cipher, j, bitmask + 1);
        accumulator = reducedCipher;
        if (!Definition_Map.containsKey(reducedCipher)) {
          Definition_Map.put(reducedCipher, 0L);
        }
      }

      rainbow.put(accumulator, startValue);

      System.out.println("Added an element");
      double coverage = ((double) Definition_Map.size()) / Math.pow(2, 20);
      double end = (System.currentTimeMillis() - start) / 1000.0;

      System.out.format("%d %f %.8f %d \n", Definition_Map.size(), end, coverage, collisions);
      outfile.format("%f %.4f %d \n", end, coverage, collisions);
    }

    long currentTime = System.currentTimeMillis();
    System.out.println("Generated the table in: " + (currentTime - lastTime) / 1000);
    outfile.close();
    return rainbow;
  }
  private void writeReport(String test, String name, DescriptiveStatistics statistics)
      throws IOException {
    File report = new File("target", test + ".txt");

    boolean needsPrefix = !report.exists();
    PrintWriter writer = new PrintWriter(new FileWriterWithEncoding(report, "UTF-8", true));
    try {
      if (needsPrefix) {
        writer.format("# %-34.34s     min     10%%     50%%     90%%     max%n", test);
      }

      writer.format(
          "%-36.36s  %6.0f  %6.0f  %6.0f  %6.0f  %6.0f%n",
          name,
          statistics.getMin(),
          statistics.getPercentile(10.0),
          statistics.getPercentile(50.0),
          statistics.getPercentile(90.0),
          statistics.getMax());
    } finally {
      writer.close();
    }
  }
Example #19
0
 @Override
 public void execute() throws NameNotFoundException, ShellException, HelpException {
   // The above exceptions are either bugs or configuration errors and should be allowed
   // to propagate so that the shell can diagnose them appropriately.
   String alias;
   CommandLine commandLine = getCommandLine();
   PrintWriter out = getOutput().getPrintWriter();
   PrintWriter err = getError().getPrintWriter();
   if (argAlias.isSet()) {
     alias = argAlias.getValue();
   } else if (commandLine.getCommandName() != null) {
     alias = commandLine.getCommandName();
   } else {
     alias = "help";
   }
   CommandShell shell = null;
   try {
     shell = (CommandShell) ShellUtils.getShellManager().getCurrentShell();
     CommandInfo cmdInfo = shell.getCommandInfo(alias);
     Help cmdHelp = HelpFactory.getHelpFactory().getHelp(alias, cmdInfo);
     if (cmdHelp == null) {
       err.format(err_no_help, alias);
       exit(1);
     }
     cmdHelp.help(out);
     otherAliases(shell.getAliasManager(), alias, cmdInfo.getCommandClass().getName(), out);
   } catch (HelpException ex) {
     err.format(err_help_ex, alias, ex.getLocalizedMessage());
     throw ex;
   } catch (ShellException ex) {
     err.println(ex.getMessage());
     throw ex;
   } catch (SecurityException ex) {
     err.format(err_sec_ex, alias, ex.getLocalizedMessage());
     throw ex;
   }
 }
 private void inicializaVariaveisGlobaisQueSaoPassadasPorReferencia() throws ExcecaoVisitaASA {
   List<NoDeclaracao> declaracoes = asa.getListaDeclaracoesGlobais();
   for (NoDeclaracao declaracao : declaracoes) {
     if (declaracao instanceof NoDeclaracaoVariavel) {
       NoDeclaracaoVariavel variavel = (NoDeclaracaoVariavel) declaracao;
       if (variavel.ehPassadaPorReferencia() && variavel.temInicializacao()) {
         String nomeTipo = Utils.getNomeTipoJava(variavel.getTipoDado());
         saida.append(Utils.geraIdentacao(nivelEscopo));
         saida.format(
             "REFS_%s[%s] = ", nomeTipo.toUpperCase(), Utils.geraStringIndice(variavel));
         variavel.getInicializacao().aceitar(this);
         saida.append(";").println(); // o ponto e vírgula depois da inicialização
       }
     }
   }
 }
Example #21
0
  @Override
  public void doPost(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    response.setContentType("text/html");

    String param = request.getParameter("vector");
    if (param == null) param = "";

    String bar = new Test().doSomething(param);

    Object[] obj = {"a", bar};
    java.io.PrintWriter out = response.getWriter();
    out.write("<!DOCTYPE html>\n<html>\n<body>\n<p>");
    out.format(java.util.Locale.US, "Formatted like: %1$s and %2$s.", obj);
    out.write("\n</p>\n</body>\n</html>");
  } // end doPost
Example #22
0
  private static void printRow(PrintWriter out, int row) throws UselessException {
    out.println("#");
    out.println("# This is a table for transliterating characters.");
    out.println("# It was created using icu4j");
    out.println("#");
    out.println("# All resulting strings that contained characters outside the");
    out.println("# range of iso 8859-1 are commented out");
    out.println("#");
    out.println();

    int count = 0;
    for (int i = 0; i < 256; i++) {
      char c = (char) ((row << 8) + i);
      String single = "" + c;
      String result = trans.transliterate(single);

      if (result.length() == 1 && result.charAt(0) == c) result = "?";
      else count++;

      boolean inRange = true;
      for (char rc : result.toCharArray()) {
        if (rc > 0xff) {
          // System.out.printf("out of range result %c for row %d\n", rc, row);
          inRange = false;
          break;
        }
      }

      if (!inRange) {
        count--;
        out.print("#");
      }

      out.format("U+%02x%02x %-12.12s # Character %s", row, i, result, single);

      // if (!inRange) {
      //	String s = decomposed.transliterate(single);
      //	out.format(", %s", s);
      //	for (char rc : s.toCharArray()) {
      //		out.format(" %04x", (int) rc);
      //	}
      // }
      out.println();
    }

    if (count == 0) throw new UselessException();
  }
  @Provides
  static ImmutableSet<Instrument> provideInstruments(
      CaliperOptions options,
      final CaliperConfig config,
      Map<Class<? extends Instrument>, Provider<Instrument>> availableInstruments,
      Platform platform,
      @Stderr PrintWriter stderr)
      throws InvalidCommandException {

    ImmutableSet.Builder<Instrument> builder = ImmutableSet.builder();
    ImmutableSet<String> configuredInstruments = config.getConfiguredInstruments();
    for (final String instrumentName : options.instrumentNames()) {
      if (!configuredInstruments.contains(instrumentName)) {
        throw new InvalidCommandException(
            "%s is not a configured instrument (%s). "
                + "use --print-config to see the configured instruments.",
            instrumentName, configuredInstruments);
      }
      final InstrumentConfig instrumentConfig = config.getInstrumentConfig(instrumentName);
      String className = instrumentConfig.className();
      try {
        Class<? extends Instrument> clazz =
            Util.lenientClassForName(className).asSubclass(Instrument.class);
        Provider<Instrument> instrumentProvider = availableInstruments.get(clazz);
        if (instrumentProvider == null) {
          throw new InvalidInstrumentException("Instrument %s not supported", className);
        }

        // Make sure that the instrument is supported on the platform.
        if (platform.supports(clazz)) {
          Instrument instrument = instrumentProvider.get();
          InstrumentInjectorModule injectorModule =
              new InstrumentInjectorModule(instrumentConfig, instrumentName);
          InstrumentComponent instrumentComponent =
              DaggerInstrumentComponent.builder().instrumentInjectorModule(injectorModule).build();
          instrumentComponent.injectInstrument(instrument);
          builder.add(instrument);
        } else {
          stderr.format(
              "Instrument %s not supported on %s, ignoring\n", className, platform.name());
        }
      } catch (ClassNotFoundException e) {
        throw new InvalidCommandException("Cannot find instrument class '%s'", className);
      }
    }
    return builder.build();
  }
Example #24
0
  // THE TRIALS
  public static void rpsTrials(PrintWriter out, int n, int k) {
    // array to store # of hulls for each k
    int[] hulls = new int[k];
    // array to store runtime of rps construction
    // double[] runtimeRPS= new double[k];
    // array to store runtime of hull finding
    // double[] runtimeCHulls= new double[k];
    // array runtime all
    double[] runtimeAll = new double[k];

    for (int i = 0; i < k; i++) {

      long startTime = System.currentTimeMillis();
      RandomPointset rps = new RandomPointset(n);
      // long endTime= System.currentTimeMillis();
      // runtimeRPS[i]= (double)(endTime-startTime);

      // startTime= System.currentTimeMillis();
      hulls[i] = rps.findConvexHulls();
      long endTime = System.currentTimeMillis();
      // runtimeCHulls[i]= (double)(endTime-startTime);
      runtimeAll[i] = (double) (endTime - startTime);
    }
    double meanhulls = find_mean(hulls, k);
    double stddevhulls = std_dev(hulls, k, meanhulls);
    double meanruntime = find_mean(runtimeAll, k);

    // Output findings
    out.format("%4d\t%10f\t%10f\t%10.3f%n", n, meanhulls, stddevhulls, meanruntime);

    /*
    System.out.println("Mean # of SHELLS for n="+n +": "+ mean );
    System.out.println("std_dev of SHELLS for n="+n +": "+ stddev );

    double runtimeRPSmean= find_mean(runtimeRPS, k);
    double runtimeRPSsd= std_dev(runtimeRPS, k, runtimeRPSmean);
    System.out.println("Mean # of SHELLS for n="+n +": "+ runtimeRPSmean );
    System.out.println("std_dev of SHELLS for n="+n +": "+ runtimeRPSsd );

    double runtimeCHmean= find_mean(runtimeCHulls, k);
    double runtimeCHsd= std_dev(runtimeCHulls, k, runtimeCHmean);
    System.out.println("Mean # of SHELLS for n="+n +": "+ runtimeCHmean );
    System.out.println("std_dev of SHELLS for n="+n +": "+ runtimeCHsd );
    */

  }
  private synchronized void writeLog(String logDir, int refID, String msg, Object... args) {
    if (!Utility.isNullOrEmpty(logDir)) {
      try {
        new File(logDir).mkdirs();
      } catch (Exception e) {
        System.out.println(e);
      }
      File logFileClass = new File(logDir, String.valueOf(refID) + ".txt");
      logfile = logFileClass.toString();

      try {
        PrintWriter writer = new PrintWriter(new FileWriter(logFileClass, true));
        writer.format(msg, args);
        writer.println();
        writer.close();
      } catch (IOException e) {
        throw new RuntimeException(e);
      }
    }
  }
 public void OnExiting(Sender sender, SOAEventArg soaEventArg) {
   String onAzureEnv = System.getenv("CCP_OnAzure");
   if (!Utility.isNullOrEmpty(onAzureEnv) && !onAzureEnv.equals("1")) {
     PrintWriter writer = null;
     try {
       writer = new PrintWriter(new FileWriter(logFile, true));
     } catch (Exception e) {
       throw new RuntimeException(e);
     }
     String envs =
         String.format(
             "%s.%s.%s",
             System.getenv(EnvVarNames.CCP_JOBID),
             System.getenv(EnvVarNames.CCP_TASKID),
             System.getenv(EnvVarNames.CCP_TASKINSTANCEID));
     writer.format("[Exit] %s%%%s%%GracefulExitEvent called.%n", Utility.getCurrentTime(), envs);
     writer.close();
   }
   System.out.format("[Exit] %s: GracefulExitEvent called.%n", Utility.getCurrentTime());
   return;
 }
    @Override
    public Void visitar(NoReferenciaVariavel no) throws ExcecaoVisitaASA {
      String nome = no.getNome();
      if (no.getEscopo() != null) {
        saida.append(no.getEscopo()).append(".");
      }

      NoDeclaracao declaracao = no.getOrigemDaReferencia();
      boolean ehParametroPorReferencia =
          declaracao instanceof NoDeclaracaoParametro
              && (((NoDeclaracaoParametro) declaracao).getModoAcesso()
                  == ModoAcesso.POR_REFERENCIA);
      if (ehParametroPorReferencia || no.ehPassadoPorReferencia()) {
        String stringIndice = ehParametroPorReferencia ? no.getNome() : Utils.geraStringIndice(no);
        String nomeTipo = Utils.getNomeTipoJava(declaracao.getTipoDado()).toUpperCase();
        saida.format("REFS_%s[%s]", nomeTipo, stringIndice);
      } else {
        saida.append(nome);
      }

      return null;
    }
  /**
   * Run benchmark.
   *
   * @param csvWriter Write for results in CSV.
   * @param count Count of data chunks.
   * @param length Length of a data chunk.
   */
  public static void run(final PrintWriter csvWriter, final int count, final int length) {
    IntegerCODEC[] codecs = {
      new JustCopy(),
      new BinaryPacking(),
      new DeltaZigzagBinaryPacking(),
      new DeltaZigzagVariableByte(),
      new IntegratedBinaryPacking(),
      new XorBinaryPacking(),
      new FastPFOR(),
    };

    csvWriter.format(
        "\"Dataset\",\"CODEC\",\"Bits per int\","
            + "\"Compress speed (MiS)\",\"Decompress speed (MiS)\"\n");

    benchmark(csvWriter, codecs, count, length, DEFAULT_MEAN, DEFAULT_RANGE);
    benchmark(csvWriter, codecs, count, length, DEFAULT_MEAN >> 5, DEFAULT_RANGE);

    IntegerCODEC[] codecs2 = {
      new JustCopy(),
      new BinaryPacking(),
      new DeltaZigzagBinaryPacking(),
      new DeltaZigzagVariableByte(),
      new IntegratedBinaryPacking(),
      new XorBinaryPacking(),
      new FastPFOR(),
    };

    int freq = length / 4;
    benchmarkSine(csvWriter, codecs2, count, length, DEFAULT_MEAN >> 0, DEFAULT_RANGE >> 0, freq);
    benchmarkSine(csvWriter, codecs2, count, length, DEFAULT_MEAN >> 5, DEFAULT_RANGE >> 0, freq);
    benchmarkSine(csvWriter, codecs2, count, length, DEFAULT_MEAN >> 10, DEFAULT_RANGE >> 0, freq);
    benchmarkSine(csvWriter, codecs2, count, length, DEFAULT_MEAN >> 0, DEFAULT_RANGE >> 2, freq);
    benchmarkSine(csvWriter, codecs2, count, length, DEFAULT_MEAN >> 5, DEFAULT_RANGE >> 2, freq);
    benchmarkSine(csvWriter, codecs2, count, length, DEFAULT_MEAN >> 10, DEFAULT_RANGE >> 2, freq);
    benchmarkSine(csvWriter, codecs2, count, length, DEFAULT_MEAN >> 0, DEFAULT_RANGE >> 4, freq);
    benchmarkSine(csvWriter, codecs2, count, length, DEFAULT_MEAN >> 5, DEFAULT_RANGE >> 4, freq);
    benchmarkSine(csvWriter, codecs2, count, length, DEFAULT_MEAN >> 10, DEFAULT_RANGE >> 4, freq);
  }
 private void solve() throws Exception {
   double a = readNumber();
   double b = readNumber();
   int k = (int) readNumber();
   double res = 0;
   int x = 0;
   int y = 0;
   double temp;
   for (int x1 = 0; x1 <= k; x1++) {
     for (int y1 = 0; y1 <= k - x1; y1++) {
       if ((temp = f(a, b, x1, y1)) > res) {
         res = temp;
         x = x1;
         y = y1;
       }
     }
   }
   out.format(Locale.US, "%.2f", res);
   out.println();
   out.print(x);
   out.print(' ');
   out.println(y);
 }
Example #30
0
 public PrintWriter format(final String format, final Object... args) {
   return out.format(format, args);
 }