Ejemplo n.º 1
0
        public void SetUp()
        {
            const int carAvailabilityProbability = 1;

            passengerBehaviour = Substitute.For <IPassengerBehaviourProvider>();
            transmissionType   = ChoiceTransportAlgorithmType.Average;
            var defaultRandomizer = new DefaultRandomizer();

            averagingAlgorithm = new AveragingAlgorithm(defaultRandomizer, carAvailabilityProbability);
        }
Ejemplo n.º 2
0
        public static Passenger CreatePassenger(
            IPassengerBehaviourProvider passengerBehaviour,
            int number,
            ChoiceTransportAlgorithmType algorithmType,
            TransportType transport,
            double satisfaction)
        {
            var rnd     = new Random();
            var quality = Math.Round(rnd.NextDouble(), 2);

            return(new Passenger(passengerBehaviour, transport, algorithmType, quality, satisfaction, number.ToString()));
        }
Ejemplo n.º 3
0
 public Passenger(
     IPassengerBehaviourProvider passengerBehaviourProvider,
     TransportType transportType,
     ChoiceTransportAlgorithmType choiceTransportAlgorithmType,
     double qualityCoefficient,
     double satisfaction,
     string id)
 {
     PassengerBehaviourProvider   = passengerBehaviourProvider;
     ChoiceTransportAlgorithmType = choiceTransportAlgorithmType;
     Id                 = id;
     TransportType      = transportType;
     QualityCoefficient = qualityCoefficient;
     Satisfaction       = satisfaction;
     Neighbors          = new HashSet <Passenger>();
 }
Ejemplo n.º 4
0
 public Passenger(
     IPassengerBehaviourProvider passengerBehaviourProvider,
     TransportType transportType,
     ChoiceTransportAlgorithmType choiceTransportAlgorithmType,
     double qualityCoefficient,
     double satisfaction,
     string id,
     List <double> allQualityCoefficients,
     double firstBusQuality)
 {
     PassengerBehaviourProvider   = passengerBehaviourProvider;
     ChoiceTransportAlgorithmType = choiceTransportAlgorithmType;
     Id = id;
     FirstBusQuality        = firstBusQuality;
     TransportType          = transportType;
     QualityCoefficient     = qualityCoefficient;
     Satisfaction           = satisfaction;
     Neighbors              = new HashSet <Passenger>();
     AllQualityCoefficients = allQualityCoefficients ?? new List <double>();
 }
Ejemplo n.º 5
0
        public Passenger[] CreatePassengers(ChoiceTransportAlgorithmType algorithmType, PassengerDto[] passengers)
        {
            var idToPassengers = passengers
                                 .ToDictionary(
                x => x.Id,
                x => Passenger.Create(x, behaviourProvider, algorithmType));

            var allPassengers = new List <Passenger>();

            foreach (var passenger in passengers)
            {
                var neighbors        = passenger.Neighbours.Select(x => idToPassengers[x]);
                var currentPassenger = idToPassengers[passenger.Id];
                foreach (var neighbor in neighbors)
                {
                    currentPassenger.AddNeighbor(neighbor);
                }

                allPassengers.Add(currentPassenger);
            }

            return(allPassengers.ToArray());
        }
 public void SetUp()
 {
     passengerBehaviour = Substitute.For <IPassengerBehaviourProvider>();
     transmissionType   = ChoiceTransportAlgorithmType.Deviation;
     averagingAlgorithm = new DeviationAlgorithm();
 }
Ejemplo n.º 7
0
 public ISatisfactionDeterminationAlgorithm GetSatisfactionDeterminationAlgorithm(ChoiceTransportAlgorithmType choiceTransportAlgorithmType)
 {
     return(satisfactionDeterminationAlgorithmFactory.GetAlgorithm(choiceTransportAlgorithmType));
 }
Ejemplo n.º 8
0
 public IChoiceTransportAlgorithm GetChoiceTransportAlgorithm(ChoiceTransportAlgorithmType choiceTransportAlgorithmType)
 {
     return(choiceTransportAlgorithmFactory.GetTransmissionFunc(choiceTransportAlgorithmType));
 }
Ejemplo n.º 9
0
 public IChoiceTransportAlgorithm GetTransmissionFunc(ChoiceTransportAlgorithmType type)
 {
     return(typeToFunc[type]);
 }
 public ISatisfactionDeterminationAlgorithm GetAlgorithm(ChoiceTransportAlgorithmType choiceTransportAlgorithmType)
 {
     return(typeToAlgorithm[choiceTransportAlgorithmType]);
 }
Ejemplo n.º 11
0
 public static Passenger Create(PassengerDto x, IPassengerBehaviourProvider passengerBehaviourProvider, ChoiceTransportAlgorithmType algorithmType)
 {
     return(new Passenger(
                passengerBehaviourProvider,
                x.TransportType,
                algorithmType,
                x.Quality,
                x.Satisfaction,
                x.Id,
                x.AllQualityCoefficients,
                x.FirstBusQuality));
 }