Exemple #1
0
        public void Test11()
        {
            string text =
            @"Max f (x, y, z) = -a + z -2y;
              3y + x + z >=4;
              x + 2y - z >=6;
              x + z <=12;";
            var res = new Parser(text).Parse().Solve();

            Assert.AreEqual(res, -6);
        }
Exemple #2
0
        public void Test12()
        {
            string text =
            @"Min f (y1, y2, y3) = y1 - 2y2+3y3;
              3y1 - 5y2 - 7y3 = 1;
              -4y1 - 6y2 + 8y3 >=2;";

            var res = new Parser(text).Parse().Solve();

            Assert.AreEqual(res, 0);
        }
Exemple #3
0
        public void Test1()
        {
            string text =
            @" Max f(x,y) = 6x+2y;

               2x + 4y <= 9;
               3x + y <=6;
            ";
            Parser p = new Parser(text);
            var smp = p.Parse();

            Fraction res = smp.Solve();

            Assert.AreEqual(res, 12);
        }
 public ActionResult Solve(string text)
 {
     Simplex tx = null;
     try
     {
         tx = new Parser(text).Parse();
         tx.Solve();
     }
     catch (ParseErrorException e)
     {
         TempData["Error"] = e.Message.ToString();
         TempData["Text"] = text;
         return RedirectToAction("EnterData");
     }
     return View(tx);
 }
Exemple #5
0
        public void Test2()
        {
            string text =
            @"Max f(x1, x2) = 5x1 + 6x2;

              4x1 + 2x2 <= 900;
              2x1 + x2 <= 400;
              x1  + x2 <=300;";
            var res = new Parser(text).Parse().Solve();

            Assert.AreEqual(res, 1800);
        }
Exemple #6
0
        public void Test13()
        {
            string text =
            @"Min f(x1, x2, x3) = 5x1 + 7x2 +13x3;
                2x1+x2+4x3>=22;
                x1 + x2 + x3 = 9;
                x1 + 2x2+2x3 <=18;";

            var res = new Parser(text).Parse().Solve();

            Assert.AreEqual(res, 61);
        }
Exemple #7
0
        public void Test6()
        {
            string text =
            @"Min f(x, y, z) = (8/1)x + (-10/1)y - (12/1)z;
              x -2y - 3y <=4;
              x + y -2z <=3;
              +(+1/1)x - 3y -1z <=5;";
            var res = new Parser(text).Parse().Solve();

            Assert.AreEqual(res, -30);
        }
Exemple #8
0
        public void Test4()
        {
            string text =
            @"Min f(x1, x2, x3, x4) = x1 + 3x2 - x3 + 2x4;
              x1 + 2x2 - 2x3 + x4 = 4;
              3x1 - x2 + x3 - x4 >= 3;
              x1 - x3 + 2x4 <= 4;";
            var res = new Parser(text).Parse().Solve();

            Assert.AreEqual(res, 4);
        }
Exemple #9
0
        public void Test3()
        {
            string text =
            @"Min f(x1, x5) = 15x1 + 33x5;
              3x1+2x5>=6;
              x5 + 6x1 >=6;
              x5 >=1;";
            var res = new Parser(text).Parse().Solve();

            Assert.AreEqual(res, 53);
        }