public void Gesamtgewichtung_berechne_richtig()
        {
            var estimatorWeightings = new List <TotalWeighting>()
            {
                new TotalWeighting()
                {
                    StoryIndizes = new List <int> {
                        2, 0, 1
                    }
                },
                new TotalWeighting()
                {
                    StoryIndizes = new List <int> {
                        1, 2, 0
                    }
                },
                new TotalWeighting()
                {
                    StoryIndizes = new List <int> {
                        2, 1, 0
                    }
                },
            };

            var sut = new Weighting();

            var result = sut.Get_Total_Weighting_From(estimatorWeightings);

            Assert.AreEqual(new[] { 2, 1, 0 }, result.StoryIndizes);
        }
示例#2
0
        public double getCurrentWeightingForEquityGroup(List <Equity> equities, List <Weighting> weightings)
        {
            double weightingPercentage = 0;

            foreach (var equity in equities)
            {
                Weighting weighting = null;

                if (weightings.Count == 0)
                {
                    weightingPercentage += 0;
                }
                else
                {
                    weighting = weightings.SingleOrDefault(w => ((Equity)w.Weightable).Id == equity.Id);
                    if (weighting == null)
                    {
                        weightingPercentage += 0;
                    }
                    else
                    {
                        weightingPercentage += weighting.Percentage;
                    }
                }
            }
            return(weightingPercentage);
        }
 public DescriptionRule(IList<string> terms, TextLookup location, TransactionType suggestedType, Weighting weighting)
 {
     Terms = terms;
     Location = location;
     SuggestedType = suggestedType;
     Weighting = weighting;
 }
示例#4
0
        public void NormalizeTests(int expectedDenominator, params int[] denominators)
        {
            List <Weighting> set = denominators.Select(x => Weighting.Create(1, (ulong)x).Value).ToList();

            ICollection <Weighting> result = Weighting.Normalize(set);

            result.All(x => x.Denominator == (ulong)expectedDenominator).Should().BeTrue();
        }
示例#5
0
        public void SimplifyTests(int top, int bottom, int expectedTop, int expectedBottom)
        {
            Weighting weighting = Weighting.Create((ulong)top, (ulong)bottom).Value;

            Weighting result = weighting.Simplify();

            result.Numerator.Should().Be((ulong)expectedTop);
            result.Denominator.Should().Be((ulong)expectedBottom);
        }
        public void Get_Total_Weighting_From_Without_Votings_Returns_Empty_List()
        {
            var sut = new Weighting();

            var result = sut.Get_Total_Weighting_From(new List <TotalWeighting>());

            Assert.AreEqual(0, result.StoryIndizes.Count());

            result = sut.Get_Total_Weighting_From(null);
            Assert.AreEqual(0, result.StoryIndizes.Count());
        }
示例#7
0
        public void PriceStartAndEndParameters_MonthlyCurveBusinessDayWeight_EqualsWeightedAverage()
        {
            var curve = new DoubleCurve <Month>(Month.CreateJanuary(2020), new [] { 56.54, 54.15, 51.14 },
                                                Weighting.BusinessDayCount <Month>(new Day[0]));

            double febMarPrice = curve.Price(Month.CreateFebruary(2020), Month.CreateMarch(2020));

            const double expectedFebMarPrice = (54.15 * 20.0 + 51.14 * 22.0) / 42.0;

            Assert.AreEqual(expectedFebMarPrice, febMarPrice);
        }
示例#8
0
        public void Bootstrap_WithZeroWeightedContract_ThrowsArgumentException()
        {
            var builder = new Bootstrapper <Day>()
                          .AddContract(new Day(2019, 1, 7), new Day(2019, 1, 13), 58.45)
                          .AddContract(new Day(2019, 1, 12), new Day(2019, 1, 13), 60.87)
                          .WithAverageWeighting(Weighting.BusinessDayCount <Day>(new List <Day>()));

            Assert.Throws(Is.TypeOf <ArgumentException>().And.Message.EqualTo(
                              "sum of weighting evaluated to non-positive number for the following contract: Start: 2019-01-12, End: 2019-01-13, Price: 60.87"),
                          () => builder.Bootstrap());
        }
  /// <p>
  /// Creates a possibly weighted {@link AbstractSimilarity}.
  /// </p>
 public AbstractSimilarity(IDataModel dataModel, Weighting weighting, bool centerData) : base(dataModel) {
   this.weighted = weighting == Weighting.WEIGHTED;
   this.centerData = centerData;
   this.cachedNumItems = dataModel.GetNumItems();
   this.cachedNumUsers = dataModel.GetNumUsers();
   this.refreshHelper = new RefreshHelper( () => {
       cachedNumItems = dataModel.GetNumItems();
       cachedNumUsers = dataModel.GetNumUsers();
     }
   );
 }
