Exemplo n.º 1
0
        public void ConsiderTest1(
            [Range(0.0f, 10.0f, 2.5f)] float xval1,
            [Range(0.0f, 10.0f, 2.5f)] float xval2)
        {
            // NEVER use the derived class to call
            // Consider otherwise the machinery in the base
            // class is never called!
            var c = ConsiderationConstructor.ConstrainedWeightedMetrics();

            var cd1 = new OptionConsideration1();
            var cd2 = new OptionConsideration2();

            cd1.NameId = "cd1";
            cd2.NameId = "cd2";
            c.AddConsideration(cd1);
            c.AddConsideration(cd2);
            _optionContext.XVal1 = xval1;
            _optionContext.XVal2 = xval2;
            cd1.Consider(_optionContext);
            cd2.Consider(_optionContext);
            var cUtil1 = cd1.Utility;
            var cUtil2 = cd2.Utility;
            var cUtilL = new List <Utility>();

            cUtilL.Add(cUtil1);
            cUtilL.Add(cUtil2);
            var cNorm = cUtilL.WeightedMetrics();

            c.Consider(_optionContext);
            Assert.That(c.Utility.Value, Is.EqualTo(cNorm).Within(Tolerance));
        }
Exemplo n.º 2
0
        void SetupConsiderations()
        {
            _considerations.Clear();
            IConsideration tmpc;

            tmpc = new OptionConsideration1("c1", _considerations);
            tmpc = new OptionConsideration1("c2", _considerations);
            tmpc = new OptionConsideration1("c3", _considerations);
            tmpc = new OptionConsideration1("c4", _considerations);
            tmpc = new OptionConsideration1("c5", _considerations);
        }
        public void ConsiderTest2(
            [Range(0.0f, 10.0f, 2.5f)] float xval1,
            [Range(0.0f, 10.0f, 2.5f)] float xval2,
            [Values(0.1f, 0.5f, 0.8f)] float threshold)
        {
            // NEVER use the derived class to call
            // Consider otherwise the machinery in the base
            // class is never called!
            var c = ConsiderationConstructor.ConstrainedChebyshev(threshold);

            var cd1 = new OptionConsideration1();
            var cd2 = new OptionConsideration2();

            cd1.NameId = "cd1";
            cd2.NameId = "cd2";
            c.AddConsideration(cd1);
            c.AddConsideration(cd2);
            _optionContext.XVal1 = xval1;
            _optionContext.XVal2 = xval2;
            cd1.Consider(_optionContext);
            cd2.Consider(_optionContext);
            var cUtil1 = cd1.Utility;
            var cUtil2 = cd2.Utility;
            var cUtilL = new List <Utility>();

            cUtilL.Add(cUtil1);
            cUtilL.Add(cUtil2);
            var cNorm = cUtilL.Chebyshev();

            if (cUtil1.Combined < threshold ||
                cUtil2 < threshold)
            {
                cNorm = 0.0f;
            }
            c.Consider(_optionContext);
            Assert.That(c.Utility.Value, Is.EqualTo(cNorm).Within(Tolerance));
        }
Exemplo n.º 4
0
 OptionConsideration1(OptionConsideration1 other) : base(other)
 {
     Initialize();
 }