Exemplo n.º 1
0
 def test_solve_fraction_largest_increase(self):
     res, D = lp_solve(self.c,
                       self.A,
                       self.b,
                       pivotrule=lambda D: largest_increase(D, eps=0))
     self.assertEqual(res, LPResult.UNBOUNDED)
     self.assertIsNone(D)
Exemplo n.º 2
0
 def test_solve_fraction_largest_coefficient(self):
     res, D = lp_solve(self.c,
                       self.A,
                       self.b,
                       pivotrule=lambda D: largest_coefficient(D, eps=0))
     self.assertEqual(res, LPResult.INFEASIBLE)
     self.assertIsNone(D)
Exemplo n.º 3
0
 def test_solve(self):
     res, D = lp_solve(self.c, self.A, self.b)
     self.assertEqual(res, LPResult.OPTIMAL)
     self.assertIsNotNone(D)
     self.assertEqual(D.value(), Fraction(-3))
     self.assertEqual(list(D.basic_solution()),
                      [Fraction(4, 3), Fraction(1, 3)])
Exemplo n.º 4
0
 def test_solve_integer_bland(self):
     res, D = lp_solve(self.c, self.A, self.b, dtype=int)
     self.assertEqual(res, LPResult.OPTIMAL)
     self.assertIsNotNone(D)
     self.assertEqual(D.value(), Fraction(152, 13))
     self.assertEqual(list(D.basic_solution()),
                      [Fraction(30, 13), Fraction(1, 13)])
Exemplo n.º 5
0
 def test_solve_float(self):
     res, D = lp_solve(self.c, self.A, self.b, dtype=np.float64)
     self.assertEqual(res, LPResult.OPTIMAL)
     self.assertIsNotNone(D)
     self.assertAlmostEqual(D.value(), -3.0)
     self.assertAlmostEqual(list(D.basic_solution()),
                            [1.3333333333333335, 0.3333333333333333])
Exemplo n.º 6
0
 def test_solve_float(self):
     res, D = lp_solve(self.c, self.A, self.b, dtype=np.float64)
     self.assertEqual(res, LPResult.OPTIMAL)
     self.assertIsNotNone(D)
     self.assertAlmostEqual(D.value(), 13.0)
     for (a, b) in zip(list(D.basic_solution()), [2.0, 0.0, 1.0]):
         self.assertAlmostEqual(a, b)
Exemplo n.º 7
0
 def test_solve_float_largest_increase(self):
     res, D = lp_solve(self.c,
                       self.A,
                       self.b,
                       dtype=np.float64,
                       pivotrule=lambda D: largest_increase(D, eps=0))
     self.assertEqual(res, LPResult.INFEASIBLE)
     self.assertIsNone(D)
Exemplo n.º 8
0
 def test_solve_float_largest_coefficient(self):
     res, D = lp_solve(self.c,
                       self.A,
                       self.b,
                       dtype=np.float64,
                       pivotrule=lambda D: largest_coefficient(D, eps=0))
     self.assertEqual(res, LPResult.UNBOUNDED)
     self.assertIsNone(D)
Exemplo n.º 9
0
 def test_solve_fraction_largest_increase(self):
     res, D = lp_solve(self.c,
                       self.A,
                       self.b,
                       pivotrule=lambda D: largest_increase(D, eps=0))
     self.assertEqual(res, LPResult.OPTIMAL)
     self.assertIsNotNone(D)
     self.assertEqual(D.value(), Fraction(5))
     self.assertEqual(list(D.basic_solution()), [Fraction(2), Fraction(1)])
Exemplo n.º 10
0
 def test_solve_float_largest_increase(self):
     res, D = lp_solve(-self.c,
                       self.A,
                       self.b,
                       dtype=np.float64,
                       pivotrule=lambda D: largest_increase(D, eps=0))
     self.assertEqual(res, LPResult.OPTIMAL)
     self.assertIsNotNone(D)
     self.assertAlmostEqual(D.value(), -self.res.fun, 1)
Exemplo n.º 11
0
 def test_solve_float_largest_increase(self):
     res, D = lp_solve(self.c,
                       self.A,
                       self.b,
                       dtype=np.float64,
                       pivotrule=lambda D: largest_increase(D, eps=0))
     self.assertEqual(res, LPResult.OPTIMAL)
     self.assertIsNotNone(D)
     self.assertAlmostEqual(D.value(), 5.0)
     self.assertAlmostEqual(list(D.basic_solution()), [2.0, 1.0])
Exemplo n.º 12
0
 def test_solve_fraction_largest_coefficient(self):
     res, D = lp_solve(self.c,
                       self.A,
                       self.b,
                       pivotrule=lambda D: largest_coefficient(D, eps=0))
     self.assertEqual(res, LPResult.OPTIMAL)
     self.assertIsNotNone(D)
     self.assertEqual(D.value(), Fraction(-3))
     self.assertEqual(list(D.basic_solution()),
                      [Fraction(4, 3), Fraction(1, 3)])
