Search in sources :

Example 21 with MapEnvironment

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

the class BidirectionalSearchTest method test_ABCDEF_MoreComplexReverseFirstButNotFromOriginal.

/**
	 * <code>
	 *                          -------------
	 *                          +           +
	 * Test I(A)<->(B)<->(C)<->(D)<->(E)<-G(F)
	 *        +                       +
	 *        -------------------------
	 * </code>
	 */
@Test
public void test_ABCDEF_MoreComplexReverseFirstButNotFromOriginal() {
    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.addUnidirectionalLink("F", "E", 5.0);
    aMap.addBidirectionalLink("E", "A", 5.0);
    aMap.addBidirectionalLink("D", "F", 5.0);
    MapEnvironment me = new MapEnvironment(aMap);
    SimpleMapAgent ma = new SimpleMapAgent(me.getMap(), me, search, new String[] { "F" });
    me.addAgent(ma, "A");
    me.addEnvironmentView(new BDSEnvironmentView());
    me.stepUntilDone();
    Assert.assertEquals("CurrentLocation=In(A), Goal=In(F):Action[name==moveTo, location==E]:Action[name==moveTo, location==D]:Action[name==moveTo, location==F]:METRIC[pathCost]=15.0:METRIC[maxQueueSize]=3:METRIC[queueSize]=3: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 22 with MapEnvironment

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

the class BidirectionalSearchTest method test_ABC_ReverseOnlyPath.

//
// Test I(A)<-(B)<-G(C)
@Test
public void test_ABC_ReverseOnlyPath() {
    ExtendableMap aMap = new ExtendableMap();
    aMap.addUnidirectionalLink("B", "A", 5.0);
    aMap.addUnidirectionalLink("C", "B", 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==NoOp]:METRIC[pathCost]=0:METRIC[maxQueueSize]=2:METRIC[queueSize]=0:METRIC[nodesExpanded]=2: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 23 with MapEnvironment

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

the class BidirectionalSearchTest method test_AB_BothWaysPath.

//
// Test I(A)<->G(B)
@Test
public void test_AB_BothWaysPath() {
    ExtendableMap aMap = new ExtendableMap();
    aMap.addBidirectionalLink("A", "B", 5.0);
    MapEnvironment me = new MapEnvironment(aMap);
    SimpleMapAgent ma = new SimpleMapAgent(me.getMap(), me, search, new String[] { "B" });
    me.addAgent(ma, "A");
    me.addEnvironmentView(new BDSEnvironmentView());
    me.stepUntilDone();
    Assert.assertEquals("CurrentLocation=In(A), Goal=In(B):Action[name==moveTo, location==B]:METRIC[pathCost]=5.0:METRIC[maxQueueSize]=2:METRIC[queueSize]=1:METRIC[nodesExpanded]=1: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 24 with MapEnvironment

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

the class BidirectionalSearchTest method test_ABC_OriginalOnlyPath.

//
// Test I(A)->(B)->G(C)
@Test
public void test_ABC_OriginalOnlyPath() {
    ExtendableMap aMap = new ExtendableMap();
    aMap.addUnidirectionalLink("A", "B", 5.0);
    aMap.addUnidirectionalLink("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]=0: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 25 with MapEnvironment

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

the class BidirectionalSearchTest method test_AB_OriginalOnlyPath.

//
// Test I(A)->G(B)
@Test
public void test_AB_OriginalOnlyPath() {
    ExtendableMap aMap = new ExtendableMap();
    aMap.addUnidirectionalLink("A", "B", 5.0);
    MapEnvironment me = new MapEnvironment(aMap);
    SimpleMapAgent ma = new SimpleMapAgent(me.getMap(), me, search, new String[] { "B" });
    me.addAgent(ma, "A");
    me.addEnvironmentView(new BDSEnvironmentView());
    me.stepUntilDone();
    Assert.assertEquals("CurrentLocation=In(A), Goal=In(B):Action[name==moveTo, location==B]:METRIC[pathCost]=5.0:METRIC[maxQueueSize]=2:METRIC[queueSize]=1:METRIC[nodesExpanded]=1: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)

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