Search in sources :

Example 6 with UniformCostSearch

use of aima.core.search.uninformed.UniformCostSearch in project aima-java by aimacode.

the class UniformCostSearchTest method testUniformCostUnSuccesfulSearch.

@Test
public void testUniformCostUnSuccesfulSearch() throws Exception {
    Problem<NQueensBoard, QueenAction> problem = new GeneralProblem<>(new NQueensBoard(3), NQueensFunctions::getIFActions, NQueensFunctions::getResult, NQueensFunctions::testGoal);
    SearchForActions<NQueensBoard, QueenAction> search = new UniformCostSearch<>();
    SearchAgent<NQueensBoard, QueenAction> agent = new SearchAgent<>(problem, search);
    List<Action> actions = agent.getActions();
    Assert.assertEquals(0, actions.size());
    Assert.assertEquals("6", agent.getInstrumentation().getProperty("nodesExpanded"));
    // Will be 0 as did not reach goal state.
    Assert.assertEquals("0", agent.getInstrumentation().getProperty("pathCost"));
}
Also used : NQueensFunctions(aima.core.environment.nqueens.NQueensFunctions) Action(aima.core.agent.Action) QueenAction(aima.core.environment.nqueens.QueenAction) UniformCostSearch(aima.core.search.uninformed.UniformCostSearch) QueenAction(aima.core.environment.nqueens.QueenAction) SearchAgent(aima.core.search.framework.SearchAgent) NQueensBoard(aima.core.environment.nqueens.NQueensBoard) GeneralProblem(aima.core.search.framework.problem.GeneralProblem) Test(org.junit.Test) GoalTest(aima.core.search.framework.problem.GoalTest)

Aggregations

UniformCostSearch (aima.core.search.uninformed.UniformCostSearch)6 Test (org.junit.Test)5 MoveToAction (aima.core.environment.map.MoveToAction)3 SimpleMapAgent (aima.core.environment.map.SimpleMapAgent)3 SearchAgent (aima.core.search.framework.SearchAgent)3 GeneralProblem (aima.core.search.framework.problem.GeneralProblem)3 GoalTest (aima.core.search.framework.problem.GoalTest)3 Action (aima.core.agent.Action)2 MapEnvironment (aima.core.environment.map.MapEnvironment)2 NQueensBoard (aima.core.environment.nqueens.NQueensBoard)2 NQueensFunctions (aima.core.environment.nqueens.NQueensFunctions)2 QueenAction (aima.core.environment.nqueens.QueenAction)2 ExtendableMap (aima.core.environment.map.ExtendableMap)1 Map (aima.core.environment.map.Map)1 SimplifiedRoadMapOfPartOfRomania (aima.core.environment.map.SimplifiedRoadMapOfPartOfRomania)1 Node (aima.core.search.framework.Node)1 Before (org.junit.Before)1