Package rinde.sim.pdptw.common

Examples of rinde.sim.pdptw.common.DynamicPDPTWProblem$DefaultUICreator


        .fromJson(new FileReader(
            "../problem/data/test/fabri-recht/lc101.scenario"), 8, 20);

    // instantiate the problem using the scenario and a random seed (which
    // will not be used in this example)
    final DynamicPDPTWProblem problem = new DynamicPDPTWProblem(scenario, 123);

    // we plug our custom vehicle in by specifying a creator
    problem.addCreator(AddVehicleEvent.class, new Creator<AddVehicleEvent>() {
      @Override
      public boolean create(Simulator sim, AddVehicleEvent event) {
        return sim.register(new Truck(event.vehicleDTO));
      }
    });

    // enable the default UI
    problem.enableUI();

    // start the simulation
    problem.simulate();

    // simulation is done, lets print the statistics!
    System.out.println(problem.getStatistics());
  }
View Full Code Here


      ConfigurationException {
    for (int i = 0; i < 100; i++) {
      final FabriRechtScenario scenario = FabriRechtParser.fromJson(
          new FileReader("files/test/fabri-recht/lc101.scenario"), 8, 20);

      final DynamicPDPTWProblem problem = new DynamicPDPTWProblem(scenario, 123);
      problem.addCreator(AddVehicleEvent.class, new Creator<AddVehicleEvent>() {
        @Override
        public boolean create(Simulator sim, AddVehicleEvent event) {
          return sim.register(new Truck(event.vehicleDTO));
        }
      });
      final int iteration = i;

      problem.enableUI(new DefaultUICreator(problem, 15) {
        @Override
        public void createUI(Simulator sim) {
          try {
            initRenderers();
            View.create(sim).with(renderers.toArray(new Renderer[] {}))
                .setSpeedUp(speedup).enableAutoClose().enableAutoPlay().show();
          } catch (final Throwable e) {
            System.err.println("Crash occured at iteration " + iteration);
            e.printStackTrace();
            throw new RuntimeException("This is the end, resistance is futile.");
          }
        }
      });
      problem.simulate();
    }
  }
View Full Code Here

    final Model<?>[] models = new Model<?>[modelSuppliers.size()];
    for (int i = 0; i < modelSuppliers.size(); i++) {
      models[i] = modelSuppliers.get(i).get(rng.nextLong());
    }

    final DynamicPDPTWProblem problem = new DynamicPDPTWProblem(scenario,
        simSeed, models);
    problem.addCreator(AddVehicleEvent.class, config.getVehicleCreator());
    if (config.getDepotCreator().isPresent()) {
      problem.addCreator(AddDepotEvent.class, config.getDepotCreator().get());
    }
    if (config.getParcelCreator().isPresent()) {
      problem.addCreator(AddParcelEvent.class, config.getParcelCreator().get());
    }
    if (showGui) {
      if (uic == null) {
        problem.addRendererToUI(new RouteRenderer());
        problem.enableUI();
      }
      else {
        problem.enableUI(uic);
      }
    }
    return problem;
  }
View Full Code Here

    }

    @Override
    public SimulationResult call() {
      try {
        final DynamicPDPTWProblem prob = init(scenario, configuration, seed,
            showGui, uiCreator);
        final StatisticsDTO stats = prob.simulate();

        @Nullable
        Object data = null;
        if (postProcessor != null) {
          data = postProcessor.collectResults(prob.getSimulator());
        }
        checkState(objectiveFunction.isValidResult(stats),
            "The simulation did not result in a valid result: %s.", stats);
        final SimulationResult result = new SimulationResult(stats, scenario,
            configuration, seed, data);
View Full Code Here

        new Point(x2, y2), new TimeWindow(tw1b, tw1e), new TimeWindow(tw2b,
            tw2e), 0, 0, 0, 0));
  }

  static StatisticsDTO runProblem(Gendreau06Scenario s, boolean useGui) {
    final DynamicPDPTWProblem problem = new DynamicPDPTWProblem(s, 123);
    if (useGui) {
      problem.enableUI(new TestUICreator(problem, 10));
    }
    problem.addCreator(AddVehicleEvent.class, new Creator<AddVehicleEvent>() {
      @Override
      public boolean create(Simulator sim, AddVehicleEvent event) {
        return sim.register(new SimpleTruck(event.vehicleDTO,
            new ClosestParcelStrategy()));
      }
    });
    problem.simulate();
    return problem.getStatistics();
  }
View Full Code Here

TOP

Related Classes of rinde.sim.pdptw.common.DynamicPDPTWProblem$DefaultUICreator

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.