Beispiel #1
0
 def test_minimizeB1(self):
     """Beam Search optimisation problem (longer) (beam=3, minimize)"""
     #beamsize has been set to the minimum that yields the correct solution
     goalstate = InformedReorderSearchState("This is supposed to be a very long sentence .".split(' '))
     informedinputstate = InformedReorderSearchState("a long very . sentence supposed to be This is".split(' '), goalstate)
     search = BeamSearch(informedinputstate, beamsize=3, graph=True, minimize=True,debug=False)
     solution = search.searchbest()
     self.assertEqual(str(solution),str(goalstate))
Beispiel #2
0
 def test_minimizeA1(self):
     """Beam Search optimisation problem A (beam=2, minimize)"""
     #beamsize has been set to the minimum that yields the correct solution
     global informedinputstate, solution, goalstate
     search = BeamSearch(informedinputstate, beamsize=2, graph=True, minimize=True,debug=0)
     solution = search.searchbest()
     self.assertEqual( str(solution), str(goalstate) )
     self.assertTrue( search.solutions > 1 ) #everything is a solution
Beispiel #3
0
 def test_minimizeA2(self):
     """Beam Search optimisation problem A (beam=100, minimize)"""
     #if a small beamsize works, a very large one should too
     global informedinputstate, solution, goalstate
     search = BeamSearch(informedinputstate, beamsize=100, graph=True, minimize=True,debug=0)
     solution = search.searchbest()
     self.assertEqual( str(solution), str(goalstate) )   
     self.assertTrue( search.solutions > 1 ) #everything is a solution
Beispiel #4
0
 def test_minimizeC1(self):
     """Beam Search needle-in-haystack problem (beam=2, minimize)"""
     #beamsize has been set to the minimum that yields the correct solution
     global informedinputstate, solution, goalstate
     search = BeamSearch(informedinputstate, beamsize=2, graph=True, minimize=True,debug=0, goal=goalstate)
     solution = search.searchbest()
     self.assertEqual( str(solution), str(goalstate) )
     self.assertEqual( search.solutions, 1 )
Beispiel #5
0
 def test_minimizeA2(self):
     """Beam Search optimisation problem A (beam=100, minimize)"""
     #if a small beamsize works, a very large one should too
     global informedinputstate, solution, goalstate
     search = BeamSearch(informedinputstate,
                         beamsize=100,
                         graph=True,
                         minimize=True,
                         debug=0)
     solution = search.searchbest()
     self.assertEqual(str(solution), str(goalstate))
     self.assertTrue(search.solutions > 1)  #everything is a solution
Beispiel #6
0
 def test_minimizeA1(self):
     """Beam Search optimisation problem A (beam=2, minimize)"""
     #beamsize has been set to the minimum that yields the correct solution
     global informedinputstate, solution, goalstate
     search = BeamSearch(informedinputstate,
                         beamsize=2,
                         graph=True,
                         minimize=True,
                         debug=0)
     solution = search.searchbest()
     self.assertEqual(str(solution), str(goalstate))
     self.assertTrue(search.solutions > 1)  #everything is a solution
Beispiel #7
0
 def test_minimizeC1(self):
     """Beam Search needle-in-haystack problem (beam=2, minimize)"""
     #beamsize has been set to the minimum that yields the correct solution
     global informedinputstate, solution, goalstate
     search = BeamSearch(informedinputstate,
                         beamsize=2,
                         graph=True,
                         minimize=True,
                         debug=0,
                         goal=goalstate)
     solution = search.searchbest()
     self.assertEqual(str(solution), str(goalstate))
     self.assertEqual(search.solutions, 1)
Beispiel #8
0
 def test_minimizeB1(self):
     """Beam Search optimisation problem (longer) (beam=3, minimize)"""
     #beamsize has been set to the minimum that yields the correct solution
     goalstate = InformedReorderSearchState(
         "This is supposed to be a very long sentence .".split(' '))
     informedinputstate = InformedReorderSearchState(
         "a long very . sentence supposed to be This is".split(' '),
         goalstate)
     search = BeamSearch(informedinputstate,
                         beamsize=3,
                         graph=True,
                         minimize=True,
                         debug=False)
     solution = search.searchbest()
     self.assertEqual(str(solution), str(goalstate))