/** * Buy an item. * @param item The item. */ public IFuture<ItemInfo> buyItem(final String item, final double price) { IBDIXAgentFeature capa = comp.getComponentFeature(IBDIXAgentFeature.class); final IGoal sell = capa.getGoalbase().createGoal("sell"); sell.getParameter("name").setValue(item); sell.getParameter("price").setValue(Double.valueOf(price)); return capa.getGoalbase().dispatchTopLevelGoal(sell); }
public void terminated(Exception reason) { IGoal[] goals = (IGoal[])capa.getGoalbase().getGoals("extinguish_fire"); for(int i=0; i<goals.length; i++) { // System.out.println("Dropping: "+goals[i]); goals[i].drop(); } } });;
IGoal[] exgoals = (IGoal[])capa.getGoalbase().getGoals("extinguish_fire"); if(exgoals.length>0) IGoal[] goals = (IGoal[])capa.getGoalbase().getGoals("clear_chemicals"); if(goals.length>0) final IGoal clearchem = capa.getGoalbase().createGoal("clear_chemicals"); clearchem.getParameter("disasterId").setValue(disasterId); capa.getGoalbase().dispatchTopLevelGoal(clearchem).addResultListener(new IResultListener<Object>()
/** * Create a goal from a template goal. * To be processed, the goal has to be dispatched as subgoal * or adopted as top-level goal. * @param type The template goal name as specified in the ADF. * @return The created goal. */ public IGoal createGoal(String type) { return getGoalbase().createGoal(type); }
/** * Dispatch a new top-level goal. * @param goal The new goal. * Note: plan step is interrupted after call. */ public void dispatchTopLevelGoal(IGoal goal) { getGoalbase().dispatchTopLevelGoal(goal); }
IGoal[] exgoals = (IGoal[])capa.getGoalbase().getGoals("extinguish_fire"); if(exgoals.length>0) IGoal[] goals = (IGoal[])capa.getGoalbase().getGoals("clear_chemicals"); if(goals.length>0) final IGoal exfire = (IGoal)capa.getGoalbase().createGoal("extinguish_fire"); exfire.getParameter("disasterId").setValue(disasterId); capa.getGoalbase().dispatchTopLevelGoal(exfire).addResultListener(new IResultListener<Object>()
IGoal dp = getScope().getGoalbase().createGoal("da_decide_participation"); dp.getParameter("auction_description").setValue(auctiondesc); dp.getParameter("initiator").setValue(initiator);
/** * Dispatch a top level goal. */ public IFuture<Object> dispatchTopLevelGoal(Object goal) { IBDIXAgentFeature bdif = component.getComponentFeature(IBDIXAgentFeature.class); return bdif.getGoalbase().dispatchTopLevelGoal((IGoal)goal); }
/** * Ask the seller for a a quote on a book. * @param title The book title. * @return The price. */ public IFuture<Integer> callForProposal(String title) { final Future<Integer> ret = new Future<Integer>(); final IGoal goal = agent.getGoalbase().createGoal("cnp_make_proposal"); goal.getParameter("cfp").setValue(title); agent.getGoalbase().dispatchTopLevelGoal(goal) .addResultListener(new ExceptionDelegationResultListener<Object, Integer>(ret) { public void customResultAvailable(Object result) { ret.setResult((Integer)goal.getParameter("proposal").getValue()); } }); return ret; }
IGoal dp = getScope().getGoalbase().createGoal("ea_decide_participation"); dp.getParameter("auction_description").setValue(auctiondesc); dp.getParameter("initiator").setValue(initiator);
/** * Dispatch a top level goal. */ public IFuture<Object> dispatchTopLevelGoal(Object goal) { IBDIXAgentFeature bdif = component.getComponentFeature(IBDIXAgentFeature.class); return bdif.getGoalbase().dispatchTopLevelGoal((IGoal)goal); }
public void terminated(Exception reason) { IGoal[] goals = (IGoal[])capa.getGoalbase().getGoals("clear_chemicals"); for(int i=0; i<goals.length; i++) { // System.out.println("Dropping: "+goals[i]); goals[i].drop(); } } });
/** * Buy a book * @param title The book title. * @param price The price to pay. * @return A future indicating if the transaction was successful. */ public IFuture<Void> acceptProposal(String title, int price) { final Future<Void> ret = new Future<Void>(); final IGoal goal = agent.getGoalbase().createGoal("cnp_execute_task"); goal.getParameter("cfp").setValue(title); goal.getParameter("proposal").setValue(Integer.valueOf(price)); agent.getGoalbase().dispatchTopLevelGoal(goal) .addResultListener(new ExceptionDelegationResultListener<Object, Void>(ret) { public void customResultAvailable(Object result) { ret.setResult(null); } }); return ret; }
IGoal goal = getGoalbase().createGoal("test"); try
bfx.getGoalbase().dispatchTopLevelGoal((IGoal)goal).addResultListener(lis);
/** * The body method is called on the * instatiated plan instance from the scheduler. */ public void body() { while(getGoalbase().getGoals("app_goal").length!=0) waitFor(100); TestReport tr = new TestReport("#1", "Test if meta-level reasoning works with retry."); if(((Integer)getBeliefbase().getBelief("result").getFact()).intValue()==2) { tr.setSucceeded(true); } else { tr.setReason("Not 2 plans have been executed."); } getBeliefbase().getBeliefSet("testcap.reports").addFact(tr); } }
final IGoal g = capa.getGoalbase().createGoal("reasoncall"); IFuture<Void> fut = capa.getGoalbase().dispatchTopLevelGoal(g); fut.addResultListener(new DelegationResultListener<Void>(ret)
public IFuture<Map<String, Object>> execute(IInternalAccess ia) final IGoal goal = ia.getComponentFeature(IBDIXAgentFeature.class).getGoalbase().createGoal(goaltype); if(parameters != null) ia.getComponentFeature(IBDIXAgentFeature.class).getGoalbase().dispatchTopLevelGoal(goal) .addResultListener(new IResultListener<Object>()
public IFuture<DrawData> execute(IInternalAccess ia) { IBDIXAgentFeature bdif = ia.getComponentFeature(IBDIXAgentFeature.class); DrawData drawdata = new DrawData(); drawdata.daytime = ((Boolean)bdif.getBeliefbase().getBelief("daytime").getFact()).booleanValue(); drawdata.visited_positions = (MapPoint[])bdif.getBeliefbase().getBeliefSet("visited_positions").getFacts(); drawdata.max_quantity = ((MapPoint)((IExpression)bdif.getExpressionbase().getExpression("query_max_quantity")).execute()).getQuantity(); drawdata.xcnt = ((Integer[])bdif.getBeliefbase().getBeliefSet("raster").getFacts())[0].intValue(); drawdata.ycnt = ((Integer[])bdif.getBeliefbase().getBeliefSet("raster").getFacts())[1].intValue(); drawdata.cleaners = (Cleaner[])bdif.getBeliefbase().getBeliefSet("cleaners").getFacts(); drawdata.chargingstations = (Chargingstation[])bdif.getBeliefbase().getBeliefSet("chargingstations").getFacts(); drawdata.wastebins = (Wastebin[])bdif.getBeliefbase().getBeliefSet("wastebins").getFacts(); drawdata.wastes = (Waste[])bdif.getBeliefbase().getBeliefSet("wastes").getFacts(); drawdata.my_vision = ((Double)bdif.getBeliefbase().getBelief("my_vision").getFact()).doubleValue(); drawdata.my_chargestate = ((Double)bdif.getBeliefbase().getBelief("my_chargestate").getFact()).doubleValue(); drawdata.my_location = (Location)bdif.getBeliefbase().getBelief("my_location").getFact(); drawdata.my_waste = bdif.getBeliefbase().getBelief("carriedwaste").getFact()!=null; IGoal[] goals = (IGoal[])bdif.getGoalbase().getGoals("achievemoveto"); drawdata.dests = new Location[goals.length]; for(int i=0; i<goals.length; i++) { drawdata.dests[i] = (Location)goals[i].getParameter("location").getValue(); } return new Future<DrawData>(drawdata); } }