示例#10
0
        public void Price_MonthlyCurveBusinessDayWeight_EqualsWeightedAverage()
        {
            var curve = new DoubleCurve <Month>(Month.CreateJanuary(2020), new[] { 56.54, 54.15, 51.14 },
                                                Weighting.BusinessDayCount <Month>(new Day[0]));

            double q1Price = curve.Price(Quarter.CreateQuarter1(2020));

            const double expectedQ1Price = (56.54 * 23.0 + 54.15 * 20.0 + 51.14 * 22.0) / 65.0;

            Assert.AreEqual(expectedQ1Price, q1Price);
        }
 /// <p>
 /// Creates a possibly weighted {@link AbstractSimilarity}.
 /// </p>
 public AbstractSimilarity(IDataModel dataModel, Weighting weighting, bool centerData) : base(dataModel)
 {
     this.weighted       = weighting == Weighting.WEIGHTED;
     this.centerData     = centerData;
     this.cachedNumItems = dataModel.GetNumItems();
     this.cachedNumUsers = dataModel.GetNumUsers();
     this.refreshHelper  = new RefreshHelper(() => {
         cachedNumItems = dataModel.GetNumItems();
         cachedNumUsers = dataModel.GetNumUsers();
     }
                                             );
 }
示例#12
0
 public static void ApplyToWeighting(Weighting rule, WeightingModel command)
 {
     rule.RuleId       = command.RuleId > 0 ? command.RuleId : rule.RuleId;
     rule.Description  = command.Description;
     rule.InternalType = command.InternalType;
     //rule.ForceUnderOver = command.ForceUnderOver;
     //rule.Ignore = command.Ignore;
     rule.InternalType = command.InternalType;
     //rule.Over = command.Over;
     rule.Type = command.Type;
     //rule.Under = command.Under;
     rule.Value = command.Value;
 }
示例#13
0
        public SlopeOneRecommender(
            DataModel dataModel,
            Weighting weighting,
            Weighting stdDevWeighting, DiffStorage diffStorage)
            : base(dataModel)
        {
            //if (stdDevWeighting != Weighting.WEIGHTED)

            //Preconditions.checkArgument(stdDevWeighting != Weighting.WEIGHTED || weighting != Weighting.UNWEIGHTED,
            //  "weighted required when stdDevWeighted is set");
            //Preconditions.checkArgument(diffStorage != null, "diffStorage is null");
            this.weighted       = weighting == Weighting.WEIGHTED;
            this.stdDevWeighted = stdDevWeighting == Weighting.WEIGHTED;
            this.diffStorage    = diffStorage;
        }
        public void Relations()
        {
            IEnumerable <WeightedComparisonPairDto> voting = new List <WeightedComparisonPairDto>
            {
                new WeightedComparisonPairDto
                {
                    Id        = "0",
                    Selection = Selection.A
                },
                new WeightedComparisonPairDto
                {
                    Id        = "1",
                    Selection = Selection.B
                },
                new WeightedComparisonPairDto
                {
                    Id        = "2",
                    Selection = Selection.B
                },
            };

            IEnumerable <ComparisonPair> comparisonPairs = new List <ComparisonPair>
            {
                new ComparisonPair
                {
                    Id     = "0",
                    IndexA = 0,
                    IndexB = 1,
                },
                new ComparisonPair
                {
                    Id     = "1",
                    IndexA = 0,
                    IndexB = 2,
                },
                new ComparisonPair
                {
                    Id     = "2",
                    IndexA = 1,
                    IndexB = 2,
                },
            };
            var result = Weighting.Create_Relations(voting, comparisonPairs).ToList();

            AssertIndize(result[0], 0, 1);
            AssertIndize(result[1], 2, 0);
            AssertIndize(result[2], 2, 1);
        }
示例#15
0
        private static Weighting MapToWeighting(WeightingModel command)
        {
            var weighting = new Weighting()
            {
                Description  = command.Description,
                InternalType = command.InternalType,
                RuleId       = command.RuleId,
                //ForceUnderOver = command.ForceUnderOver,
                //Ignore = command.Ignore,
                //Over = command.Over,
                Type = command.Type,
                //Under = command.Under,
                Value = command.Value
            };

            return(weighting);
        }
