支配度是nsga-ⅱ中的概念。在nsga-ⅱ中,支配度有助於我們選擇最佳解集作為親本。這些解支配了其他解,即表明為它們不會比其他所有解差。
當且僅當滿足下列兩個條件時,我們說解x支配解y。
通俗地講就是當採用某乙個解時,它的效果都不比另乙個解差(至少相等),並且至少有乙個指標好過另乙個解。
以下列資料為例,其中第二行與第三行的資料都是越小越好ida
bcde
fgh成本
2060
6515
5550
8025
最糟反饋
2.24.4
3.54.4
4.51.8
4.04.6
其中可以說解d支配解b,因為d在成本上小於b,且最糟反饋上不比b差。
以下是求解指定索引的支配集的**
import numpy as np
import pandas as pd
d =df = pd.dataframe(data=d)
.tdata_labels =
list
(df.index)
data_array = np.array(df)
.t# 指定解決的索引
sol_index =
1sol = data_array[
:, sol_index]
obj1_not_worse = np.where(sol[0]
>= data_array[0,
:])[
0]obj2_not_worse = np.where(sol[1]
>= data_array[1,
:])[
0]not_worse_candidates =
set.intersection(
set(obj1_not_worse)
,set
(obj2_not_worse)
)obj1_better = np.where(sol[0]
> data_array[0,
:])[
0]obj2_better = np.where(sol[1]
> data_array[1,
:])[
0]better_candidates =
set.intersection(
set(obj1_better)
,set
(obj2_better)
)dominating_solution =
list
(set
.intersection(not_worse_candidates, better_candidates))if
len(dominating_solution)==0
:print
("no solution dominates solution"
, data_labels[sol_index]
,"."
)else
:print
("labels of one or more solutions dominating this solution :"
, end="")
for k in dominating_solution:
print
(data_labels[k]
, end=
',')
而我們往往需要求解非支配解集。非支配解集中所有的元素都不被所有解支配。在此解集中沒有解支配另乙個解。通俗地說,在非支配解集中的元素都有其可取之處,不存在完全優於它的其他解。
求解非支配解集的**如下:
import numpy as np
import pandas as pd
d =df = pd.dataframe(data=d)
.tdata_labels =
list
(df.index)
data_array = np.array(df)
.tdef
solve
(sol_index)
: sol = data_array[
:, sol_index]
obj1_not_worse = np.where(sol[0]
>= data_array[0,
:])[
0]obj2_not_worse = np.where(sol[1]
>= data_array[1,
:])[
0]not_worse_candidates =
set.intersection(
set(obj1_not_worse)
,set
(obj2_not_worse)
) obj1_better = np.where(sol[0]
> data_array[0,
:])[
0]obj2_better = np.where(sol[1]
> data_array[1,
:])[
0]better_candidates =
set.intersection(
set(obj1_better)
,set
(obj2_better)
) dominating_solution =
list
(set
.intersection(not_worse_candidates, better_candidates))if
len(dominating_solution)==0
:return
true
else
:return
false
dominating_set =
for k in
range
(data_array.shape[1]
):if solve(k):)
print
(dominating_set)
樹的最小支配集
最小支配集,就是圖中用最少的點覆蓋其它所有點 如果用選a點覆蓋,則與a點相連的點都被覆蓋,大致 就是這樣 有乙個圖g,現在希望在一些點建立控制站,每個控制站能控制與它相臨的點 直接相連 現在希望有選擇的在一些點建立控制站,使得以最小得控制站數,控制所有的點 圖的最小支配集是np 問題,我只會樹的最小...
多目標優化非支配關係實現
遍歷所有m個目標值 for obj index 1 global.m if newpop.obj obj index population i obj obj index 如果目標值小於等於則計數值加1 offspringless or equal offspringless or equal 1 ...
非遞迴實現迷宮求解
迷宮求解問題 用乙個m n的矩陣表示迷宮,0和1分別表示迷宮中的通路和障礙。設計乙個程式,對給定的迷宮,求出找到的第一條從入口到出口的通路,或得到沒有通路的結論。我們指定 迷宮的入口為矩陣的左上角 1,1 迷宮的出口為右下角 m,n 路徑的探索順序依次為 東南西北 即 右下左上 輸入 第一行輸入兩個...