Search in sources :

Example 16 with ExtendableMap

use of aima.core.environment.map.ExtendableMap 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 17 with ExtendableMap

use of aima.core.environment.map.ExtendableMap 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 18 with ExtendableMap

use of aima.core.environment.map.ExtendableMap 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 19 with ExtendableMap

use of aima.core.environment.map.ExtendableMap 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)

Example 20 with ExtendableMap

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

the class OnlineDFSAgentTest method setUp.

@Before
public void setUp() {
    aMap = new ExtendableMap();
    aMap.addBidirectionalLink("A", "B", 5.0);
    aMap.addBidirectionalLink("A", "C", 6.0);
    aMap.addBidirectionalLink("B", "D", 4.0);
    aMap.addBidirectionalLink("B", "E", 7.0);
    aMap.addBidirectionalLink("D", "F", 4.0);
    aMap.addBidirectionalLink("D", "G", 8.0);
    envChanges = new StringBuffer();
}
Also used : ExtendableMap(aima.core.environment.map.ExtendableMap) Before(org.junit.Before)

Aggregations

ExtendableMap (aima.core.environment.map.ExtendableMap)22 MapEnvironment (aima.core.environment.map.MapEnvironment)17 Test (org.junit.Test)16 SimpleMapAgent (aima.core.environment.map.SimpleMapAgent)15 Before (org.junit.Before)6 MoveToAction (aima.core.environment.map.MoveToAction)2 GeneralProblem (aima.core.search.framework.problem.GeneralProblem)2 GoalTest (aima.core.search.framework.problem.GoalTest)2 OnlineDFSAgent (aima.core.search.online.OnlineDFSAgent)2 UniformCostSearch (aima.core.search.uninformed.UniformCostSearch)1