示例#16
0
 public MemoryDiffStorage(DataModel dataModel,
                          Weighting stdDevWeighted,
                          long maxEntries)
 {
     //Preconditions.checkArgument(dataModel != null, "dataModel is null");
     //Preconditions.checkArgument(dataModel.getNumItems() >= 1, "dataModel has no items");
     //Preconditions.checkArgument(maxEntries > 0L, "maxEntries must be positive");
     this.dataModel               = dataModel;
     this.stdDevWeighted          = stdDevWeighted == Weighting.WEIGHTED;
     this.maxEntries              = maxEntries;
     this.averageDiffs            = new FastByIDMap <FastByIDMap <RunningAverage> >();
     this.averageItemPref         = new FastByIDMap <RunningAverage>();
     this.buildAverageDiffsLock   = new ReaderWriterLockSlim();
     this.allRecommendableItemIDs = new FastIDSet(dataModel.getNumItems());
     this.refreshHelper           = new RefreshHelper(buildAverageDiffs);
     refreshHelper.addDependency(dataModel);
     buildAverageDiffs();
 }
示例#17
0
        public AbstractSimilarity(DataModel dataModel, Weighting weighting, bool centerData)
            : base(dataModel)
        {
            Action refreshRunnable = null;

            this.weighted       = weighting == Weighting.WEIGHTED;
            this.centerData     = centerData;
            this.cachedNumItems = dataModel.getNumItems();
            this.cachedNumUsers = dataModel.getNumUsers();
            if (refreshRunnable == null)
            {
                refreshRunnable = delegate
                {
                    this.cachedNumItems = dataModel.getNumItems();
                    this.cachedNumUsers = dataModel.getNumUsers();
                };
            }
            this.refreshHelper = new RefreshHelper(refreshRunnable);
        }
        public async Task AddWeighting(AddWeightingCommand command)
        {
            var weighting = _context.Weightings.FirstOrDefault(w => w.Date == command.Date);

            if (weighting != null)
            {
                weighting.Weight = command.Weight;
            }
            else
            {
                Weighting newWeighting = new Weighting()
                {
                    Date   = command.Date,
                    Weight = command.Weight
                };
                _context.Weightings.Add(newWeighting);
            }

            await _context.SaveChangesAsync();
        }
        public void Compute_Estimator_Weighting()
        {
            var voting = new List <WeightedComparisonPairDto>()
            {
                new WeightedComparisonPairDto {
                    Id = "1", Selection = Selection.A
                },
                new WeightedComparisonPairDto {
                    Id = "2", Selection = Selection.B
                },
                new WeightedComparisonPairDto {
                    Id = "3", Selection = Selection.B
                },
            };

            var paare = new List <ComparisonPair>()
            {
                new ComparisonPair {
                    Id = "1", IndexA = 0, IndexB = 1
                },
                new ComparisonPair {
                    Id = "2", IndexA = 0, IndexB = 2
                },
                new ComparisonPair {
                    Id = "3", IndexA = 1, IndexB = 2
                }
            };

            var result = new int[0];
            var sut    = new Weighting();

            sut.Compute_Estimator_Weighting(
                voting,
                paare,
                g => result = g.StoryIndizes.ToArray(),
                () => { throw new Exception(); }
                );

            Assert.AreEqual(new[] { 2, 0, 1 }, result);
        }
示例#20
0
        public double getCurrentWeightingForEquity(string equityId, List <Weighting> weightings)
        {
            double    weightingPercentage = 0;
            Weighting weighting           = null;

            if (weightings.Count == 0)
            {
                weightingPercentage = 0;
            }
            else
            {
                weighting = weightings.SingleOrDefault(w => ((Equity)w.Weightable).Id == equityId);
                if (weighting == null)
                {
                    weightingPercentage = 0;
                }
                else
                {
                    weightingPercentage = weighting.Percentage;
                }
            }
            return(weightingPercentage);
        }
        public void Compute_Estimator_Weighting_Raises_Exception()
        {
            var voting = new List <WeightedComparisonPairDto>()
            {
                new WeightedComparisonPairDto {
                    Id = "1", Selection = Selection.A
                },
                new WeightedComparisonPairDto {
                    Id = "2", Selection = Selection.B
                },
                new WeightedComparisonPairDto {
                    Id = "3", Selection = Selection.A
                },
            };

            var paare = new List <ComparisonPair>()
            {
                new ComparisonPair {
                    Id = "1", IndexA = 0, IndexB = 1
                },
                new ComparisonPair {
                    Id = "2", IndexA = 0, IndexB = 2
                },
                new ComparisonPair {
                    Id = "3", IndexA = 1, IndexB = 2
                }
            };

            var sut = new Weighting();

            sut.Compute_Estimator_Weighting(
                voting,
                paare,
                g => { throw new Exception("kein Fehler"); },
                () => Assert.True(true)
                );
        }
 public PearsonCorrelationSimilarity(DataModel dataModel, Weighting weighting)
     : base(dataModel, weighting, true)
 {
 }
