Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
autumn_rrs
autumn_agent_2023
Commits
b6aaede1
Commit
b6aaede1
authored
Nov 07, 2023
by
Ryosuke Suzuki
Browse files
Merge branch 'analysis_hungarian' into 'develop'
Analysis hungarian See merge request
!2
parents
41657e3a
af8744d9
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/main/java/autumn_2023/module/complex/CentralizedControlFBAllocator.java
View file @
b6aaede1
...
...
@@ -181,33 +181,40 @@ public class CentralizedControlFBAllocator extends FireTargetAllocator {
super
.
updateInfo
(
messageManager
);
Set
<
EntityID
>
recievetasks
=
messageManager
.
getReceivedMessageList
(
MessageCivilian
.
class
).
stream
()
.
map
(
e
->
{
MessageCivilian
mesciv
=
(
MessageCivilian
)
e
;
MessageUtil
.
reflectMessage
(
this
.
worldInfo
,
mesciv
);
return
(
mesciv
);
})
.
map
(
MessageCivilian:
:
getAgentID
)
.
filter
(
e
->
this
.
isNeedRescueHuman
(
this
.
worldInfo
.
getEntity
(
e
)))
.
filter
(
e
->
!(
finishEntityIDs
.
contains
(
e
)))
.
collect
(
Collectors
.
toSet
());
.
map
(
e
->
{
MessageCivilian
mesciv
=
(
MessageCivilian
)
e
;
MessageUtil
.
reflectMessage
(
this
.
worldInfo
,
mesciv
);
return
(
mesciv
);
})
.
map
(
MessageCivilian:
:
getAgentID
)
.
filter
(
e
->
this
.
isNeedRescueHuman
(
this
.
worldInfo
.
getEntity
(
e
)))
.
filter
(
e
->
!(
finishEntityIDs
.
contains
(
e
)))
.
collect
(
Collectors
.
toSet
());
this
.
taskSet
.
addAll
(
recievetasks
);
// 消防隊の情報をリセット
for
(
EntityID
fbid
:
this
.
fireBrigadeInfoMap
.
keySet
()){
FireBrigadeInfo
fbi
=
this
.
fireBrigadeInfoMap
.
get
(
fbid
);
fbi
.
resetInfo
();
}
List
<
EntityID
>
fblist
=
new
ArrayList
<>();
List
<
CommunicationMessage
>
mesfblist
=
messageManager
.
getReceivedMessageList
(
MessageFireBrigade
.
class
);
for
(
CommunicationMessage
mes
:
mesfblist
){
MessageFireBrigade
mesfb
=
(
MessageFireBrigade
)
mes
;
MessageUtil
.
reflectMessage
(
this
.
worldInfo
,
mesfb
);
EntityID
fbID
=
mesfb
.
getAgentID
();
fblist
.
add
(
fbID
);
FireBrigadeInfo
fbi
=
this
.
fireBrigadeInfoMap
.
get
(
fbID
);
fbi
.
setInfo
(
mesfb
.
getTargetID
(),
mesfb
.
getPosition
(),
mesfb
.
getBuriedness
(),
(
mesfb
.
getAction
()
==
MessageFireBrigade
.
ACTION_RESCUE
)
?
false
:
true
,
this
.
agentInfo
.
getTime
());
}
List
<
EntityID
>
reportlist
=
messageManager
.
getReceivedMessageList
(
MessageReport
.
class
).
stream
()
.
map
(
MessageReport
.
class
::
cast
)
.
filter
(
MessageReport:
:
isDone
)
.
map
(
MessageReport:
:
getFromID
)
.
collect
(
Collectors
.
toList
());
.
map
(
MessageReport
.
class
::
cast
)
.
filter
(
MessageReport:
:
isDone
)
.
map
(
MessageReport:
:
getFromID
)
.
collect
(
Collectors
.
toList
());
this
.
finishEntityIDs
.
addAll
(
reportlist
);
this
.
taskSet
.
removeAll
(
reportlist
);
...
...
@@ -294,5 +301,16 @@ public class CentralizedControlFBAllocator extends FireTargetAllocator {
this
.
canNewAction
=
canNewAction
;
this
.
commandTime
=
commandTime
;
}
/**
* 消防隊に関する情報をリセットするメソッド
*/
public
void
resetInfo
(){
prevtarget
=
null
;
position
=
null
;
buriedness
=
-
1
;
target
=
null
;
canNewAction
=
true
;
commandTime
=
-
1
;
}
}
}
\ No newline at end of file
src/main/java/autumn_2023/module/complex/SampleSearch.java
View file @
b6aaede1
...
...
@@ -14,6 +14,7 @@ import adf.core.agent.develop.DevelopData;
import
rescuecore2.standard.entities.*
;
import
rescuecore2.worldmodel.EntityID
;
import
java.util.*
;
import
java.util.stream.Collector
;
import
java.util.stream.Collectors
;
import
static
java
.
lang
.
Double
.
POSITIVE_INFINITY
;
...
...
@@ -57,11 +58,39 @@ public class SampleSearch extends Search
List
<
CommunicationMessage
>
messages
=
mm
.
getReceivedMessageList
();
this
.
messageManager
=
mm
;
int
idx
=
this
.
clustering
.
getClusterIndex
(
this
.
agentInfo
.
me
());
Collection
<
EntityID
>
cluster
=
this
.
clustering
.
getClusterEntityIDs
(
idx
);
if
(
cluster
==
null
)
return
this
;
// エージェントが動けるステップではないなら
if
(
this
.
agentInfo
.
getTime
()
<
this
.
scenarioInfo
.
getKernelAgentsIgnoreuntil
())
return
this
;
// エージェントが動けるステップのはじめに
if
(
this
.
agentInfo
.
getTime
()
==
this
.
scenarioInfo
.
getKernelAgentsIgnoreuntil
()){
this
.
list
=
new
ArrayList
<>(
cluster
);
}
// エージェントが現在位置する建物や道路のIDを取得する
EntityID
position
=
this
.
agentInfo
.
getPosition
();
// 探索済みの (辿り着いたことがある) 対象を候補から除外する
this
.
searchedSet
.
add
(
position
);
// 探索済みの (辿り着いたことがある) 対象を候補から除外する
list
.
removeAll
(
this
.
searchedSet
);
// クラスタ内の建物や道路のIDリストから建物のIDリストを取得
List
<
EntityID
>
buildinglist
=
this
.
list
.
stream
()
// listのストリームを取得
.
map
(
this
.
worldInfo
::
getEntity
)
// EntityIDをStandardEntityに変換
.
filter
(
e
->
(
e
instanceof
Building
))
// StandardEntityオブジェクトのうちBuildingクラスのものだけ抽出
.
map
(
StandardEntity:
:
getID
)
// StandardEntityをEntityIDに変換
.
collect
(
Collectors
.
toList
());
// ストリームをリストにして取得
// すべての対象が探索済みの場合,探索済みリストをリセット候補をリセットする
if
(
buildinglist
.
isEmpty
()){
this
.
searchedSet
.
clear
();
this
.
list
=
new
ArrayList
<>(
cluster
);
}
return
this
;
}
...
...
@@ -69,24 +98,17 @@ public class SampleSearch extends Search
@Override
public
Search
calc
()
{
// エージェントが動けるステップではないなら
if
(
this
.
agentInfo
.
getTime
()
<
this
.
scenarioInfo
.
getKernelAgentsIgnoreuntil
())
return
this
;
EntityID
me
=
this
.
agentInfo
.
getID
();
int
idx
=
this
.
clustering
.
getClusterIndex
(
me
);
if
(
idx
==
-
1
)
{
return
this
;
}
//System.out.println("time:"+this.agentInfo.getTime()+" id:"+me+" target:"+this.getTarget());
if
(
idx
==
-
1
)
return
this
;
Collection
<
EntityID
>
cluster
=
this
.
clustering
.
getClusterEntityIDs
(
idx
);
if
(
cluster
==
null
)
{
return
this
;
}
Collection
<
EntityID
>
cluster
=
this
.
clustering
.
getClusterEntityIDs
(
idx
);
if
(
cluster
==
null
)
return
this
;
// Listに変換
if
(
this
.
result
==
null
){
list
=
new
ArrayList
<>(
cluster
);
//System.out.println(list);
}
//System.out.println("time:"+this.agentInfo.getTime()+" id:"+me+" target:"+this.getTarget());
// エージェントが現在位置する建物や道路のIDを取得する
EntityID
position
=
this
.
agentInfo
.
getPosition
();
...
...
@@ -94,25 +116,20 @@ public class SampleSearch extends Search
if
(
this
.
getTarget
()
!=
null
&&
!
position
.
equals
(
this
.
getTarget
()))
{
return
this
;
}
// 探索済みの (辿り着いたことがある) 対象を候補から除外する
list
.
removeAll
(
this
.
searchedSet
);
// すべての対象が探索済みの場合,候補をリセットする
if
(
list
.
size
()
<=
0
)
{
this
.
searchedSet
.
clear
();
list
=
new
ArrayList
<>(
cluster
);
}
// クラスタ内の建物や道路のIDリストから建物のIDリストを取得
List
<
EntityID
>
buildinglist
=
list
.
stream
()
// listのストリームを取得
.
map
(
this
.
worldInfo
::
getEntity
)
// EntityIDをStandardEntityに変換
.
filter
(
e
->
(
e
instanceof
Building
))
// StandardEntityオブジェクトのうちBuildingクラスのものだけ抽出
.
map
(
StandardEntity:
:
getID
)
// StandardEntityをEntityIDに変換
.
collect
(
Collectors
.
toList
());
// ストリームをリストにして取得
double
near
=
Double
.
MAX_VALUE
;
for
(
EntityID
lists
:
this
.
list
)
{
StandardEntity
test
=
this
.
worldInfo
.
getEntity
(
lists
);
if
(
test
instanceof
Building
)
{
double
distance
=
this
.
worldInfo
.
getDistance
(
position
,
lists
);
if
(
distance
<
near
){
near
=
distance
;
this
.
result
=
lists
;
}
for
(
EntityID
lists
:
buildinglist
)
{
double
distance
=
this
.
worldInfo
.
getDistance
(
position
,
lists
);
if
(
distance
<
near
){
near
=
distance
;
this
.
result
=
lists
;
}
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment