コード例 #1
0
        private void _InitAttrParameters(SolveInfoWrap settings)
        {
            Debug.Assert(settings != null);

            foreach (RouteAttrInfo attr in settings.AttrParameters)
            {
                bool isValid = false;

                // check if attribute settings are valid
                if (!String.IsNullOrEmpty(attr.AttrName) &&
                    !String.IsNullOrEmpty(attr.ParamName) &&
                    attr.Value != null)
                {
                    // find parameter in network description
                    NetworkAttributeParameter param = null;
                    if (_FindParamInNetworkDesc(attr.AttrName, attr.ParamName, out param))
                    {
                        // check if parameter value is valid
                        if (_IsParamValueValid(attr.Value, param.Type))
                        {
                            isValid = true;
                        }
                    }
                }

                if (!isValid)
                {
                    Logger.Warning(String.Format(LOG_INVALID_NETWORK_ATTR,
                                                 attr.AttrName,
                                                 attr.ParamName));
                }
            }
        }
コード例 #2
0
 /// <summary>
 /// Method provides initialization of Curb approach policies.
 /// </summary>
 /// <param name="settings">Settings.</param>
 private void _InitCurbApproachPolicies(SolveInfoWrap settings)
 {
     // Validate settings for Curb Approach policies.
     if (settings.UTurnAtStops)
     {
         settings.StopOnOrderSide = true;
     }
 }
コード例 #3
0
 /// <summary>
 /// Method provides initialization of U-Turn policies.
 /// </summary>
 /// <param name="settings">Settings.</param>
 private void _InitUTurnPolicies(SolveInfoWrap settings)
 {
     // Validate settings for U-Turn policies.
     if (settings.UTurnAtIntersections)
     {
         settings.UTurnAtDeadEnds = true;
     }
 }
コード例 #4
0
        ///////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////

        private void _InitRestrictions(SolveInfoWrap settings,
                                       NetworkDescription netDesc)
        {
            Debug.Assert(settings != null);
            Debug.Assert(netDesc != null);

            Dictionary <string, Restriction> restrictions = new Dictionary <
                string, Restriction>();

            // add all available restrictions with default data
            foreach (NetworkAttribute attr in netDesc.NetworkAttributes)
            {
                if (attr.UsageType == NetworkAttributeUsageType.Restriction &&
                    !String.IsNullOrEmpty(attr.Name))
                {
                    restrictions.Add(attr.Name.ToLower(), new Restriction(
                                         attr.Name,
                                         String.Empty, // description
                                         true,         // editable is true by default
                                         _IsRestrictionEnabled(attr.Name,
                                                               netDesc.EnabledRestrictionNames)));
                }
            }

            // override restrictions according to settings
            foreach (string name in settings.RestrictionNames)
            {
                RestrictionInfo ri = settings.GetRestriction(name);
                if (ri != null)
                {
                    string key = name.ToLower();

                    Restriction rest = null;
                    if (restrictions.TryGetValue(key, out rest))
                    {
                        // override restriction
                        restrictions[key] = new Restriction(
                            rest.NetworkAttributeName, // NOTE: use name from server
                            ri.Description,
                            ri.IsEditable,
                            ri.IsTurnedOn);
                    }
                    else
                    {
                        Logger.Warning(String.Format(LOG_UNKNOWN_RESTRICTION, name));
                    }
                }
            }

            // attach to events
            foreach (Restriction rest in restrictions.Values)
            {
                rest.PropertyChanged += new PropertyChangedEventHandler(Restriction_PropertyChanged);
            }

            _restrictions.AddRange(restrictions.Values);
        }
コード例 #5
0
        private void _InitRouteSettings(SolveInfoWrap settings,
                                        ICollection <AgsServer> servers)
        {
            var service = settings.RouteService;

            _solveServiceValidator.Validate(service);

            _routeServiceConfig = service;
            _routeServer        = _GetServerByName(servers, service.ServerName);
        }