示例#23
0
 public override int GetHashCode()
 {
     return(Weighting.GetHashCode() ^ Response.GetHashCode() ^ NumberOfTimesSeen.GetHashCode() ^ GamePieces.GetHashCode());
 }
示例#24
0
        static void Main()
        {
            //===============================================================================================
            // BASIC BOOTSTRAPPING CALCULATION

            // Bootstrapping 1 quarterly price and 1 monthly price into a monthly curve
            BootstrapResults <Month> bootstrapResults = new Bootstrapper <Month>()
                                                        .AddContract(Month.CreateJanuary(2020), 19.05)
                                                        .AddContract(Quarter.CreateQuarter1(2020), 17.22)
                                                        .Bootstrap();

            Console.WriteLine("Derived piecewise flat curve:");
            Console.WriteLine(bootstrapResults.Curve.FormatData("F5"));

            Console.WriteLine();

            Console.WriteLine("Equivalent bootstrapped contracts:");
            foreach (Contract <Month> contract in bootstrapResults.BootstrappedContracts)
            {
                Console.WriteLine(contract);
            }

            Console.WriteLine();
            Console.WriteLine();

            //===============================================================================================
            // APPLYING SHAPING DURING BOOTSTRAPPING

            var jan20 = Month.CreateJanuary(2020);
            var feb20 = Month.CreateFebruary(2020);
            var mar20 = Month.CreateMarch(2020);

            // Shaping applied as a ratio between Feb and Mar
            const double ratio = 1.1;

            var(pieceWiseCurveWithRatio, _) = new Bootstrapper <Month>()
                                              .AddContract(jan20, 19.05)
                                              .AddContract(Quarter.CreateQuarter1(2020), 17.22)
                                              .AddShaping(Shaping <Month> .Ratio.Between(feb20).And(mar20).Is(ratio))
                                              .Bootstrap();

            Console.WriteLine($"Derived piecewise flat curve with {ratio} ratio applied between Feb and Mar:");
            Console.WriteLine(pieceWiseCurveWithRatio.FormatData("F5"));

            Console.WriteLine();

            Console.WriteLine("Ratio in derived curve: {0:F5}",
                              pieceWiseCurveWithRatio[feb20] / pieceWiseCurveWithRatio[mar20]);

            Console.WriteLine();
            Console.WriteLine();

            // Shaping applied as a spread between Feb and Mar
            const double spread = 0.21;

            var(pieceWiseCurveWithSpread, _) = new Bootstrapper <Month>()
                                               .AddContract(jan20, 19.05)
                                               .AddContract(Quarter.CreateQuarter1(2020), 17.22)
                                               .AddShaping(Shaping <Month> .Spread.Between(feb20).And(mar20).Is(spread))
                                               .Bootstrap();

            Console.WriteLine($"Derived piecewise flat curve with {spread} spread applied between Feb and Mar:");
            Console.WriteLine(pieceWiseCurveWithSpread.FormatData("F5"));

            Console.WriteLine();

            Console.WriteLine("Spread in derived curve: {0:F5}",
                              pieceWiseCurveWithSpread[feb20] - pieceWiseCurveWithSpread[mar20]);

            Console.WriteLine();
            Console.WriteLine();

            //===============================================================================================
            // HANDLING REDUNDANCY OF CONTRACTS AND SHAPING FACTORS

            try
            {
                // If the price of Feb-20 is added, this essentially represents redundancy in the inputs, resulting in an exception
                new Bootstrapper <Month>()
                .AddContract(jan20, 22.95)
                .AddContract(feb20, 21.05)
                .AddContract(Quarter.CreateQuarter1(2020), 19.05)
                .AddShaping(Shaping <Month> .Spread.Between(feb20).And(mar20).Is(spread))
                .Bootstrap();
            }
            catch (ArgumentException e)
            {
                Console.WriteLine("Exception raised when redundancy inputs provided:");
                Console.WriteLine(e);
            }

            Console.WriteLine();
            Console.WriteLine();

            // Using AllowRedundancy() allows the calculation to perform without checks on redundancy
            var(pieceWiseCurveWithRedundancy, _) = new Bootstrapper <Month>()
                                                   .AddContract(jan20, 22.95)
                                                   .AddContract(feb20, 21.05)
                                                   .AddContract(Quarter.CreateQuarter1(2020), 19.05)
                                                   .AddShaping(Shaping <Month> .Spread.Between(feb20).And(mar20).Is(spread))
                                                   .AllowRedundancy()
                                                   .Bootstrap();

            Console.WriteLine("Derived piecewise flat curve with redundant inputs, after AllowRedundancy() called:");
            Console.WriteLine(pieceWiseCurveWithRedundancy.FormatData("F5"));

            Console.WriteLine();
            Console.WriteLine();

            //===============================================================================================
            // APPLYING AN ALTERNATIVE WEIGHTING SCHEME

            // By default, the bootstrap calculations assume averages are weighted by the number of minutes in a contract period.
            // This assumption is fine for instruments where the commodity is delivered at a constant rate, e.g. natural gas forwards.
            // An alternative weighting scheme can be added by calling WithAverageWeighting and supplying a weighting scheme as a function.
            // The below example makes use of the Weighting helper class to provide the weighting function as the count of business days.
            // An example of when such a weighting scheme should be used is for oil swaps, based on an index which is only published on a business day.

            var holidays = new List <Day>()
            {
                new Day(2020, 1, 1)
            };
            Func <Month, double> busDayWeight = Weighting.BusinessDayCount <Month>(holidays);

            var(pieceWiseCurveBusDayWeight, _) = new Bootstrapper <Month>()
                                                 .AddContract(jan20, 19.05)
                                                 .AddContract(Quarter.CreateQuarter1(2020), 17.22)
                                                 .WithAverageWeighting(busDayWeight)
                                                 .Bootstrap();

            Console.WriteLine("Derived piecewise flat curve with business day weighting:");
            Console.WriteLine(pieceWiseCurveBusDayWeight.FormatData("F5"));

            Console.ReadKey();
        }
