Search in sources :

Example 11 with MapEnvironment

use of aima.core.environment.map.MapEnvironment in project aima-java by aimacode.

the class BidirectionalSearchTest method test_ABCDE_OriginalOnlyPath.

//
// Test I(A)->(B)->(C)<->(D)<->G(E)
@Test
public void test_ABCDE_OriginalOnlyPath() {
    ExtendableMap aMap = new ExtendableMap();
    aMap.addBidirectionalLink("A", "B", 5.0);
    aMap.addUnidirectionalLink("B", "C", 5.0);
    aMap.addBidirectionalLink("C", "D", 5.0);
    aMap.addBidirectionalLink("D", "E", 5.0);
    MapEnvironment me = new MapEnvironment(aMap);
    SimpleMapAgent ma = new SimpleMapAgent(me.getMap(), me, search, new String[] { "E" });
    me.addAgent(ma, "A");
    me.addEnvironmentView(new BDSEnvironmentView());
    me.stepUntilDone();
    Assert.assertEquals("CurrentLocation=In(A), Goal=In(E):Action[name==moveTo, location==B]:Action[name==moveTo, location==C]:Action[name==moveTo, location==D]:Action[name==moveTo, location==E]:METRIC[pathCost]=20.0:METRIC[maxQueueSize]=2:METRIC[queueSize]=1:METRIC[nodesExpanded]=5:Action[name==NoOp]:", envChanges.toString());
}
Also used : SimpleMapAgent(aima.core.environment.map.SimpleMapAgent) MapEnvironment(aima.core.environment.map.MapEnvironment) ExtendableMap(aima.core.environment.map.ExtendableMap) Test(org.junit.Test)

Example 12 with MapEnvironment

use of aima.core.environment.map.MapEnvironment in project aima-java by aimacode.

the class BidirectionalSearchTest method test_ABCDEF_OriginalFirst.

/**
	 * <code>
	 * Test I(A)<->(B)<->(C)<->(D)<->(E)<->(F)<->(G)<->G(H)
	 *              |                                    +
	 *              --------------------------------------
	 * </code>
	 */
@Test
public void test_ABCDEF_OriginalFirst() {
    ExtendableMap aMap = new ExtendableMap();
    aMap.addBidirectionalLink("A", "B", 5.0);
    aMap.addBidirectionalLink("B", "C", 5.0);
    aMap.addBidirectionalLink("C", "D", 5.0);
    aMap.addBidirectionalLink("D", "E", 5.0);
    aMap.addBidirectionalLink("E", "F", 5.0);
    aMap.addBidirectionalLink("F", "G", 5.0);
    aMap.addBidirectionalLink("G", "H", 5.0);
    aMap.addUnidirectionalLink("B", "H", 5.0);
    MapEnvironment me = new MapEnvironment(aMap);
    SimpleMapAgent ma = new SimpleMapAgent(me.getMap(), me, search, new String[] { "H" });
    me.addAgent(ma, "A");
    me.addEnvironmentView(new BDSEnvironmentView());
    me.stepUntilDone();
    Assert.assertEquals("CurrentLocation=In(A), Goal=In(H):Action[name==moveTo, location==B]:Action[name==moveTo, location==H]:METRIC[pathCost]=10.0:METRIC[maxQueueSize]=2:METRIC[queueSize]=2:METRIC[nodesExpanded]=3:Action[name==NoOp]:", envChanges.toString());
}
Also used : SimpleMapAgent(aima.core.environment.map.SimpleMapAgent) MapEnvironment(aima.core.environment.map.MapEnvironment) ExtendableMap(aima.core.environment.map.ExtendableMap) Test(org.junit.Test)

Example 13 with MapEnvironment

use of aima.core.environment.map.MapEnvironment in project aima-java by aimacode.

the class BidirectionalSearchTest method test_ABC_BothWaysPath.

