Search in sources :

Example 11 with SimpleMapAgent

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

Example 12 with SimpleMapAgent

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

the class BidirectionalSearchTest method test_ABC_StartingAtGoal.

//
// Test IG(A)<->(B)<->(C)
@Test
public void test_ABC_StartingAtGoal() {
    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[] { "A" });
    me.addAgent(ma, "A");
    me.addEnvironmentView(new BDSEnvironmentView());
    me.stepUntilDone();
    Assert.assertEquals("CurrentLocation=In(A), Goal=In(A):Action[name==NoOp]:METRIC[pathCost]=0.0:METRIC[maxQueueSize]=0:METRIC[queueSize]=0:METRIC[nodesExpanded]=0: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 SimpleMapAgent

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

the class BidirectionalSearchTest method test_ABCDEF_ReverseFirstButNotFromOriginal.

/**
	 * <code>
	 * Test I(A)<->(B)<->(C)<->(D)<->(E)<->G(F)
	 *        +                       |
	 *        -------------------------
	 * </code>
	 */
@Test
public void test_ABCDEF_ReverseFirstButNotFromOriginal() {
    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.addUnidirectionalLink("E", "A", 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==B]:Action[name==moveTo, location==C]:Action[name==moveTo, location==D]:Action[name==moveTo, location==E]:Action[name==moveTo, location==F]:METRIC[pathCost]=25.0:METRIC[maxQueueSize]=2:METRIC[queueSize]=1:METRIC[nodesExpanded]=6: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 SimpleMapAgent

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

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

Aggregations

SimpleMapAgent (aima.core.environment.map.SimpleMapAgent)20 MapEnvironment (aima.core.environment.map.MapEnvironment)19 Test (org.junit.Test)19 ExtendableMap (aima.core.environment.map.ExtendableMap)15 UniformCostSearch (aima.core.search.uninformed.UniformCostSearch)3 MoveToAction (aima.core.environment.map.MoveToAction)2 Before (org.junit.Before)1