Ejemplo n.º 1
0
            protected override void SetProbability(DestinationSampler destinationSampler, bool skipChoicePropabilityCalculator = false) {
                var zoneProbability1 = _tourWeightFromOrigin / Math.Max(_totalTourWeightFromOrigin, Constants.EPSILON);
                var zoneProbability2 = _tripWeightFromOrigin / Math.Max(_totalTripWeightFromOrigin, Constants.EPSILON);

                // set chosen alternative availability if model is in estimation mode and the sample item is the chosen alternative
                var setAvailability = destinationSampler._choiceProbabilityCalculator.ModelIsInEstimationMode && ParcelId == destinationSampler._chosenParcel.Id;

                if (Global.Configuration.DestinationScale == Global.Settings.DestinationScales.Zone) {
                    Probability1 = zoneProbability1;
                    Probability2 = zoneProbability2;

                    // set chosen alternative availability if model is in estimation mode and the sample item is the chosen alternative
                    if (setAvailability) {
                        Available = (Probability1 > 0 || Probability2 > 0) && _tourWeightFromOrigin > Global.Configuration.MinParcelSize;
                        if (!skipChoicePropabilityCalculator) Alternative.Available = Available;
                    }

                    return;
                }

                // excludedSize will be 0 when in model is in estimation mode and the sample item is the chosen alternative
                var excludedSize = setAvailability ? 0 : ExcludedSize;
                var parcelProbability = SizeFromDestination / Math.Max(TotalSizeFromDestination - excludedSize, Constants.EPSILON);

                Probability1 = zoneProbability1 * parcelProbability;
                Probability2 = zoneProbability2 * parcelProbability;

                // set chosen alternative availability if model is in estimation mode and the sample item is the chosen alternative
                if (setAvailability) {
                    Available = (Probability1 > 0 || Probability2 > 0) && SizeFromDestination >= Global.Configuration.MinParcelSize;
                    if (!skipChoicePropabilityCalculator) Alternative.Available = Available;
                }
            }
Ejemplo n.º 2
0
            protected override void SetProbability(DestinationSampler destinationSampler, bool skipChoicePropabilityCalculator = false) {
                var zoneProbability = _weightFromOrigin / Math.Max(_totalWeightFromOrigin, Constants.EPSILON);

                // set chosen alternative availability if model is in estimation mode and the sample item is the chosen alternative
                //JLB 20120329 replaced followign to allow for no chosen alt in destinationSampler when in estimation mode (usual work location model)
                //                var setAvailability = destinationSampler._choiceProbabilityCalculator.ModelIsInEstimationMode && ParcelId == destinationSampler._chosenParcel.Id;
                var setAvailability = destinationSampler._choiceProbabilityCalculator.ModelIsInEstimationMode && destinationSampler._chosenParcel != null && ParcelId == destinationSampler._chosenParcel.Id;

                if (Global.Configuration.DestinationScale == Global.Settings.DestinationScales.Zone) {
                    Probability = zoneProbability;

                    // set chosen alternative availability if model is in estimation mode and the sample item is the chosen alternative
                    if (setAvailability) {
                        Available = Probability > 0 && _weightFromOrigin > Global.Configuration.MinParcelSize;
                        if (!skipChoicePropabilityCalculator) { Alternative.Available = Available; }
                    }

                    return;
                }

                // excludedSize will be 0 when in model is in estimation mode and the sample item is the chosen alternative
                var excludedSize = setAvailability ? 0 : ExcludedSize;
                var parcelProbability = SizeFromDestination / Math.Max(TotalSizeFromDestination - excludedSize, Constants.EPSILON);

                Probability = zoneProbability * parcelProbability;

                // set chosen alternative availability if model is in estimation mode and the sample item is the chosen alternative
                if (setAvailability) {
                    Available = Probability > 0 && SizeFromDestination >= Global.Configuration.MinParcelSize;
                    if (!skipChoicePropabilityCalculator) { Alternative.Available = Available; }

                }
            }
Ejemplo n.º 3
0
            public void SetAlternative <TSample>(DestinationSampler destinationSampler, Dictionary <TSample, int> sample,
                                                 bool isChosenAlternative, AlternativeType alternativeType = AlternativeType.Default, bool skipChoiceProbabilityCalculator = false) where TSample : ISampleItem
            {
                TSample key = (TSample)(object)this;

                Available = true;
                IsChosen  = isChosenAlternative;

                if (sample.ContainsKey(key))
                {
                    sample[key] += 1;
                }
                else
                {
                    int alternativeIndex;

                    switch (alternativeType)
                    {
                    case AlternativeType.Chosen:
                        if (sample.Count == destinationSampler._sampleSize)
                        {
                            sample.Remove(sample.Last().Key);
                        }

                        alternativeIndex = sample.Count;

                        break;

                    case AlternativeType.Usual:
                        //                            alternativeIndex = sample.Count;
                        alternativeIndex = destinationSampler._sampleSize;

                        break;

                    default:
                        alternativeIndex = destinationSampler._alternativeIndex++;

                        break;
                    }

                    sample.Add(key, 1);

                    if (!skipChoiceProbabilityCalculator)
                    {
                        Alternative = destinationSampler._choiceProbabilityCalculator.GetAlternative(alternativeIndex, true, isChosenAlternative);
                    }

                    SetProbability(destinationSampler, skipChoiceProbabilityCalculator);
                }
            }
Ejemplo n.º 4
0
            //            public bool Available { get; set; }
            //            public bool IsChosen { get; set; }

            public override void Initialize(DestinationSampler destinationSampler, int destinationParcelId, int destinationParcelSequence, SegmentZone destinationSegmentZone) {
                _weightFromOrigin = destinationSampler._originSegmentZone.GetWeight(destinationSegmentZone.Id);
                _totalWeightFromOrigin = destinationSampler._originSegmentZone.TotalWeight;

                TotalWeightFromDestination = destinationSegmentZone.TotalWeight;

                ParcelId = destinationParcelId;

                //if (Global.Configuration.DestinationScale == Constants.DestinationScale.ZONE) {
                //    return;
                //}

                SizeFromDestination = destinationSegmentZone.GetSize(destinationParcelSequence);
                TotalSizeFromDestination = destinationSegmentZone.TotalSize;
            }
Ejemplo n.º 5
0
 protected abstract void SetProbability(DestinationSampler destinationSampler, bool skipChoiceProbabilityCalculator = false);
Ejemplo n.º 6
0
 public abstract void Initialize(DestinationSampler destinationSampler, int destinationParcelId, int destinationParcelSequence, SegmentZone destinationSegmentZone);