在我的模型中,我希望我的運輸車隊的代理型別每秒計算一次在該運輸車 2 米范圍內是否還有其他代理(人員),如果有,它應該減慢速度。我知道一些如何編碼,但由于我習慣于 python 而不是 java,我發現很難真正知道如何編碼,所以目前我在每秒運行一次的 AGV 的代理型別中創建了一個事件(這是傳輸器的代理型別)。
在代碼框中,我想要這樣的東西,但不知道具體如何:
for person (if person.walking=true) in personpopulation:
if double distanceTo(person)<2:
unit.setspeed(0.05)
break // Since knowing that one agent is close is enough.
unit.setspeed(2) // if there is no agent close he did not break and reaches this part of the code.
但是你如何在 java/anylogic 中準確地編碼這個
現狀畫面:在方法一中,我使用了簡單的方法,只添加了設定速度功能。

比我也試過這個,在模型中看到代理的 maxspeed 引數發生了變化,但 AGV 的運動并沒有減慢。

uj5u.com熱心網友回復:
以下代碼應該可以作業:
for (Person currPerson : personPopulation) {
if (currPerson.walking==true) {
for (AGV currAgv: agvPopulation) {
if (currPerson.distanceTo(currAgv)<2){
currAgv.setMaximumSpeed(0.05,MPS);
}
}
}
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/396687.html
下一篇:為什么陣列不列印?
