Exemple #1
0
        /// <summary>
        /// Gets violations.
        /// </summary>
        /// <param name="vrpResult">VRP solve operation result.</param>
        /// <returns>Founded violations.</returns>
        protected virtual List <Violation> GetViolations(VrpResult vrpResult)
        {
            Debug.Assert(null != vrpResult);

            var list = new List <Violation>();

            var conv = new VrpResultConverter(_context.Project, _schedule,
                                              _context.SolverSettings);

            var results = vrpResult.ResultObjects;

            int hr = vrpResult.SolveHR;

            if (ComHelper.IsHRSucceeded(hr) && vrpResult.ResultObjects != null)
            {
                list.AddRange(conv.GetOrderViolations(results.ViolatedStops, hr));
            }

            else if (hr == (int)NAError.E_NA_VRP_SOLVER_EMPTY_INFEASIBLE_ROUTES)
            {
                list.AddRange(conv.GetRouteViolations(results.Routes, hr));
            }

            else if (hr == (int)NAError.E_NA_VRP_SOLVER_NO_SOLUTION)
            {
                list.AddRange(conv.GetOrderViolations(results.ViolatedStops, hr));
            }

            else if (hr == (int)NAError.E_NA_VRP_SOLVER_PREASSIGNED_INFEASIBLE_ROUTES)
            {
                list.AddRange(conv.GetRouteViolations(results.Routes, hr));
                list.AddRange(conv.GetOrderViolations(results.ViolatedStops, hr));
            }
            else if (hr == (int)NAError.E_NA_VRP_SOLVER_INVALID_INPUT)
            {
                list.AddRange(conv.GetDepotViolations(results.ViolatedStops));
                list.AddRange(conv.GetRestrictedOrderViolations(results.ViolatedStops));
            }

            return(list);
        }