/// <summary> /// Creates orders assigning operation result without solving. /// </summary> /// <param name="context">Solve operation context.</param> /// <param name="requestData">Solve operation request data.</param> /// <param name="violations">Violations found upon request building.</param> /// <returns>Result of the solve for the specified request.</returns> public static SolveResult CreateResultWithoutSolve( SolverContext context, SolveRequestData requestData, IEnumerable<Violation> violations) { foreach (var route in requestData.Routes) { context.Project.Schedules.ClearRouteResults(route); } return new SolveResult(null, violations.ToArray(), false); }
/////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////// public AssignOrdersStep2(SolverContext context, Schedule schedule, SolveRequestData reqData, AssignOrdersParams inputParams, IList<RouteResult> prevRouteResults, IList<Violation> prevViolations, SolveOptions options) : base(context, schedule, options) { _reqData = reqData; _inputParams = inputParams; _prevRouteResults = prevRouteResults; _prevViolations = prevViolations; }
public BuildRoutesOperation(SolverContext context, Schedule schedule, SolveOptions options, SolveRequestData reqData, List<Violation> violations, BuildRoutesParameters inputParams) : base(context, schedule, options) { Debug.Assert(reqData != null); Debug.Assert(violations != null); Debug.Assert(inputParams != null); _reqData = reqData; _violations = violations; _inputParams = inputParams; }
/////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////// private SolveRequestData _BuildRequestData() { List<Route> routes = new List<Route>(); List<Order> orders = new List<Order>(); // get unlocked routes from RoutesToSequence and all orders // assigned to converting routes foreach (Route route in _inputParams.RoutesToSequence) { if (route.Schedule.Equals(Schedule)) { if (!route.IsLocked) { routes.Add(route); orders.AddRange(SolveHelper.GetAssignedOrders(route)); } } else { // route does not have corresponding route results that // belongs to schedule throw new RouteException(String.Format( Properties.Messages.Error_InvalidRouteToSequence, route.Id)); } } // check if we have unlocked routes if (routes.Count == 0) throw new RouteException(Properties.Messages.Error_InvalidRoutesToSequenceCount); // get barriers planned on schedule's date ICollection<Barrier> barriers = SolverContext.Project.Barriers.Search( (DateTime)Schedule.PlannedDate); SolveRequestData reqData = new SolveRequestData(); reqData.Routes = routes; reqData.Orders = orders; reqData.Barriers = barriers; return reqData; }
protected override VrpOperation CreateOperation(SolveRequestData reqData, List<Violation> violations) { return new SequenceRoutesOperation(base.SolverContext, base.Schedule, _inputParams, base.Options, reqData, violations); }
/////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////// private SolveRequestData _BuildRequestData() { // exclude ungeocoded orders List<Order> orders = new List<Order>(); foreach (Order order in _inputParams.OrdersToAssign) { if (order.IsGeocoded) orders.Add(order); else { var violation = new Violation() { ViolationType = ViolationType.Ungeocoded, AssociatedObject = order }; _violations.Add(violation); } } // get barriers planned on schedule's date DateTime day = (DateTime)Schedule.PlannedDate; ICollection<Barrier> barriers = SolverContext.Project.Barriers.Search(day); SolveRequestData reqData = new SolveRequestData(); reqData.Routes = _inputParams.TargetRoutes; reqData.Orders = orders; reqData.Barriers = barriers; return reqData; }
protected override VrpOperation CreateOperation(SolveRequestData reqData, List<Violation> violations) { throw new NotSupportedException(); }
/////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// Method collect information from solve request data for planned date and build request /// object. /// </summary> /// <param name="schedule">Current schedule.</param> /// <param name="reqData">Request data to get information.</param> /// <param name="options">Request options.</param> /// <param name="solveOptions">The reference to to the solve options object.</param> /// <returns>Request object with filled information for request.</returns> /// <exception cref="RouteException">If Fuel Economy in some of routes is 0.0, /// If unassigned order or location is not geocoded.</exception> public SubmitVrpJobRequest BuildRequest(Schedule schedule, SolveRequestData reqData, SolveRequestOptions options, SolveOptions solveOptions) { Debug.Assert(schedule != null); Debug.Assert(reqData != null); Debug.Assert(options != null); Debug.Assert(solveOptions != null); _plannedDate = (DateTime)schedule.PlannedDate; _orderRevenue = Math.Min(_CalcMaxRoutesCost(reqData.Routes), MAX_REVENUE); _BuildDepotsColl(reqData.Routes); SubmitVrpJobRequest req = new SubmitVrpJobRequest(); // Get depots. req.Depots = _ConvertDepots(); // Get orders. req.Orders = _ConvertOrders(reqData.Orders, reqData.Routes, options.ConvertUnassignedOrders); // Get order pairs. req.OrderPairs = _ConvertOrderPairs(reqData.Orders); // Get routes. req.Routes = _ConvertRoutes(reqData.Routes); // Get route zones. var zoneInfo = _ConvertZones(reqData.Routes); req.RouteZones = zoneInfo.Zones; req.SpatiallyClusterRoutes = zoneInfo.UseSpatialClustering; // Get renewals. req.Renewals = _ConvertRenewals(reqData.Routes); // Get breaks. req.Breaks = ConvertBreaks(reqData.Routes); // Get barriers of all types. var typedBarriers = reqData.Barriers.ToLookup(BarriersConverter.DetermineBarrierType); req.PointBarriers = _ConvertBarriers(typedBarriers, BarrierGeometryType.Point, _context.NetworkDescription.NetworkAttributes); req.PolygonBarriers = _ConvertBarriers(typedBarriers, BarrierGeometryType.Polygon, _context.NetworkDescription.NetworkAttributes); req.LineBarriers = _ConvertBarriers(typedBarriers, BarrierGeometryType.Polyline, _context.NetworkDescription.NetworkAttributes); // Get network attribute parameters. req.NetworkParams = _ConvertNetworkParams(); // Get analysis region. req.AnalysisRegion = _context.RegionName; // Get restrictions. req.Restrictions = _FormatRestrictions(); // Get u-turn policy. req.UTurnPolicy = _GetUTurnPolicy(); req.Date = GPObjectHelper.DateTimeToGPDateTime(_plannedDate); req.UseHierarchyInAnalysis = true; req.PopulateRouteLines = false; req.EnvOutSR = solverSR.WKID; req.EnvProcessSR = solverSR.WKID; req.TWPreference = _context.SolverSettings.TWPreference; req.ExcludeRestrictedStreets = _context.SolverSettings.ExcludeRestrictedStreets; req.OutputFormat = NAOutputFormat.JSON; req.DirectionsLanguage = RequestBuildingHelper.GetDirectionsLanguage(); req.PopulateDirections = options.PopulateRouteLines; req.SaveOutputLayer = _context.SolverSettings.SaveOutputLayer; req.ReturnM = true; return req; }