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)
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)
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)])
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)])
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])
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)
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)
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)
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)])
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)
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])
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)])
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)))
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])
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)))
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)))
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)))
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)])
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)))
def test_solve(self): res, D = lp_solve(self.c, self.A, self.b) self.assertEqual(res, LPResult.INFEASIBLE) self.assertIsNone(D)
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)
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)))
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)))
def test_solve(self): res, D = lp_solve(self.c, self.A, self.b) self.assertEqual(res, LPResult.UNBOUNDED) self.assertIsNone(D)
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)