Example #1
0
  @Path("/events/{eventName}/sessions")
  @GET
  public Response getSessionsForEvent(@PathParam("eventName") final String eventName) {
    IncogitoUri incogitoUri = new IncogitoUri(incogito.getConfiguration().baseurl);
    F<List<Session>, List<SessionXml>> sessionToXmlList =
        List.<Session, SessionXml>map_()
            .f(
                XmlFunctions.sessionToXml
                    .f(incogitoUri.restEvents().eventUri(eventName))
                    .f(incogitoUri.events().eventUri(eventName)));

    return toJsr311(
        incogito
            .getSessions(eventName)
            .ok()
            .map(compose(SessionListXml.sessionListXml, sessionToXmlList)));
  }
  public void performIteration(final TuningAlgorithm alg) {
    final List<Vector> parameterList = alg.getParameterList();

    // TODO: deal with maximisation problems
    results =
        results.snoc(
            parameterList.map(
                new F<Vector, OptimisationSolution>() {
                  @Override
                  public OptimisationSolution f(Vector a) {
                    return new OptimisationSolution(a, alg.evaluate(a));
                  }
                }));

    // (+1 because iterations start at 0)
    if (alg.getIterations() + 1 >= minProblems.getParameter() && parameterList.length() != 1) {
      List<List<Double>> data =
          results.map(
              List.<OptimisationSolution, Double>map_().f(getFitness().andThen(getValue())));
      P2<Double, Double> friedman = StatsTests.friedman(0.05, data);

      if (friedman._1() > friedman._2()) {
        final List<Integer> indexes = StatsTests.postHoc(0.05, friedman._1(), data);
        alg.setParameterList(indexes.map(flip(Utils.<Vector>index()).f(parameterList)));

        results =
            results.map(
                new F<List<OptimisationSolution>, List<OptimisationSolution>>() {
                  @Override
                  public List<OptimisationSolution> f(final List<OptimisationSolution> a) {
                    return indexes.map(flip(Utils.<OptimisationSolution>index()).f(a));
                  }
                });
      }
    }
  }