Exemplo n.º 1
0
        public static VehicleUpdateRequest GenerateVehicleUpdateRequestWithName(string name)
        {
            var request = new VehicleUpdateRequest
            {
                Name = name,
                RelocationType = "None",
                Capacities = new List<CapacityData>
                {
                    new CapacityData {Name = "Weight", Amount = 5000}
                },
                StartLocation = new LocationData
                {
                    Coordinate = new CoordinateData
                    {
                        Latitude = 62.244958,
                        Longitude = 25.747143,
                        System = "Euclidian"
                    }
                },
                EndLocation = new LocationData
                {
                    Address = new AddressData
                    {
                        City = "Jyväskylä",
                        Country = "Finland",
                        Street = "Poratie 2",
                        PostalCode = "40320"
                    }
                },
                TimeWindows =
                {
                    new TimeWindowData
                    {
                        Start = new DateTime(2013, 5, 14, 8, 0, 0),
                        End = new DateTime(2013, 5, 14, 12, 0, 0)
                    }
                }

            };

            return request;
        }
Exemplo n.º 2
0
        public void T22VehicleMassImport()
        {
            var api = TestHelper.Authenticate();
            var user = TestHelper.GetOrCreateUser(api);
            var problem = TestHelper.CreateProblemWithDemoData(api, user);
            //vehiclemassimport

            var vehicleCapacities = new List<CapacityData> {new CapacityData() {Name = "Weight", Amount = 100000}};

            var vehicleTimeWindow = new List<TimeWindowData>
            {
                new TimeWindowData
                {
                    Start = new DateTime(2013, 5, 14, 7, 0, 0),
                    End = new DateTime(2013, 5, 14, 16, 0, 0)
                }
            };

            var vehiclePickup = new LocationData()
            {
                Coordinate = new CoordinateData {Latitude = 62.244588, Longitude = 25.742683, System = "WGS84"}
            };
            var vehicleDelivery = new LocationData()
            {
                Coordinate = new CoordinateData {Latitude = 62.244588, Longitude = 25.742683, System = "WGS84"}
            };

            //##BEGIN EXAMPLE importvehicleset##
            var importRequest = new VehicleSetImportRequest
            {
                Items = new List<VehicleUpdateRequest>()
            };

            for (int i = 0; i < 10; i++)
            {
                var veh = new VehicleUpdateRequest()
                {
                    Name = "Vehicle name "+i,
                    Capacities = vehicleCapacities,
                    StartLocation = vehiclePickup,
                    EndLocation = vehicleDelivery,
                    TimeWindows = vehicleTimeWindow,
                    RelocationType = "None"
                };
                importRequest.Items.Add(veh);
            }

            var result = api.Navigate<ResponseData>(problem.GetLink("import-vehicles"), importRequest);
            var vehicles = api.Navigate<VehicleDataSet>( problem.GetLink( "list-vehicles" ) );
            //##END EXAMPLE##
        }
Exemplo n.º 3
0
        public void T07ListingVehiclesTest()
        {
            var api = TestHelper.Authenticate();
            var user = TestHelper.GetOrCreateUser(api);
            var problem = TestHelper.CreateProblemWithDemoData(api, user);

            var vehicle = new VehicleUpdateRequest
            {
                Name = "vehicle 2",
                RelocationType = "None",
                Capacities = new List<CapacityData>
                {
                    new CapacityData {Name = "Weight", Amount = 3500}
                },
                StartLocation = new LocationData
                {
                    Coordinate = new CoordinateData
                    {
                        Latitude = 61.244958,
                        Longitude = 20.747143,
                        System = "Euclidian"
                    }
                },
                EndLocation = new LocationData
                {
                    Coordinate = new CoordinateData
                    {
                        Latitude = 62.244958,
                        Longitude = 25.747143,
                        System = "Euclidian"
                    }
                },
                TimeWindows =
                {
                    new TimeWindowData
                    {
                        Start = new DateTime(2013, 5, 14, 8, 0, 0),
                        End = new DateTime(2013, 5, 14, 12, 0, 0)
                    }
                }

            };
            api.Navigate<ResponseData>(problem.GetLink("create-vehicle"), vehicle);
            //##BEGIN EXAMPLE listingvehicles##
            var vehicles = api.Navigate<VehicleDataSet>(problem.GetLink("list-vehicles"));
            //##END EXAMPLE##

            var mockVehicles = TestUtils.GetMockResponse<VehicleDataSet>(responses["listingvehiclesresp"].json);
            ResponseWriter.Write(JsonConvert.SerializeObject(vehicles, Formatting.Indented), "listingvehiclesresp", responsePath + "/listingvehiclesresp.dat");
            //TestUtils.VehicleDataSetsAreEqual(mockVehicles, vehicles);
        }
