Package rinde.sim.pdptw.central.Solvers

Examples of rinde.sim.pdptw.central.Solvers.StateContext


    final TestSimAPI simAPI = new TestSimAPI(0, 1, NonSI.MINUTE);
    final SimulationConverter handle = Solvers.converterBuilder().with(mp)
        .with(simAPI).build();

    final StateContext sc = handle.convert(SolveArgs.create().useAllParcels()
        .noCurrentRoutes());
    assertEquals(ImmutableMap.of(v1.dto, v1), sc.vehicleMap);
    assertEquals(ImmutableMap.of(p1.dto, p1), sc.parcelMap);

    assertEquals(ImmutableSet.of(p1.dto), sc.state.availableParcels);
    checkVehicles(asList(v1), sc.state.vehicles);

    rm.moveTo(v1, p1, create(NonSI.HOUR, 0L, 1L));

    checkVehicles(
        asList(v1),
        handle.convert(SolveArgs.create().useAllParcels().noCurrentRoutes()).state.vehicles);

    rm.moveTo(v1, p1, create(NonSI.HOUR, 0, 40));
    assertTrue(rm.equalPosition(v1, p1));
    pm.service(v1, p1, create(NonSI.HOUR, 0, 1));

    assertEquals(VehicleState.PICKING_UP, pm.getVehicleState(v1));
    final StateContext sc2 = handle.convert(SolveArgs.create().useAllParcels()
        .noCurrentRoutes());

    assertTrue(sc2.state.availableParcels.contains(p1.dto));
    assertFalse(sc2.state.vehicles.get(0).contents.contains(p1.dto));
    assertSame(p1.dto, sc2.state.vehicles.get(0).destination);
View Full Code Here


    assertEquals(ParcelState.AVAILABLE, pm.getParcelState(p1));

    final SimulationConverter handle = Solvers.converterBuilder().with(mp)
        .with(simAPI).build();

    final StateContext sc = handle.convert(SolveArgs.create()
        .useParcels(ImmutableSet.<DefaultParcel> of())
        .noCurrentRoutes());
    assertEquals(1, sc.state.availableParcels.size());
    assertEquals(0, sc.state.vehicles.get(0).contents.size());
    final Solver solver = SolverValidator.wrap(new MultiVehicleSolverAdapter(
        new RandomMVArraysSolver(new MersenneTwister(123)), NonSI.MINUTE));
    Solvers.solverBuilder(solver).with(mp).with(simAPI).build().solve(sc);

    // give enough time to reach destination
    rm.moveTo(v1, destination, TimeLapseFactory.create(0, 1000000000));
    assertEquals(rm.getPosition(destination), rm.getPosition(v1));

    pm.pickup(v1, destination, TimeLapseFactory.create(0, 1));
    assertEquals(VehicleState.PICKING_UP, pm.getVehicleState(v1));

    final StateContext sc2 = handle.convert(SolveArgs.create()
        .useParcels(ImmutableSet.<DefaultParcel> of())
        .noCurrentRoutes());
    assertEquals(1, sc2.state.availableParcels.size());
    assertEquals(0, sc2.state.vehicles.get(0).contents.size());

    // finish pickup operation
    v1.tick(TimeLapseFactory.create(0, 1000000000));
    assertEquals(VehicleState.IDLE, pm.getVehicleState(v1));

    final StateContext sc3 = handle.convert(SolveArgs.create()
        .useParcels(ImmutableSet.<DefaultParcel> of())
        .noCurrentRoutes());
    assertTrue(sc3.state.availableParcels.isEmpty());
    assertEquals(1, sc3.state.vehicles.get(0).contents.size());

    // move to delivery location
    rm.moveTo(v1, destination, TimeLapseFactory.create(0, 1000));
    assertEquals(destination, rm.getDestinationToParcel(v1));
    assertEquals(ParcelState.IN_CARGO, pm.getParcelState(p1));

    final StateContext sc4 = handle.convert(SolveArgs.create()
        .useParcels(ImmutableSet.<DefaultParcel> of())
        .noCurrentRoutes());
    assertEquals(1, sc4.state.vehicles.get(0).contents.size());
    assertTrue(sc4.state.availableParcels.isEmpty());

    // service delivery
    rm.moveTo(v1, destination, TimeLapseFactory.create(0, 1000000000));
    assertEquals(destination.dto.destinationLocation, rm.getPosition(v1));
    pm.deliver(v1, p1, TimeLapseFactory.create(0, 1));
    assertNull(rm.getDestinationToParcel(v1));
    assertEquals(VehicleState.DELIVERING, pm.getVehicleState(v1));
    final StateContext sc5 = handle.convert(SolveArgs.create()
        .useParcels(ImmutableSet.<DefaultParcel> of())
        .noCurrentRoutes());
    assertEquals(1, sc5.state.vehicles.get(0).contents.size());
    assertTrue(sc5.state.availableParcels.isEmpty());

    // finish delivery operation
    v1.tick(TimeLapseFactory.create(0, 1000000000));
    assertEquals(VehicleState.IDLE, pm.getVehicleState(v1));

    final StateContext sc6 = handle.convert(SolveArgs.create()
        .useParcels(ImmutableSet.<DefaultParcel> of())
        .noCurrentRoutes());
    assertTrue(sc6.state.vehicles.get(0).contents.isEmpty());
    assertTrue(sc6.state.availableParcels.isEmpty());
  }
View Full Code Here

        new Point(0, 1), new Point(1, 1)).build());

    final DefaultVehicle vehicle = new TestVehicle(new Point(1, 1));
    final GlobalStateObject gso = mock(GlobalStateObject.class);

    final StateContext sc = new StateContext(gso,
        ImmutableMap.of(vehicle.getDTO(), vehicle),
        ImmutableMap.of(a.dto, a));

    boolean fail = false;
    try {
View Full Code Here

    final TestVehicle v2 = new TestVehicle(new Point(0, 1));
    PDPTWTestUtil.register(sim, p1, p2, p3, v1, v2);

    final SimulationConverter s = Solvers.converterBuilder().with(sim).build();

    StateContext res = s.convert(SolveArgs.create().useAllParcels()
        .noCurrentRoutes());
    assertEquals(2, res.state.vehicles.size());
    assertTrue(res.state.vehicles.get(0).contents.isEmpty());
    assertNull(res.state.vehicles.get(0).destination);
    assertEquals(3, res.state.availableParcels.size());
View Full Code Here

      sim.tick();
    }

    final SimulationConverter simConv = Solvers.converterBuilder().with(sim)
        .build();
    final StateContext sc = simConv.convert(SolveArgs.create()
        .noCurrentRoutes().useAllParcels());

    final ArraysObject singleVehicleArrays = ArraysSolvers
        .toSingleVehicleArrays(sc.state,
            SI.MILLI(SI.SECOND));
View Full Code Here

TOP

Related Classes of rinde.sim.pdptw.central.Solvers.StateContext

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.