Exemple #1
0
        public static RealLifeProfile CreateProfile(
            this OperatorSet operatorSet,
            string from, string to,
            string walksGeneratorDescription,
            uint internalTransferTime     = 180,
            double searchFactor           = 2.5,
            uint minimalSearchTimeSeconds = 2 * 60 * 60,
            bool allowCancelled           = false,
            uint maxNumberOfTransfers     = uint.MaxValue
            )
        {
            var stops = operatorSet.GetStopsReader().AddOsmReader();

            stops.MoveTo(from);
            var fromId = stops.Id;

            stops.MoveTo(to);
            var toId = stops.Id;


            var walksGenerator = State.GlobalState.OtherModeBuilder.Create(
                walksGeneratorDescription,
                new List <StopId> {
                fromId
            },
                new List <StopId> {
                toId
            }
                );


            var internalTransferGenerator = new InternalTransferGenerator(internalTransferTime);

            var maxDistance = uint.MaxValue;

            foreach (var op in operatorSet.Operators)
            {
                maxDistance = Math.Min(maxDistance, op.MaxSearch);
            }

            if (walksGenerator.Range() > maxDistance)
            {
                throw new ArgumentException(
                          $"Search range too high: with the chosen operators, at most {maxDistance}m is allowed");
            }

            var searchFunction =
                RealLifeProfile.DefaultSearchLengthSearcher(searchFactor,
                                                            TimeSpan.FromSeconds(minimalSearchTimeSeconds));

            return(new RealLifeProfile(
                       operatorSet,
                       internalTransferGenerator,
                       walksGenerator,
                       allowCancelled,
                       maxNumberOfTransfers,
                       searchFunction
                       ));
        }
Exemple #2
0
 public RealLifeProfile(
     OperatorSet operatorSet,
     IOtherModeGenerator internalTransferGenerator,
     IOtherModeGenerator walksGenerator,
     bool allowCancelled,
     uint maxNumberOfTransfers,
     Func <DateTime, DateTime, TimeSpan> searchLengthCalculator
     ) :
     base(
         internalTransferGenerator,
         walksGenerator,
         TransferMetric.Factory,
         TransferMetric.ParetoCompare,
         allowCancelled ? null : new CancelledConnectionFilter(),
         new ChangeableMaxNumberOfTransferFilter(uint.MaxValue))
 {
     OperatorSet            = operatorSet;
     _filter                = (ChangeableMaxNumberOfTransferFilter)JourneyFilter;
     _maxNumberOfTransfers  = maxNumberOfTransfers;
     SearchLengthCalculator = searchLengthCalculator;
 }
        private OperatorSet GetView(List <Operator> operators)
        {
            if (operators == null)
            {
                throw new NullReferenceException("If you want an operator set, pass in a list of operators");
            }

            var names = operators.Select(op => op.Name.ToLower()).ToList();

            names.Sort();
            var cacheKey = string.Join("\n", names);

            if (_cachedViews.TryGetValue(cacheKey, out var cached))
            {
                return(cached);
            }

            var newSet = new OperatorSet(operators);

            _cachedViews.Add(cacheKey, newSet);
            return(newSet);
        }
 internal static (Segment, int newIndex) TranslateSegment <T>(this OperatorSet dbs, List <Journey <T> > parts, int i)