Search in sources :

Example 6 with ExtendableMap

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

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

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

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

the class MapAgentTest method setUp.

@Before
public void setUp() {
    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);
    envChanges = new StringBuffer();
}
Also used : ExtendableMap(aima.core.environment.map.ExtendableMap) Before(org.junit.Before)

Example 10 with ExtendableMap

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

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