[英]How many agents JADE handle on contract net protocol
我的問題是JADE在使用合約網絡協議時可以處理多少個代理? 我在同一個容器上有一個 ContractNetInitiator 代理和 130 個 ContractNetResponder。 用於創建這些代理的代碼如下:
ProfileImpl profileImpl2 = new ProfileImpl(false);
profileImpl2.setParameter(ProfileImpl.MAIN_HOST, "localhost");
AgentContainer agentContainer = runtime.createAgentContainer(profileImpl2);
AgentController v;
for (int i=0; i<130; i++){ //8 est le nombre d'agents véhicules
v=agentContainer.createNewAgent("vehicle"+i, "VehicleAgent", new Object[]{});
v.start(); }
和
try {
// Register the vehicle-transporting service in the yellow pages
dfd = new DFAgentDescription();
dfd.setName(getAID());
ServiceDescription sd = new ServiceDescription();
sd.setName("Transport Of Items");
sd.setType("Transport");
dfd.addServices(sd);
DFService.register(this, dfd);
} catch (FIPAException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
ContractNetInitiator 只找到了 100 個代理。我用來搜索這些代理的代碼如下:
try {
// search list of Vehicle agents
template = new DFAgentDescription();
sd = new ServiceDescription();
sd.setType("Transport");
template.addServices(sd);
DFAgentDescription[] result = DFService.search(this, template);
if (result.length > 0) {
vehicleAgentsD = new AID[result.length];
log.info("Agent Dispatcher Agent found this vehicle's Agents :");
for (int i = 0; i < result.length; ++i) {
vehicleAgentsD[i] = result[i].getName();
log.info("VA" + i + "===>" + vehicleAgentsD[i].getName());
}
} else {
System.out.println("Agent " + getLocalName() + " did not find any service");
}
} catch (FIPAException fe) {
fe.printStackTrace();
}
這個錯誤是與 JADE 的限制有關還是與我的計算機性能有關? 預先感謝您的回答。
DFService
似乎對它返回的結果數量有一個默認限制設置為 100。您可以通過為DFService.search()
方法設置適當的SearchConstraints
來降低它,如下所示
SearchConstraints getAll = new SearchConstraints();
getAll.setMaxResults(new Long(max_results));
DFAgentDescription dfd = new DFAgentDescription();
ServiceDescription sd = new ServiceDescription();
sd.setType( "service-proxy" );
dfd.addServices(sd);
DFAgentDescription[] result = DFService.search(this, dfd,getAll);
為了增加該值,您需要將屬性jade_domain_df_maxresult
設置為更高的值,並在創建時將其提供給容器:
Profile pMain = new ProfileImpl(null, 8888, null);
pMain.setParameter("jade_domain_df_maxresult", "1000");
AgentContainer mc = rt.createMainContainer(pMain);
感謝 Farida 提到了我原來的答案的問題並指出了正確的解決方案。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.