Exemplo n.º 13
0
 def test_solve_fraction_bland_benchmark(self):
     reps = 3
     duration = timereps(
         reps, lambda: lp_solve(self.c,
                                self.A,
                                self.b,
                                dtype=Fraction,
                                pivotrule=lambda D: bland(D, eps=0)))
     print("TestBigLP1: It takes {} ms to run fraction, bland".format(
         round(duration * 1000, 2)))
Exemplo n.º 14
0
 def test_solve_float_largest_coefficient(self):
     res, D = lp_solve(self.c,
                       self.A,
                       self.b,
                       dtype=np.float64,
                       pivotrule=lambda D: largest_coefficient(D, eps=0))
     self.assertEqual(res, LPResult.OPTIMAL)
     self.assertIsNotNone(D)
     self.assertAlmostEqual(D.value(), -3.0)
     self.assertAlmostEqual(list(D.basic_solution()),
                            [1.3333333333333335, 0.3333333333333333])
Exemplo n.º 15
0
 def test_solve_int_largest_increase_benchmark(self):
     reps = 1000
     duration = timereps(
         reps,
         lambda: lp_solve(self.c,
                          self.A,
                          self.b,
                          dtype=int,
                          pivotrule=lambda D: largest_increase(D, eps=0)))
     print("It takes {} ms to run int, largest_increase".format(
         round(duration * 1000, 3)))
Exemplo n.º 16
0
 def test_solve_fraction_largest_coefficient_benchmark(self):
     reps = 1000
     duration = timereps(
         reps, lambda: lp_solve(self.c,
                                self.A,
                                self.b,
                                dtype=Fraction,
                                pivotrule=lambda D: largest_coefficient(
                                    D, eps=0)))
     print("It takes {} ms to run fraction, largest_coefficient".format(
         round(duration * 1000, 2)))
Exemplo n.º 17
0
 def test_solve_fraction_largest_increase_benchmark(self):
     reps = 10
     duration = timereps(
         reps,
         lambda: lp_solve(self.c,
                          self.A,
                          self.b,
                          dtype=Fraction,
                          pivotrule=lambda D: largest_increase(D, eps=0)))
     print("TestBigLP2: It takes {} ms to run Fraction, largest increase".
           format(round(duration * 1000, 2)))
Exemplo n.º 18
0
 def test_solve_integer_largest_increase(self):
     res, D = lp_solve(self.c,
                       self.A,
                       self.b,
                       dtype=int,
                       pivotrule=lambda D: largest_increase(D, eps=0))
     self.assertEqual(res, LPResult.OPTIMAL)
     self.assertIsNotNone(D)
     self.assertEqual(D.value(), Fraction(152, 13))
     self.assertEqual(list(D.basic_solution()),
                      [Fraction(30, 13), Fraction(1, 13)])
Exemplo n.º 19
0
 def test_solve_float_largest_coefficient_benchmark(self):
     reps = 3
     duration = timereps(
         reps, lambda: lp_solve(self.c,
                                self.A,
                                self.b,
                                dtype=np.float64,
                                pivotrule=lambda D: largest_coefficient(
                                    D, eps=0)))
     print("TestBigLP1: It takes {} ms to run float, largest coefficient".
           format(round(duration * 1000, 2)))
Exemplo n.º 20
0
 def test_solve(self):
     res, D = lp_solve(self.c, self.A, self.b)
     self.assertEqual(res, LPResult.INFEASIBLE)
     self.assertIsNone(D)
Exemplo n.º 21
0
 def test_solve_float_bland(self):
     res, D = lp_solve(-self.c, self.A, self.b, dtype=np.float64)
     self.assertEqual(res, LPResult.OPTIMAL)
     self.assertIsNotNone(D)
     self.assertAlmostEqual(D.value(), -self.res.fun, 1)
Exemplo n.º 22
0
 def test_solve_int_bland_benchmark(self):
     reps = 1000
     duration = timereps(
         reps, lambda: lp_solve(self.c, self.A, self.b, dtype=int))
     print("It takes {} ms to run int, bland".format(
         round(duration * 1000, 2)))
Exemplo n.º 23
0
 def test_solve_float_bland_benchmark(self):
     reps = 3
     duration = timereps(
         reps, lambda: lp_solve(self.c, self.A, self.b, dtype=np.float64))
     print("TestBigLP1: It takes {} ms to run float, bland".format(
         round(duration * 1000, 2)))
Exemplo n.º 24
0
 def test_solve(self):
     res, D = lp_solve(self.c, self.A, self.b)
     self.assertEqual(res, LPResult.UNBOUNDED)
     self.assertIsNone(D)
Exemplo n.º 25
0
 def test_solve_float(self):
     res, D = lp_solve(self.c, self.A, self.b, dtype=np.float64)
     self.assertEqual(res, LPResult.UNBOUNDED)
     self.assertIsNone(D)