Esempio n. 1
0
        public void T24TaskMassImport()
        {
            var api = TestHelper.Authenticate();
            var user = TestHelper.GetOrCreateUser(api);
            var problem = TestHelper.CreateProblemWithDemoData(api, user);

            var capacity = new CapacityData {Name = "Weight", Amount = 20};

            var timeWindows = 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 importtaskset##
            var importRequest = new TaskSetImportRequest
            {
                Items = new List<TaskUpdateRequest>()
            };

            for (int i = 0; i < 10; i++)
            {
                var task = new TaskUpdateRequest {Name = "test name"};
                task.RelocationType = "None";
                task.ActivityState = "Active";

                var pickup = new TaskEventUpdateRequest
                {
                    Type = "Pickup",
                    Location = 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 ) } }
                };
                pickup.Capacities.Add(capacity);
                task.TaskEvents.Add(pickup);

                var delivery = new TaskEventUpdateRequest
                {
                    Type = "Delivery",
                    Location = new LocationData
                    {
                        Coordinate = new CoordinateData
                        {
                            Latitude = 62.244589,
                            Longitude = 25.74892,
                            System = "Euclidian"
                        }
                    },
                    TimeWindows = { new TimeWindowData { Start = new DateTime( 2013, 5, 14, 8, 0, 0 ), End = new DateTime( 2013, 5, 14, 12, 0, 0 ) } }
                };
                delivery.Capacities.Add(capacity);
                task.TaskEvents.Add(delivery);
                importRequest.Items.Add(task);
            }

            var result = api.Navigate<ResponseData>(problem.GetLink("import-tasks"), importRequest);
            //##END EXAMPLE##
        }
Esempio n. 2
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);
        }
Esempio n. 3
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##
        }
Esempio n. 4
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.
        }