コード例 #6
0
        /// <summary>
        /// Creates new instance of the <see cref="ESRI.ArcLogistics.Routing.IVrpRequestAnalyzer"/>
        /// object corresponding to the specified service options.
        /// </summary>
        /// <param name="options">The options specifying the analyzer to be used.</param>
        /// <param name="solverConfig">Solver config, containing info about max orders and routes
        /// count for synq request.</param>
        /// <returns>The reference to the new instance of the VRP requests analyzer.</returns>
        private static IVrpRequestAnalyzer _CreateRequestAnalyzer(ServiceOptions options,
                                                                  SolveInfoWrap solverConfig)
        {
            // Check that sync vrp is allowed.
            if ((options & ServiceOptions.UseSyncVrp) != 0)
            {
                return(new SimpleVrpRequestAnalyzer(solverConfig.MaxSyncVrpRequestRoutesCount,
                                                    solverConfig.MaxSyncVrpRequestOrdersCount));
            }

            return(new ConstantVrpRequestAnalyzer(false));
        }
コード例 #7
0
        private void _InitSettings(
            SolveInfoWrap settings,
            ICollection <AgsServer> servers,
            ServiceOptions options)
        {
            Debug.Assert(settings != null);
            Debug.Assert(servers != null);

            // VRP data
            _InitVrpSettings(settings, servers, options);

            // route data
            _InitRouteSettings(settings, servers);

            // solver settings
            _solverConfig = settings;
        }
コード例 #8
0
        private void _InitVrpSettings(
            SolveInfoWrap settings,
            ICollection <AgsServer> servers,
            ServiceOptions options)
        {
            var service = settings.VrpService;

            _solveServiceValidator.Validate(service);
            _vrpServiceConfig = service;
            _vrpServer        = _GetServerByName(servers, service.ServerName);

            if ((options & ServiceOptions.UseSyncVrp) != 0)
            {
                var syncService = settings.SyncVrpService;
                _solveServiceValidator.Validate(syncService);
                _syncVrpServiceConfig = syncService;
                _syncVrpServer        = _GetServerByName(servers, syncService.ServerName);
            }
        }
コード例 #9
0
        ///////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////

        internal SolverSettings(SolveInfoWrap settings,
                                NetworkDescription netDesc)
        {
            Debug.Assert(settings != null);
            Debug.Assert(netDesc != null);

            _settings = settings;
            _netDesc  = netDesc;

            // Init restrictions.
            if (_netDesc != null)
            {
                _InitRestrictions(settings, netDesc);
            }

            // parameters
            _InitAttrParameters(settings);

            // Initialize U-Turn and curb approach policies.
            _InitUTurnPolicies(settings);
            _InitCurbApproachPolicies(settings);
        }
コード例 #10
0
        ///////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Initializes solver.
        /// </summary>
        /// <param name="settings">Current solve settings.</param>
        /// <param name="servers">Collection of ags servers.</param>
        /// <param name="solveServiceValidator">Object to perform service validation.</param>
        /// <param name="options">Options influencing services used by the application.</param>
        internal VrpSolver(
            SolveInfoWrap settings,
            ICollection <AgsServer> servers,
            ISolveServiceValidator solveServiceValidator,
            ServiceOptions options)
        {
            _solveServiceValidator = solveServiceValidator;
            _options = options;

            // init phase 1: set/validate configuration
            _InitSettings(settings, servers, _options);

            // Create discovery service.
            var factory = new DiscoveryServiceFactory();

            _discoveryService = factory.CreateService(settings, servers,
                                                      solveServiceValidator);

            // init phase 2: create services
            try
            {
                // check servers state
                ServiceHelper.ValidateServerState(_vrpServer);
                ServiceHelper.ValidateServerState(_routeServer);
                _discoveryService.ValidateServerState();
            }
            catch (Exception e)
            {
                // do not fail here, will try to re-initialize later
                Logger.Error(e);
            }

            // attach events
            _asyncMgr.AsyncSolveCompleted += new AsyncSolveCompletedEventHandler(
                _asyncMgr_AsyncSolveCompleted);
        }