Exemplo n.º 4
0
        public void T20VehicleImportSpeedTest()
        {
            var api = TestHelper.Authenticate();
            var user = TestHelper.GetOrCreateUser(api);
            var problem = TestHelper.CreateProblemWithDemoData(api, user);

            var vehicleCapacities = new List<CapacityData> {new CapacityData() {Name = "Weight", Amount = 100000}};

            var vehicleTimeWindow = new List<TimeWindowData>
            {
                new TimeWindowData
                {
                    Start = new DateTime(2013, 5, 14, 7, 0, 0),
                    End = new DateTime(2013, 5, 14, 16, 0, 0)
                }
            };

            var vehiclePickup = new LocationData()
            {
                Coordinate = new CoordinateData {Latitude = 62.244588, Longitude = 25.742683, System = "WGS84"}
            };
            var vehicleDelivery = new LocationData()
            {
                Coordinate = new CoordinateData {Latitude = 62.244588, Longitude = 25.742683, System = "WGS84"}
            };
            var importRequest = new VehicleSetImportRequest
            {
                Items = new List<VehicleUpdateRequest>()
            };

            for (int i = 0; i < 10; i++)
            {
                var veh = new VehicleUpdateRequest()
                {
                    Name = "Vehicle" + i + 1,
                    Capacities = vehicleCapacities,
                    StartLocation = vehiclePickup,
                    EndLocation = vehicleDelivery,
                    TimeWindows = vehicleTimeWindow,
                    RelocationType = "None"
                };
                importRequest.Items.Add(veh);
            }

            Stopwatch timer = new Stopwatch();
            timer.Start();
            var result = api.Navigate<ResponseData>(problem.GetLink("import-vehicles"), importRequest);
            timer.Stop();
            Console.WriteLine("Time elapsed with set import: {0}", timer.Elapsed);



            var vehicleList = new List<VehicleUpdateRequest>();
            for (int i = 0; i < 10; i++)
            {
                var vehicleReq = new VehicleUpdateRequest()
                {
                    Name = "Car" + i + 1,
                    Capacities = vehicleCapacities,
                    StartLocation = vehiclePickup,
                    EndLocation = vehicleDelivery,
                    TimeWindows = vehicleTimeWindow,
                    RelocationType = "None"
                };
                vehicleList.Add(vehicleReq);
            }

            timer = new Stopwatch();
            timer.Start();
            foreach (var request in vehicleList)
            {
                api.Navigate<ResponseData>(problem.GetLink("create-vehicle"), request);
            }
            timer.Stop();
            Console.WriteLine("Time elapsed with 100 create operations: {0}", timer.Elapsed);
        }
Exemplo n.º 5
0
        private static void CreateDemoData( RoutingProblemData problem, Api api )
        {
            // To build a test case we first need to create a vehicle.
            // We start by defining vehicle capacity.
            var vehicleCapacities = new List<CapacityData> {new CapacityData {Name = "Weight", Amount = 100000}};
            // ...the time window(s)
            var vehicleTimeWindow = new List<TimeWindowData> { new TimeWindowData { Start = new DateTime( 2013, 5, 14, 7, 0, 0 ), End = new DateTime( 2013, 5, 14, 16, 0, 0 ) }};
            // ... the locations for pickup and delivery
            var vehiclePickup = new LocationData {Coordinate = new CoordinateData { Latitude = 62.244588, Longitude = 25.742683, System = "WGS84" }};
            var vehicleDelivery = new LocationData {Coordinate = new CoordinateData { Latitude = 62.244588, Longitude = 25.742683, System = "WGS84" }};
            // And then we wrap these into a single vehicle update request.
            var vehicleUpdateRequest = new VehicleUpdateRequest
                                           {
                                               Name = "Vehicle1",
                                               Capacities = vehicleCapacities,
                                               StartLocation = vehiclePickup,
                                               EndLocation = vehicleDelivery,
                                               TimeWindows = vehicleTimeWindow,
                                               RelocationType = "None"
                                           };


            api.Navigate<ResponseData>( problem.GetLink( "create-vehicle" ), vehicleUpdateRequest );
            // This should have created a vehicle.

            // Next, we will create a pickup and delivery task.
            // The task will consist of two task events that are the pickup and delivery.
            // Define the capacity, location and time window for the pickup.
            var capacity = new CapacityData { Name = "Weight", Amount = 1 };
            var task1PickupLocation = new LocationData
                                          {
                                              Coordinate = new CoordinateData
                                                               {
                                                                   Latitude = 62.247906,
                                                                   Longitude = 25.867395,
                                                                   System = "WGS84"
                                                               }
                                          };
            var task1PickupTimeWindows = new List<TimeWindowData> { new TimeWindowData { Start = new DateTime(2013, 5, 14, 7, 0, 0), End = new DateTime(2013, 5, 14, 16, 0, 0) } };
            //... and wrap it in a task event update request.
            var pickup = new TaskEventUpdateRequest
            {
                Type = "Pickup",
                Location = task1PickupLocation,
                TimeWindows = task1PickupTimeWindows,
                Capacities = new List<CapacityData> {capacity}
            };


            // Then we do the same for the delivery.
            var task1DeliveryLocation = new LocationData
                                            {
                                                Coordinate = new CoordinateData
                                                                 {
                                                                     Latitude = 61.386909,
                                                                     Longitude = 24.654106,
                                                                     System = "WGS84"
                                                                 }
                                            };
            var task1DeliveryTimeWindows = new List<TimeWindowData> { new TimeWindowData { Start = new DateTime(2013, 5, 14, 7, 0, 0), End = new DateTime(2013, 5, 14, 16, 0, 0) } };

            var delivery = new TaskEventUpdateRequest
            {
                Type = "Delivery",
                Location = task1DeliveryLocation,
                TimeWindows = task1DeliveryTimeWindows,
                Capacities = new List<CapacityData> { capacity }
            };


            // And finally we contain the pickup and delivery in a task update request and send it.
            var newTask = new TaskUpdateRequest {Name = "Task1", RelocationType = "None"};
            newTask.TaskEvents.Add( pickup );
            newTask.TaskEvents.Add( delivery );

            api.Navigate<ResponseData>( problem.GetLink( "create-task" ), newTask );

            // And this is how we can create optimization cases.
        }