Package rinde.sim.pdptw.gendreau06

Examples of rinde.sim.pdptw.gendreau06.Gendreau06Test


            .getResourceAsStream("/data/gendreau06/req_rapide_1_240_24"),
            "req_rapide_1_240_24")
        .allowDiversion()
        .parse().get(0);

    final Gendreau06ObjectiveFunction objFunc = new Gendreau06ObjectiveFunction();
    Experiment
        .build(objFunc)
        .withRandomSeed(123)
        .addConfiguration(new GradientFieldConfiguration())
        .addScenario(scenario)
View Full Code Here


    final RandomGenerator rng = new MersenneTwister(123);
    for (int i = 0; i < 5; i++) {
      final long seed = rng.nextLong();
      final DebugSolverCreator dsc = new DebugSolverCreator(seed,
          scenario.getTimeUnit());
      final Gendreau06ObjectiveFunction obj = new Gendreau06ObjectiveFunction();
      final ExperimentResults results = Experiment.build(obj)
          .addConfiguration(Central.solverConfiguration(dsc))
          .addScenario(scenario).perform();
      assertEquals(1, results.results.size());
      assertEquals(1, dsc.arraysSolver.getInputs().size());
      assertEquals(1, dsc.arraysSolver.getOutputs().size());

      final SolutionObject[] sols = dsc.arraysSolver.getOutputs().get(0);
      int objVal = 0;
      for (final SolutionObject sol : sols) {
        objVal += sol.objectiveValue;
      }

      // convert the objective values computed by the solver to the unit of the
      // gendreau benchmark (minutes).
      final UnitConverter converter = scenario.getTimeUnit().getConverterTo(
          NonSI.MINUTE);
      final double objValInMinutes = converter.convert(objVal);

      final GlobalStateObject solverInput = dsc.solver.getInputs().get(0);
      final ImmutableList<ImmutableList<ParcelDTO>> solverOutput = dsc.solver
          .getOutputs().get(0);

      assertEquals(obj.computeCost(results.results.get(0).stats),
          objValInMinutes, 0.2);

      final StatisticsDTO stats = Solvers.computeStats(solverInput,
          solverOutput);
      assertTrue(stats.toString(), obj.isValidResult(stats));
      assertEquals(objValInMinutes, obj.computeCost(stats), 0.1);
      assertEquals(objValInMinutes,
          decomposedCost(solverInput, solverOutput, obj), 0.01);
    }
  }
View Full Code Here

        .parse(new File("files/test/gendreau06/req_rapide_1_240_24"));

    final DebugSolverCreator dsc = new DebugSolverCreator(123,
        scenario.getTimeUnit());

    final Gendreau06ObjectiveFunction obj = new Gendreau06ObjectiveFunction();
    Experiment.build(obj).addConfiguration(Central.solverConfiguration(dsc))
        .addScenario(scenario).repeat(10).perform();

    final MVASDebugger arraysSolver = dsc.arraysSolver;
    final SolverDebugger solver = dsc.solver;

    final int n = solver.getInputs().size();
    assertEquals(n, arraysSolver.getInputs().size());
    assertEquals(n, solver.getOutputs().size());
    assertEquals(n, arraysSolver.getOutputs().size());

    for (int i = 0; i < n; i++) {
      final GlobalStateObject solverInput = solver.getInputs().get(i);

      final ImmutableList<ImmutableList<ParcelDTO>> solverOutput = solver
          .getOutputs().get(i);
      final SolutionObject[] sols = arraysSolver.getOutputs().get(i);
      final MVArraysObject arrInput = arraysSolver.getInputs().get(i);
      assertEquals(solverOutput.size(), sols.length);

      final double arrObjVal = ArraysSolvers.computeTotalObjectiveValue(sols)
          / MS_TO_MIN;
      final double arrOverTime = overTime(sols, arrInput) / MS_TO_MIN;
      final double arrTardiness = computeTardiness(sols, arrInput) / MS_TO_MIN;
      final double arrTravelTime = computeTravelTime(sols, arrInput)
          / MS_TO_MIN;

      final ExtendedStats stats = (ExtendedStats) Solvers.computeStats(
          solverInput, solverOutput);

      // check arrival times
      for (int j = 0; j < sols.length; j++) {
        final SolutionObject sol = sols[j];
        final long[] arraysArrivalTimes = incrArr(sol.arrivalTimes,
            solverInput.time);
        final long[] arrivalTimes = Longs.toArray(stats.arrivalTimes.get(j));
        assertArrayEquals(arraysArrivalTimes, arrivalTimes);
      }

      final double tardiness = obj.tardiness(stats) + obj.overTime(stats);
      final double travelTime = obj.travelTime(stats);

      assertEquals(arrOverTime, obj.overTime(stats), 0.001);
      assertEquals(arrTravelTime, travelTime, 0.01);
      assertEquals(arrTardiness, tardiness, 0.001);
      assertEquals(arrObjVal, obj.computeCost(stats), 0.01);
      assertEquals(arrObjVal,
          decomposedCost(solverInput, solverOutput, obj), 0.01);
    }
  }