//
// Test I(A)<->(B)<->G(C)
@Test
public void test_ABC_BothWaysPath() {
    ExtendableMap aMap = new ExtendableMap();
    aMap.addBidirectionalLink("A", "B", 5.0);
    aMap.addBidirectionalLink("B", "C", 5.0);
    MapEnvironment me = new MapEnvironment(aMap);
    SimpleMapAgent ma = new SimpleMapAgent(me.getMap(), me, search, new String[] { "C" });
    me.addAgent(ma, "A");
    me.addEnvironmentView(new BDSEnvironmentView());
    me.stepUntilDone();
    Assert.assertEquals("CurrentLocation=In(A), Goal=In(C):Action[name==moveTo, location==B]:Action[name==moveTo, location==C]:METRIC[pathCost]=10.0:METRIC[maxQueueSize]=2:METRIC[queueSize]=1:METRIC[nodesExpanded]=3:Action[name==NoOp]:", envChanges.toString());
}
Also used : SimpleMapAgent(aima.core.environment.map.SimpleMapAgent) MapEnvironment(aima.core.environment.map.MapEnvironment) ExtendableMap(aima.core.environment.map.ExtendableMap) Test(org.junit.Test)

Example 14 with MapEnvironment

use of aima.core.environment.map.MapEnvironment in project aima-java by aimacode.

the class MapAgentTest method testNormalSearchGraphSearchMinFrontier.

@Test
public void testNormalSearchGraphSearchMinFrontier() {
    MapEnvironment me = new MapEnvironment(aMap);
    UniformCostSearch<String, MoveToAction> ucSearch = new UniformCostSearch<>(new GraphSearchReducedFrontier<>());
    SimpleMapAgent ma = new SimpleMapAgent(me.getMap(), me, ucSearch, new String[] { "D" });
    me.addAgent(ma, "A");
    me.addEnvironmentView(new TestEnvironmentView());
    me.stepUntilDone();
    Assert.assertEquals("CurrentLocation=In(A), Goal=In(D):Action[name==moveTo, location==C]:Action[name==moveTo, location==D]:METRIC[pathCost]=13.0:METRIC[maxQueueSize]=2:METRIC[queueSize]=1:METRIC[nodesExpanded]=3:Action[name==NoOp]:", envChanges.toString());
}
Also used : UniformCostSearch(aima.core.search.uninformed.UniformCostSearch) SimpleMapAgent(aima.core.environment.map.SimpleMapAgent) MapEnvironment(aima.core.environment.map.MapEnvironment) MoveToAction(aima.core.environment.map.MoveToAction) Test(org.junit.Test)

Example 15 with MapEnvironment

use of aima.core.environment.map.MapEnvironment in project aima-java by aimacode.

the class MapEnvironmentTest method setUp.

@Before
public void setUp() {
    ExtendableMap aMap = new ExtendableMap();
    aMap.addBidirectionalLink("A", "B", 5.0);
    aMap.addBidirectionalLink("A", "C", 6.0);
    aMap.addBidirectionalLink("B", "C", 4.0);
    aMap.addBidirectionalLink("C", "D", 7.0);
    aMap.addUnidirectionalLink("B", "E", 14.0);
    me = new MapEnvironment(aMap);
    ma = new SimpleMapAgent(me.getMap(), me, new UniformCostSearch(), new String[] { "A" });
}
Also used : UniformCostSearch(aima.core.search.uninformed.UniformCostSearch) SimpleMapAgent(aima.core.environment.map.SimpleMapAgent) MapEnvironment(aima.core.environment.map.MapEnvironment) ExtendableMap(aima.core.environment.map.ExtendableMap) Before(org.junit.Before)

Aggregations

MapEnvironment (aima.core.environment.map.MapEnvironment)31 Test (org.junit.Test)25 SimpleMapAgent (aima.core.environment.map.SimpleMapAgent)19 ExtendableMap (aima.core.environment.map.ExtendableMap)17 MoveToAction (aima.core.environment.map.MoveToAction)8 GeneralProblem (aima.core.search.framework.problem.GeneralProblem)7 GoalTest (aima.core.search.framework.problem.GoalTest)7 LRTAStarAgent (aima.core.search.online.LRTAStarAgent)4 OnlineDFSAgent (aima.core.search.online.OnlineDFSAgent)4 UniformCostSearch (aima.core.search.uninformed.UniformCostSearch)2 ArrayList (java.util.ArrayList)2 Agent (aima.core.agent.Agent)1 Point2D (aima.core.util.math.geom.shapes.Point2D)1 MapNode (aimax.osm.data.entities.MapNode)1 Before (org.junit.Before)1