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
f6734e74
Commit
f6734e74
authored
Oct 28, 2023
by
k20066
Browse files
typo modify
parent
cc10dafa
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/main/java/autumn_2023/module/algorithm/KmeansPPClustering.java
View file @
f6734e74
...
...
@@ -13,6 +13,9 @@ import java.util.*;
import
static
java
.
util
.
stream
.
Collectors
.*;
import
static
java
.
util
.
Comparator
.*;
import
adf.core.debug.DefaultLogger
;
import
org.apache.log4j.Logger
;
public
class
KmeansPPClustering
extends
StaticClustering
{
// エージェントとクラスタの結びつけを保存
...
...
@@ -24,9 +27,13 @@ public class KmeansPPClustering extends StaticClustering
// エージェントの種類
private
StandardEntityURN
urn
;
private
Logger
logger
;
// K-means++ 繰り返し実行回数の定義
private
final
static
int
REP_PRECOMPUTE
=
20
;
private
final
static
int
REP_PREPARE
=
20
;
// 事前計算の結果保存用キーの定義
// 事前計算の結果はPrecomputeDataクラスを通して保存します.
// 文字列によるキーと値のペアで保存できます.
...
...
@@ -42,6 +49,7 @@ public class KmeansPPClustering extends StaticClustering
{
super
(
ai
,
wi
,
si
,
mm
,
dd
);
this
.
urn
=
this
.
agentInfo
.
me
().
getStandardURN
();
this
.
logger
=
DefaultLogger
.
getLogger
(
agentInfo
.
me
());
}
// 保存用キーにエージェントの種類を区別するための接尾辞を足すメソッド
...
...
@@ -88,6 +96,12 @@ public class KmeansPPClustering extends StaticClustering
pd
.
setEntityID
(
this
.
addSuffixToKey
(
PD_CLUSTER_A
,
i
),
agent
);
}
//debug
for
(
int
i
=
1
;
i
<
this
.
clusterer
.
getClusterNumber
()
+
1
;
i
++)
{
Collection
<
EntityID
>
myClusterEntities
=
this
.
clusterer
.
getClusterMembers
(
i
-
1
);
logger
.
debug
(
"cluster="
+
i
+
", EntityID="
+
myClusterEntities
.
toString
());
}
return
this
;
}
...
...
@@ -98,7 +112,27 @@ public class KmeansPPClustering extends StaticClustering
super
.
resume
(
pd
);
// 重複した処理の実行を回避
if
(
this
.
getCountResume
()
>
1
)
return
this
;
// 事前計算の結果の読み込みもPrecomputeDataクラスを通しておこなえます.
// グループ数を読み込みます.
this
.
n
=
pd
.
getInteger
(
this
.
addSuffixToKey
(
PD_CLUSTER_N
));
List
<
Collection
<
EntityID
>>
clusters
=
new
ArrayList
<>(
this
.
n
);
for
(
int
i
=
0
;
i
<
this
.
n
;
++
i
)
{
// i番目のクラスタの要素を読み込みます.
List
<
EntityID
>
cluster
=
pd
.
getEntityIDList
(
this
.
addSuffixToKey
(
PD_CLUSTER_M
,
i
));
// i番目のクラスタと結び付けられたエージェントを読み込みます.
EntityID
agent
=
pd
.
getEntityID
(
this
.
addSuffixToKey
(
PD_CLUSTER_A
,
i
));
clusters
.
add
(
cluster
);
// エージェントとクラスタの結び付きを復元します.
this
.
assignment
.
put
(
agent
,
i
);
}
// グループ数と各クラスタの要素を表したListでKmeansPPを復元します.
this
.
clusterer
=
new
KmeansPP
(
this
.
n
,
clusters
);
return
this
;
}
...
...
@@ -111,6 +145,10 @@ public class KmeansPPClustering extends StaticClustering
// 重複した処理の実行を回避
if
(
this
.
getCountPreparate
()
>
1
)
return
this
;
this
.
initN
();
this
.
initClusterer
();
this
.
clusterer
.
execute
(
REP_PREPARE
);
this
.
pair
();
return
this
;
}
...
...
src/main/java/sample_team/module/complex/SampleRoadDetector.java
View file @
f6734e74
...
...
@@ -44,7 +44,7 @@ public class SampleRoadDetector extends RoadDetector {
"SampleRoadDetector.PathPlanning"
,
"adf.impl.module.algorithm.DijkstraPathPlanning"
);
this
.
clustering
=
moduleManager
.
getModule
(
"SampleRoadDetector.Clustering"
,
"adf.impl.module.algorithm.KMeansClustring"
);
"adf.impl.module.algorithm.KMeansClust
e
ring"
);
registerModule
(
this
.
clustering
);
registerModule
(
this
.
pathPlanning
);
this
.
result
=
null
;
...
...
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