示例#1
0
 def test_solve_5(self):
     S = scarf.gen_random_instance(num_single=20,
                                   num_couple=10,
                                   num_hospital=10,
                                   single_pref_len=5,
                                   couple_pref_len=10)
     self.run_solve(S)
示例#2
0
 def test_small(self):
     S = scarf.gen_random_instance(num_single=2,
                                   num_couple=0,
                                   num_hospital=2)
     self.assertEqual(S.num_single, 2)
     self.assertEqual(S.num_couple, 0)
     self.assertEqual(S.num_hospital, 2)
示例#3
0
 def run_rounding(self):
     S = scarf.gen_random_instance(num_single=10,
                                   num_couple=200,
                                   num_hospital=15,
                                   single_pref_len=10,
                                   couple_pref_len=150,
                                   ihp=True)
     sol = scarf.solve(S)
     int_sol = scarf.round(sol, S)
     self.assertGreater(
         sum(sol.act_hospital_cap) + 4 + 1e-6,
         sum(int_sol.act_hospital_cap))
     self.assertTrue(
         np.all(
             int_sol.act_hospital_cap - sol.act_hospital_cap <= 2 + 1e-6))
     self.assertFalse(
         np.any([(sol[p] < 1e-6) & (int_sol[p] > 1e-6)
                 for p in S.admissible_plans()]))
     self.assertFalse(
         np.any([(sol[p] > 1 - 1e-6) & (int_sol[p] < 1 - 1e-6)
                 for p in S.admissible_plans()]))
示例#4
0
 def test_solve_4(self):
     S = scarf.gen_random_instance(num_single=20,
                                   num_couple=0,
                                   num_hospital=10)
     self.run_solve(S)
示例#5
0
 def test_solve_2(self):
     S = scarf.gen_random_instance(num_single=2,
                                   num_couple=2,
                                   num_hospital=2,
                                   ihp=False)
     self.run_solve(S)
示例#6
0
 def test_ihp(self):
     S = scarf.gen_random_instance(num_single=10,
                                   num_couple=20,
                                   num_hospital=10,
                                   ihp=True)
     self.run_test(S)
示例#7
0
 def test_1_hosp(self):
     S = scarf.gen_random_instance(num_single=0,
                                   num_couple=2,
                                   num_hospital=1)
     self.run_test(S)