示例#25
0
        /// <summary>
        /// Combat Hook entry-point, manages when lower-level hooks can run and executes trinity features.
        /// </summary>
        public static async Task <bool> MainCombatTask()
        {
            if (!ZetaDia.IsInGame || ZetaDia.Globals.IsLoadingWorld || !ZetaDia.Me.IsValid)
            {
                return(false);
            }

            if (Core.IsOutOfGame || Core.Player.IsDead)
            {
                return(false);
            }

            if (!Core.Scenes.CurrentWorldScenes.Any())
            {
                return(false);
            }

            // Allow a 'false' return in routine (to continue with profile) and skip default behavior.
            var startHookResult = await Routines.Current.HandleStart();

            if (Routines.Current.ShouldReturnStartResult)
            {
                return(startHookResult);
            }

            await UsePotion.Execute();

            await OpenTreasureBags.Execute();

            await VacuumItems.Execute();

            var target = Weighting.WeightActors(Core.Targets);

            if (await CastBuffs())
            {
                return(true);
            }

            if (await Routines.Current.HandleBeforeCombat())
            {
                return(true);
            }

            // When combat is disabled, we're still allowing trinity to handle non-unit targets.
            if (!IsCombatAllowed && IsUnitOrInvalid(target))
            {
                return(false);
            }

            if (await Targeting.HandleTarget(target))
            {
                return(true);
            }

            // We're not in combat at this point.

            if (await Routines.Current.HandleOutsideCombat())
            {
                return(true);
            }

            if (!Core.Player.IsCasting && (!TargetUtil.AnyMobsInRange(20f) || !Core.Player.IsTakingDamage))
            {
                await EmergencyRepair.Execute();

                await AutoEquipSkills.Instance.Execute();

                await AutoEquipItems.Instance.Execute();

                return(false);
            }

            // Allow Profile to Run.
            return(false);
        }
