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
Show whitespace changes
Inline
Side-by-side
src/main/java/autumn_2023/module/complex/CentralizedControlFBAllocator.java
View file @
b6aaede1
...
@@ -193,11 +193,18 @@ public class CentralizedControlFBAllocator extends FireTargetAllocator {
...
@@ -193,11 +193,18 @@ public class CentralizedControlFBAllocator extends FireTargetAllocator {
this
.
taskSet
.
addAll
(
recievetasks
);
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
);
List
<
CommunicationMessage
>
mesfblist
=
messageManager
.
getReceivedMessageList
(
MessageFireBrigade
.
class
);
for
(
CommunicationMessage
mes
:
mesfblist
){
for
(
CommunicationMessage
mes
:
mesfblist
){
MessageFireBrigade
mesfb
=
(
MessageFireBrigade
)
mes
;
MessageFireBrigade
mesfb
=
(
MessageFireBrigade
)
mes
;
MessageUtil
.
reflectMessage
(
this
.
worldInfo
,
mesfb
);
MessageUtil
.
reflectMessage
(
this
.
worldInfo
,
mesfb
);
EntityID
fbID
=
mesfb
.
getAgentID
();
EntityID
fbID
=
mesfb
.
getAgentID
();
fblist
.
add
(
fbID
);
FireBrigadeInfo
fbi
=
this
.
fireBrigadeInfoMap
.
get
(
fbID
);
FireBrigadeInfo
fbi
=
this
.
fireBrigadeInfoMap
.
get
(
fbID
);
fbi
.
setInfo
(
mesfb
.
getTargetID
(),
mesfb
.
getPosition
(),
mesfb
.
getBuriedness
(),
fbi
.
setInfo
(
mesfb
.
getTargetID
(),
mesfb
.
getPosition
(),
mesfb
.
getBuriedness
(),
(
mesfb
.
getAction
()
==
MessageFireBrigade
.
ACTION_RESCUE
)
?
false
:
true
,
this
.
agentInfo
.
getTime
());
(
mesfb
.
getAction
()
==
MessageFireBrigade
.
ACTION_RESCUE
)
?
false
:
true
,
this
.
agentInfo
.
getTime
());
...
@@ -294,5 +301,16 @@ public class CentralizedControlFBAllocator extends FireTargetAllocator {
...
@@ -294,5 +301,16 @@ public class CentralizedControlFBAllocator extends FireTargetAllocator {
this
.
canNewAction
=
canNewAction
;
this
.
canNewAction
=
canNewAction
;
this
.
commandTime
=
commandTime
;
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;
...
@@ -14,6 +14,7 @@ import adf.core.agent.develop.DevelopData;
import
rescuecore2.standard.entities.*
;
import
rescuecore2.standard.entities.*
;
import
rescuecore2.worldmodel.EntityID
;
import
rescuecore2.worldmodel.EntityID
;
import
java.util.*
;
import
java.util.*
;
import
java.util.stream.Collector
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
import
static
java
.
lang
.
Double
.
POSITIVE_INFINITY
;
import
static
java
.
lang
.
Double
.
POSITIVE_INFINITY
;
...
@@ -57,11 +58,39 @@ public class SampleSearch extends Search
...
@@ -57,11 +58,39 @@ public class SampleSearch extends Search
List
<
CommunicationMessage
>
messages
=
mm
.
getReceivedMessageList
();
List
<
CommunicationMessage
>
messages
=
mm
.
getReceivedMessageList
();
this
.
messageManager
=
mm
;
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を取得する
// エージェントが現在位置する建物や道路のIDを取得する
EntityID
position
=
this
.
agentInfo
.
getPosition
();
EntityID
position
=
this
.
agentInfo
.
getPosition
();
// 探索済みの (辿り着いたことがある) 対象を候補から除外する
// 探索済みの (辿り着いたことがある) 対象を候補から除外する
this
.
searchedSet
.
add
(
position
);
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
;
return
this
;
}
}
...
@@ -69,24 +98,17 @@ public class SampleSearch extends Search
...
@@ -69,24 +98,17 @@ public class SampleSearch extends Search
@Override
@Override
public
Search
calc
()
public
Search
calc
()
{
{
// エージェントが動けるステップではないなら
if
(
this
.
agentInfo
.
getTime
()
<
this
.
scenarioInfo
.
getKernelAgentsIgnoreuntil
())
return
this
;
EntityID
me
=
this
.
agentInfo
.
getID
();
EntityID
me
=
this
.
agentInfo
.
getID
();
int
idx
=
this
.
clustering
.
getClusterIndex
(
me
);
int
idx
=
this
.
clustering
.
getClusterIndex
(
me
);
if
(
idx
==
-
1
)
{
if
(
idx
==
-
1
)
return
this
;
return
this
;
}
//System.out.println("time:"+this.agentInfo.getTime()+" id:"+me+" target:"+this.getTarget());
Collection
<
EntityID
>
cluster
=
Collection
<
EntityID
>
cluster
=
this
.
clustering
.
getClusterEntityIDs
(
idx
);
this
.
clustering
.
getClusterEntityIDs
(
idx
);
if
(
cluster
==
null
)
return
this
;
if
(
cluster
==
null
)
{
return
this
;
}
// Listに変換
//System.out.println("time:"+this.agentInfo.getTime()+" id:"+me+" target:"+this.getTarget());
if
(
this
.
result
==
null
){
list
=
new
ArrayList
<>(
cluster
);
//System.out.println(list);
}
// エージェントが現在位置する建物や道路のIDを取得する
// エージェントが現在位置する建物や道路のIDを取得する
EntityID
position
=
this
.
agentInfo
.
getPosition
();
EntityID
position
=
this
.
agentInfo
.
getPosition
();
...
@@ -95,26 +117,21 @@ public class SampleSearch extends Search
...
@@ -95,26 +117,21 @@ public class SampleSearch extends Search
return
this
;
return
this
;
}
}
// 探索済みの (辿り着いたことがある) 対象を候補から除外する
// クラスタ内の建物や道路のIDリストから建物のIDリストを取得
list
.
removeAll
(
this
.
searchedSet
);
List
<
EntityID
>
buildinglist
=
list
.
stream
()
// listのストリームを取得
.
map
(
this
.
worldInfo
::
getEntity
)
// EntityIDをStandardEntityに変換
// すべての対象が探索済みの場合,候補をリセットする
.
filter
(
e
->
(
e
instanceof
Building
))
// StandardEntityオブジェクトのうちBuildingクラスのものだけ抽出
if
(
list
.
size
()
<=
0
)
{
.
map
(
StandardEntity:
:
getID
)
// StandardEntityをEntityIDに変換
this
.
searchedSet
.
clear
();
.
collect
(
Collectors
.
toList
());
// ストリームをリストにして取得
list
=
new
ArrayList
<>(
cluster
);
}
double
near
=
Double
.
MAX_VALUE
;
double
near
=
Double
.
MAX_VALUE
;
for
(
EntityID
lists
:
this
.
list
)
{
for
(
EntityID
lists
:
buildinglist
)
{
StandardEntity
test
=
this
.
worldInfo
.
getEntity
(
lists
);
if
(
test
instanceof
Building
)
{
double
distance
=
this
.
worldInfo
.
getDistance
(
position
,
lists
);
double
distance
=
this
.
worldInfo
.
getDistance
(
position
,
lists
);
if
(
distance
<
near
){
if
(
distance
<
near
){
near
=
distance
;
near
=
distance
;
this
.
result
=
lists
;
this
.
result
=
lists
;
}
}
}
}
}
return
this
;
return
this
;
}
}
...
...
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