示例#1
0
        public void UtilityMaximizationTest()
        {
            var p = new Problem(nameof(UtilityMaximizationTest));
            var a = (Proposition)"a";

            a.Utility = 1;
            var b = (Proposition)"b";

            b.Utility = -1;
            var c = (Proposition)"c";

            c.Utility = 1.5f;
            var d = (Proposition)"d";

            d.Utility = 3.3f;
            var zero = (Proposition)"zeroUtility";

            p.Quantify(1, 4, a, b, c, d, zero);

            for (int i = 0; i < 100; i++)
            {
                var s = p.HighUtilitySolution(1000);
                Console.WriteLine(s.Model);

                Assert.IsTrue(Math.Abs((1 + 1.5 + 3.3) - s.Utility) < 0.00001f);
            }
        }