示例#26
0
        public void LowestCommonDenominatorTests(int left, int right, int expected)
        {
            ulong result = Weighting.DetermineCommonDenominator((ulong)left, (ulong)right);

            result.Should().Be((ulong)expected);
        }
   /// @{@link DataModel} does not have preference values
  public EuclideanDistanceSimilarity(IDataModel dataModel, Weighting weighting) :
		base(dataModel, weighting, false) {
    
    //Preconditions.checkArgument(dataModel.hasPreferenceValues(), "DataModel doesn't have preference values");
  }
示例#28
0
        public static async Task <CoroutineResult> RunCombat()
        {
            if (!ZetaDia.IsInGame ||
                ZetaDia.Globals.IsLoadingWorld ||
                ZetaDia.Globals.IsPlayingCutscene ||
                !ZetaDia.Me.IsFullyValid() ||
                ZetaDia.Me.IsDead)
            {
                return(CoroutineResult.NoAction);
            }

            if (ZetaDia.IsInTown &&
                BrainBehavior.IsVendoring)
            {
                return(CoroutineResult.NoAction);
            }

            if (Core.Scenes.CurrentWorldSceneIds.Count == 0)
            {
                return(CoroutineResult.NoAction);
            }

            await UsePotion.DrinkPotion();

            // TODO: Why is OpenTreasureBags called during combat? Move to Townrun.
            await OpenTreasureBags.Execute();

            if (!await VacuumItems.Execute())
            {
                return(CoroutineResult.Running);
            }

            var target = Weighting.WeightActors(Core.Targets);

            if (await CastBuffs())
            {
                return(CoroutineResult.Running);
            }

            if (await Routines.Current.HandleBeforeCombat())
            {
                return(CoroutineResult.Running);
            }

            // When combat is disabled, we're still allowing trinity to handle non-unit targets.
            if (!IsCombatAllowed && IsUnitOrInvalid(target))
            {
                return(CoroutineResult.NoAction);
            }

            // Sometimes it is standing still and stuck - need to handle that before we are entering
            // the target one.
            if (Navigator.StuckHandler.IsStuck)
            {
                await Navigator.StuckHandler.DoUnstick();

                return(CoroutineResult.Running);
            }

            if (await Targeting.HandleTarget(target))
            {
                return(CoroutineResult.Running);
            }

            // We're not in combat at this point.

            if (await Routines.Current.HandleOutsideCombat())
            {
                return(CoroutineResult.Running);
            }

            if (!ZetaDia.Me.IsCasting && (!TargetUtil.AnyMobsInRange(20f) || !Core.Player.IsTakingDamage))
            {
                await AutoEquipSkills.Instance.Execute();

                await AutoEquipItems.Instance.Execute();

                return(CoroutineResult.NoAction);
            }

            // Allow Profile to Run.
            return(CoroutineResult.NoAction);
        }
