Package rinde.sim.scenario

Examples of rinde.sim.scenario.ScenarioBuilder$ScenarioCreator


    VanLon14.generateDataSet(new File("files/dataset/"));
  }

  @Test
  public void testIO() {
    final ScenarioBuilder sb = new ScenarioBuilder(PDPScenarioEvent.ADD_DEPOT,
        PDPScenarioEvent.ADD_PARCEL, PDPScenarioEvent.ADD_VEHICLE,
        PDPScenarioEvent.TIME_OUT);

    sb.addEvent(new AddVehicleEvent(100, new VehicleDTO(new Point(7, 7), 7d, 2,
        new TimeWindow(0, 1000L))));
    sb.addEvent(new AddDepotEvent(76, new Point(3, 3)));
    sb.addEvent(new AddVehicleEvent(125, new VehicleDTO(new Point(6, 9), 3d, 1,
        new TimeWindow(500, 10000L))));
    sb.addEvent(new AddParcelEvent(ParcelDTO
        .builder(new Point(0, 0), new Point(1, 1))
        .pickupTimeWindow(new TimeWindow(2500, 10000))
        .deliveryTimeWindow(new TimeWindow(5000, 10000))
        .neededCapacity(0)
        .arrivalTime(2400)
        .pickupDuration(200)
        .deliveryDuration(800)
        .build()));
    sb.addEvent(new TimedEvent(PDPScenarioEvent.TIME_OUT, 200000));

    final VanLon14Scenario s = sb
        .build(new ScenarioCreator<VanLon14Scenario>() {
          @Override
          public VanLon14Scenario create(List<TimedEvent> eventList,
              Set<Enum<?>> eventTypes) {
            return new VanLon14Scenario(eventList, new TimeWindow(0, 10),
View Full Code Here


public class ScenarioIOTest {

  @Test
  public void test() {
    final ScenarioBuilder sb = new ScenarioBuilder(PDPScenarioEvent.ADD_DEPOT,
        PDPScenarioEvent.ADD_PARCEL, PDPScenarioEvent.ADD_VEHICLE,
        PDPScenarioEvent.TIME_OUT);

    sb.addEvent(new AddVehicleEvent(100, new VehicleDTO(new Point(7, 7), 7d, 2,
        new TimeWindow(0, 1000L))));
    sb.addEvent(new AddDepotEvent(76, new Point(3, 3)));
    sb.addEvent(new AddVehicleEvent(125, new VehicleDTO(new Point(6, 9), 3d, 1,
        new TimeWindow(500, 10000L))));
    sb.addEvent(new AddParcelEvent(new ParcelDTO(new Point(0, 0), new Point(1,
        1), new TimeWindow(2500, 10000), new TimeWindow(5000, 10000), 0, 2400,
        200, 800)));
    sb.addEvent(new TimedEvent(PDPScenarioEvent.TIME_OUT, 200000));

    final TestScenario s = sb.build(new ScenarioCreator<TestScenario>() {
      @Override
      public TestScenario create(List<TimedEvent> eventList,
          Set<Enum<?>> eventTypes) {
        return new TestScenario(eventList, new TimeWindow(0, 1000), 1000L, SI
            .MILLI(SI.SECOND), TestProblemClass.TEST);
View Full Code Here

  private static Gendreau06Scenario parse(
      ParcelsSupplier parcels,
      String fileName, int numVehicles, final long tickSize,
      final boolean allowDiversion, boolean online) {
    final ScenarioBuilder sb = new ScenarioBuilder(ADD_PARCEL, ADD_DEPOT,
        ADD_VEHICLE, TIME_OUT);

    final Matcher m = Pattern.compile(REGEX).matcher(fileName);
    checkArgument(m.matches(),
        "The filename must conform to the following regex: %s input was: %s",
        REGEX, fileName);

    final int instanceNumber = Integer.parseInt(m.group(1));
    final long minutes = Long.parseLong(m.group(2));
    final long totalTime = minutes * 60000L;
    final long requestsPerHour = Long.parseLong(m.group(3));

    final GendreauProblemClass problemClass = GendreauProblemClass.with(
        minutes, requestsPerHour);

    final int vehicles = numVehicles == -1 ? problemClass.vehicles
        : numVehicles;

    final Point depotPosition = new Point(2.0, 2.5);
    final double truckSpeed = 30;
    sb.addEvent(new AddDepotEvent(-1, depotPosition));
    for (int i = 0; i < vehicles; i++) {
      sb.addEvent(new AddVehicleEvent(-1, new VehicleDTO(depotPosition,
          truckSpeed, 0, new TimeWindow(0, totalTime))));
    }
    sb.addEvents(parcels.get(online));
    sb.addEvent(new TimedEvent(TIME_OUT, totalTime));

    return sb.build(new ScenarioCreator<Gendreau06Scenario>() {
      @Override
      public Gendreau06Scenario create(List<TimedEvent> eventList,
          Set<Enum<?>> eventTypes) {
        return new Gendreau06Scenario(eventList, eventTypes, tickSize,
            problemClass, instanceNumber, allowDiversion);
View Full Code Here

  private final static Gson gson = initialize();

  public static FabriRechtScenario parse(String coordinateFile,
      String ordersFile) throws IOException {
    final ScenarioBuilder sb = new ScenarioBuilder(PDPScenarioEvent.ADD_DEPOT,
        PDPScenarioEvent.ADD_PARCEL, PDPScenarioEvent.ADD_VEHICLE,
        PDPScenarioEvent.TIME_OUT);

    final BufferedReader coordinateFileReader = new BufferedReader(
        new FileReader(coordinateFile));
    final BufferedReader ordersFileReader = new BufferedReader(new FileReader(
        ordersFile));

    final List<Point> coordinates = newArrayList();
    String line;
    int coordinateCounter = 0;
    int minX = Integer.MAX_VALUE;
    int minY = Integer.MAX_VALUE;
    int maxX = Integer.MIN_VALUE;
    int maxY = Integer.MIN_VALUE;
    while ((line = coordinateFileReader.readLine()) != null) {
      final String[] parts = line.split(";");
      if (Integer.parseInt(parts[0]) != coordinateCounter) {
        throw new IllegalArgumentException(
            "The coordinate file seems to be in an unrecognized format.");
      }
      final int x = Integer.parseInt(parts[1]);
      final int y = Integer.parseInt(parts[2]);

      minX = Math.min(x, minX);
      minY = Math.min(y, minY);
      maxX = Math.max(x, maxX);
      maxY = Math.max(y, maxY);

      coordinates.add(new Point(x, y));
      if (Integer.parseInt(parts[0]) == 0) {
        sb.addEvent(new AddDepotEvent(0, new Point(x, y)));
      }
      coordinateCounter++;
    }
    coordinateFileReader.close();

    final Point min = new Point(minX, minY);
    final Point max = new Point(maxX, maxY);

    //
    // sb.addMultipleEvents(0, 10, PDPScenarioEvent.ADD_DEPOT);

    // Anzahl der Fahrzeuge; Kapazität; untere Zeitfenstergrenze; obere
    // Zeitfenstergrenze
    final String[] firstLine = ordersFileReader.readLine().split(";");
    final int numVehicles = Integer.parseInt(firstLine[0]);
    final int capacity = Integer.parseInt(firstLine[1]);
    final long startTime = Long.parseLong(firstLine[2]);
    final long endTime = Long.parseLong(firstLine[3]);
    final TimeWindow timeWindow = new TimeWindow(startTime, endTime);

    sb.addEvent(new TimedEvent(PDPScenarioEvent.TIME_OUT, endTime));

    // for (int i = 0; i < numVehicles; i++) {
    // sb.addEvent(new AddVehicleEvent(0, new VehicleDTO(coordinates.get(0),
    // 1.0, capacity, timeWindow)));
    // }
    final VehicleDTO defaultVehicle = new VehicleDTO(coordinates.get(0), 1.0,
        capacity, timeWindow);

    // Nr. des Pickup-Orts; Nr. des Delivery-Orts; untere Zeitfenstergrenze
    // Pickup; obere Zeitfenstergrenze Pickup; untere Zeitfenstergrenze
    // Delivery; obere Zeitfenstergrenze Delivery; benötigte Kapazität;
    // Anrufzeit; Servicezeit Pickup; Servicezeit Delivery
    while ((line = ordersFileReader.readLine()) != null) {
      final String[] parts = line.split(";");

      final int neededCapacity = 1; // Integer.parseInt(parts[6]);

      final ParcelDTO o = new ParcelDTO(coordinates.get(Integer
          .parseInt(parts[0])), coordinates.get(Integer.parseInt(parts[1])),
          new TimeWindow(Long.parseLong(parts[2]), Long.parseLong(parts[3])),
          new TimeWindow(Long.parseLong(parts[4]), Long.parseLong(parts[5])),
          neededCapacity, Long.parseLong(parts[7]), Long.parseLong(parts[8]),
          Long.parseLong(parts[9]));

      sb.addEvent(new AddParcelEvent(o));
    }
    ordersFileReader.close();

    return sb.build(new ScenarioCreator<FabriRechtScenario>() {
      @Override
      public FabriRechtScenario create(List<TimedEvent> eventList,
          Set<Enum<?>> eventTypes) {
        return new FabriRechtScenario(eventList, eventTypes, min, max,
            timeWindow, defaultVehicle);
View Full Code Here

        .generate(rng));
    final ImmutableList<Point> locations = locationsGenerator.generate(
        times.size(), rng);
    int index = 0;

    final ScenarioBuilder sb = new ScenarioBuilder(PDPScenarioEvent.ADD_DEPOT,
        PDPScenarioEvent.ADD_PARCEL, PDPScenarioEvent.ADD_VEHICLE,
        PDPScenarioEvent.TIME_OUT);
    sb.addEvent(new AddDepotEvent(-1, depotLocation));
    sb.addEvents(vehicleGenerator.generate(rng));

    for (final long time : times) {
      final Point pickup = locations.get(index++);
      final Point delivery = locations.get(index++);
      final ImmutableList<TimeWindow> tws = timeWindowGenerator.generate(time,
          pickup, delivery, rng);
      sb.addEvent(new AddParcelEvent(
          ParcelDTO.builder(pickup, delivery)
              .pickupTimeWindow(tws.get(0))
              .deliveryTimeWindow(tws.get(1))
              .neededCapacity(0)
              .arrivalTime(time)
              .serviceDuration(serviceTime)
              .build()));
    }
    sb.addEvent(new TimedEvent(PDPScenarioEvent.TIME_OUT, length));
    if (scenarioCreator != null) {
      return sb.build(new FactoryWrapper<T>(scenarioCreator, this, num));
    }
    else {
      return (T) sb.build();
    }
  }
View Full Code Here

    final Gendreau06Scenario gs = Gendreau06Parser
        .parser()
        .addFile(new ByteArrayInputStream("".getBytes()), "req_rapide_1_240_24")
        .setNumVehicles(numTrucks)
        .parse().get(0);
    final ScenarioBuilder sb = new ScenarioBuilder(gs.getPossibleEventTypes());
    sb.addEvents(gs.asList());
    sb.addEvents(parcels);
    return sb.build(new ScenarioCreator<Gendreau06Scenario>() {
      @Override
      public Gendreau06Scenario create(List<TimedEvent> eventList,
          Set<Enum<?>> eventTypes) {
        return GendreauTestUtil.create(eventList, eventTypes, 1000);
      }
View Full Code Here

TOP

Related Classes of rinde.sim.scenario.ScenarioBuilder$ScenarioCreator

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.