Exemplo n.º 1
0
  public static void main(final String... args) throws Exception {
    final Config config =
        ConfigUtils.loadConfig(args[0], new SocialChoiceSetConstraintsConfigGroup());

    try (AutoCloseable monitor = MonitoringUtils.monitorAndLogOnClose();
        AutoCloseable logCloseable = MoreIOUtils.initOut(config);
        AutoCloseable gcTracker =
            MonitoringUtils.writeGCFigure(config.controler().getOutputDirectory() + "/gc.dat")) {
      final Scenario scenario = ScenarioUtils.loadScenario(config);
      final SocialChoiceSetConstraintsAnalyser analyser =
          new SocialChoiceSetConstraintsAnalyser(scenario);

      analyser.analyzeToFile(
          config.controler().getOutputDirectory() + "/constrainedChoiceSetSizes.dat");
    }
  }
Exemplo n.º 2
0
  public static void writeCodebook(final String filename, final Codebook codebook) {
    try (final BufferedWriter writer = IOUtils.getBufferedWriter(filename)) {
      MoreIOUtils.writeLines(
          writer,
          "Information",
          "===========",
          "This is metadata to dataset generated with:",
          "",
          "`" + getMainClassName() + "`",
          "",
          "Date: " + DateFormat.getDateInstance(DateFormat.FULL).format(new Date()),
          "",
          "",
          "Conversion to pdf: use [pandoc](http://pandoc.org/README.html)",
          "",
          "Command: `pandoc Codebook.md -o Codebook.pdf`",
          "",
          "Codebook",
          "========");

      for (Codebook.Codepage page : codebook.getPages().values()) {
        writer.write(page.getVariableName());
        writer.newLine();

        for (int i = 0; i < page.getVariableName().length(); i++) writer.write("-");
        writer.newLine();
        writer.newLine();

        // Probably not supernice, one should adapt column width to some extent.
        // on the other side, one can simply use pandoc to get a PDF version
        writer.write("| Code | Meaning | Count |");
        writer.newLine();
        writer.write("|------|---------|-------|");
        writer.newLine();
        for (Number code : page.getCodingToCount().keySet()) {
          writer.write("| " + code);
          writer.write(" | " + page.getCodingToMeaning().get(code));
          writer.write(" | " + page.getCodingToCount().get(code) + " |");
          writer.newLine();
        }
        writer.newLine();
      }
    } catch (IOException e) {
      throw new UncheckedIOException(e);
    }
  }