View Full Code Here

        .add(ImmutableList.<ParcelDTO> of(a, b, c, c, b))
        .add(ImmutableList.<ParcelDTO> of(d, d))
        .build();

    final StatisticsDTO stats = Solvers.computeStats(state, routes);
    final ObjectiveFunction objFunc = new Gendreau06ObjectiveFunction();
    final double cost = objFunc.computeCost(stats);

    final double cost0 = objFunc.computeCost(Solvers.computeStats(
        state.withSingleVehicle(0),
        ImmutableList.of(routes.get(0))));
    final double cost1 = objFunc.computeCost(Solvers.computeStats(
        state.withSingleVehicle(1),
        ImmutableList.of(routes.get(1))));
    assertEquals(cost, cost0 + cost1, 0.001);
  }
View Full Code Here

            ArraysSolverValidator.wrap(new RandomMVArraysSolver(
                new MersenneTwister(seed))), scenario.getTimeUnit()));
      }
    };
    final Experiment.Builder builder = Experiment
        .build(new Gendreau06ObjectiveFunction()) //
        .addScenario(scenario) //
        .addConfiguration(Central.solverConfiguration(s)) //
        .withRandomSeed(123);

    final ExperimentResults res1 = builder.perform();
View Full Code Here

   * {@link rinde.sim.pdptw.central.arrays.MultiVehicleArraysSolver} interface.
   */
  @Test
  public void test() {
    Experiment
        .build(new Gendreau06ObjectiveFunction())
        .addScenario(
            scenario)
        .addConfiguration(
            Central.solverConfiguration(RandomMVArraysSolver.solverSupplier()))
        .repeat(3)
View Full Code Here

   * interface.
   */
  @Test
  public void testRandomSolver() {
    Experiment
        .build(new Gendreau06ObjectiveFunction())
        .addScenario(scenario)
        .addConfiguration(
            Central.solverConfiguration(SolverValidator.wrap(RandomSolver
                .supplier())))
        .repeat(6)
View Full Code Here

  public void test() {
    final Gendreau06Scenario scenario = Gendreau06Parser.parse(
        new File("files/test/gendreau06/req_rapide_1_240_24"));

    final Experiment.Builder builder = Experiment
        .build(new Gendreau06ObjectiveFunction())
        .addScenario(scenario)
        .addConfiguration(Central.solverConfiguration(RandomSolver.supplier()))
        .usePostProcessor(new TestPostProcessor())
        .withRandomSeed(123);
View Full Code Here

  public void multiThreadedOrder() {
    final Gendreau06Scenario scenario = Gendreau06Parser.parse(
        new File("files/test/gendreau06/req_rapide_1_240_24"));

    final Experiment.Builder builder = Experiment
        .build(new Gendreau06ObjectiveFunction())
        .addScenario(scenario)
        .addConfiguration(
            Central.solverConfiguration(RandomSolver.supplier(), "A"))
        .addConfiguration(
            Central.solverConfiguration(RandomSolver.supplier(), "B"))
View Full Code Here

        { false, true }, { true, true }, { true, false }, { false, false } });
  }

  @Before
  public void setUp() {
    final Gendreau06Parser parser = Gendreau06Parser.parser().addFile(
        "files/test/gendreau06/req_rapide_1_240_24");
    if (allowDiversion) {
      parser.allowDiversion();
    }
    if (offline) {
      parser.offline();
    }
    scenario = parser.parse().get(0);
  }
View Full Code Here

TOP

Related Classes of rinde.sim.pdptw.gendreau06.Gendreau06Test

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.