示例#29
0
        public static void ApplyToPass(Pass pass, PassModel command, IMapper mapper)
        {
            if (pass != null && command != null)
            {
                pass.Id   = command.Id > 0 ? command.Id : pass.Id;
                pass.Name = command.Name;

                List <General> oldGenerals = new List <General>();
                pass.General.ForEach(item => oldGenerals.Add(item));
                pass.General.Clear();
                foreach (GeneralModel generalModel in command.General)
                {
                    General oldGeneral = oldGenerals.Find(item => item.RuleId == generalModel.RuleId);
                    if (oldGeneral == null)
                    {
                        General general = MapToGeneral(generalModel);
                        pass.General.Add(general);
                    }
                    else
                    {
                        ApplyToGeneral(oldGeneral, generalModel);
                        pass.General.Add(oldGeneral);
                    }
                }

                List <PassRule> oldRules = new List <PassRule>();
                pass.Rules.ForEach(item => oldRules.Add(item));
                pass.Rules.Clear();
                foreach (PassRuleModel ruleModel in command.Rules)
                {
                    PassRule oldRule = oldRules.Find(item => item.RuleId == ruleModel.RuleId);
                    if (oldRule == null)        // New rule
                    {
                        PassRule rule = MapToRule(ruleModel);
                        pass.Rules.Add(rule);
                    }
                    else
                    {
                        ApplyToRule(oldRule, ruleModel);
                        pass.Rules.Add(oldRule);
                    }
                }

                #region pass.Tolerances

                List <Tolerance> oldTolerances = new List <Tolerance>();
                pass.Tolerances.ForEach(item => oldTolerances.Add(item));
                pass.Tolerances.Clear();
                foreach (ToleranceModel toleranceModel in command.Tolerances)
                {
                    Tolerance oldTolerance = oldTolerances.Find(item => item.RuleId == toleranceModel.RuleId);
                    if (oldTolerance == null)        // New rule
                    {
                        Tolerance tolerance = MapToTolerance(toleranceModel);
                        pass.Tolerances.Add(tolerance);
                    }
                    else
                    {
                        ApplyToTolerance(oldTolerance, toleranceModel);
                        pass.Tolerances.Add(oldTolerance);
                    }
                }

                #endregion pass.Tolerances

                #region pass.RatingPoints

                pass.RatingPoints = command.RatingPoints.Select(x => mapper.Map <RatingPoint>(x)).ToList();

                #endregion pass.RatingPoints

                #region pass.Weightings

                List <Weighting> oldWeightings = new List <Weighting>();
                pass.Weightings.ForEach(item => oldWeightings.Add(item));
                pass.Weightings.Clear();
                foreach (WeightingModel weightingMode in command.Weightings)
                {
                    Weighting oldWeighting = oldWeightings.Find(item => item.RuleId == weightingMode.RuleId);
                    if (oldWeighting == null)        // New rule
                    {
                        Weighting weighting = MapToWeighting(weightingMode);
                        pass.Weightings.Add(weighting);
                    }
                    else
                    {
                        ApplyToWeighting(oldWeighting, weightingMode);
                        pass.Weightings.Add(oldWeighting);
                    }
                }

                #endregion pass.Weightings

                #region pass.ProgrammeRepetitions

                pass.ProgrammeRepetitions.Clear();
                foreach (ProgrammeRepetitionModel programmeRepetitionMode in command.ProgrammeRepetitions)
                {
                    ProgrammeRepetition programmeRepetition = MapToProgrammeRepetition(programmeRepetitionMode);
                    pass.ProgrammeRepetitions.Add(programmeRepetition);
                }

                #endregion pass.ProgrammeRepetitions

                #region pass.BreakExclusions

                pass.BreakExclusions.Clear();
                foreach (BreakExclusionModel breakExclusionMode in command.BreakExclusions)
                {
                    BreakExclusion breakExclusion = MapToBreakExclusion(breakExclusionMode);
                    pass.BreakExclusions.Add(breakExclusion);
                }

                #endregion pass.BreakExclusions

                #region pass.SlottingLimits

                pass.SlottingLimits.Clear();
                foreach (SlottingLimitModel slottingLimitMode in command.SlottingLimits)
                {
                    SlottingLimit slottingLimit = MapToSlottingLimit(slottingLimitMode);
                    pass.SlottingLimits.Add(slottingLimit);
                }

                #endregion pass.SlottingLimits

                #region pass.PassSalesAreaPriorities

                pass.PassSalesAreaPriorities = MapToPassSalesAreaPriorities(command.PassSalesAreaPriorities);

                #endregion pass.PassSalesAreaPriorities
            }
        }
示例#30
0
 /// @{@link DataModel} does not have preference values
 public PearsonCorrelationSimilarity(IDataModel dataModel, Weighting weighting)
     : base(dataModel, weighting, true)
 {
     //Preconditions.checkArgument(dataModel.hasPreferenceValues(), "DataModel doesn't have preference values");
 }
 public UncenteredCosineSimilarity(DataModel dataModel, Weighting weighting)
     : base(dataModel, weighting, false)
 {
 }
示例#32
0
 public EuclideanDistanceSimilarity(DataModel dataModel, Weighting weighting)
     : base(dataModel, weighting, false)
 {
 }
示例#33
0
 public TypeWeighting(TransactionType type, Weighting weighting)
 {
     Type = type;
     Weighting = weighting;
 }
 /// @{@link DataModel} does not have preference values
 public EuclideanDistanceSimilarity(IDataModel dataModel, Weighting weighting) :
     base(dataModel, weighting, false)
 {
     //Preconditions.checkArgument(dataModel.hasPreferenceValues(), "DataModel doesn't have preference values");
 }
   /// @{@link DataModel} does not have preference values
	public PearsonCorrelationSimilarity(IDataModel dataModel, Weighting weighting)
		: base(dataModel, weighting, true) {
    
    //Preconditions.checkArgument(dataModel.hasPreferenceValues(), "DataModel doesn't have preference values");
  }