4.2 雛型協商系統說明與實驗結果分析
4.2.1 協商雛型系統建置說明
在進行協商機制的過程中,需將協商參數輸入,在 4.1 有介紹過 ua 代表使用 者代理人、ia 代表 IT 專案管理代理人、va1 代表廠商 1、va2 代表廠商 2、va3 代 表廠商 3。因此為了方便說明,後續陳述皆以代號表示。在此,特別說明的一點是 參數的順序是成本期望值, 成本下限, 成本上限, 成本彈性調整值, 時間期望值, 時間下限, 時間上限, 時間彈性調整值, 範疇期望值, 範疇下限, 範疇上限, 範 疇彈性調整值, 品質期望值, 品質下限, 品質上限, 品質彈性調整值, 人力資源 期望值, 人力資源下限, 人力資源上限, 人力資源彈性調整值。以下為程式碼:
//宣告物件
NegotiationCounters ua = new NegotiationCounters(20,15,25,0.2,30,24,35,0.2,1,1,2,0.1,4,4,5,0.1,3,1,3,0.3);
NegotiationCounters ia = new NegotiationCounters(18,12,25,0.1,26,20,28,0.1,1,1,2,0.1,5,4,5,0.1,3,1,3,0.2);
NegotiationCounters va1 = new NegotiationCounters(25,20,30,0.3,32,30,40,0.3,1,1,2,0.1,5,4,5,0.1,2,1,2,0.2);
NegotiationCounters va2 = new NegotiationCounters(35,33,38,0.3,30,30,40,0.3,1,1,2,0.1,4,3,5,0.1,2,1,3,0.2);
NegotiationCounters va3 = new NegotiationCounters(28,24,32,0.3,30,30,40,0.3,1,1,2,0.1,4,4,5,0.1,2,1,2,0.2);
為了計算出各個代理人所提出的五個協商屬性的最大集合,以便找出最多代 理人認同的屬性區間,程式利用以下這段程式碼來找出每個屬性最大集合的下上 限。最大集合之協商區間值如圖 4.7 及圖 4.8,因此就可以計算出各個代理人的屬 性區間值是否有符合,舉例說明,如 ua 的成本協商區間值為[15,25],而成本屬性 的最大集合為[24,32],因此就可以演算出 ua 的成本區間值有落在最大集合内。
for (int i=0;i<5;i++){ //進行五回合比較
for (int j=0;j<5;j++){ //每一回合區間 i 與除了自己之外的其他四個區間 j 比較 if (j!=i) {
tmp_upper=interval[i][1]; tmp_lower=interval[i][0];
if (interval[j][0]<interval[i][1]&&interval[j][1]>interval[i][0]){
tmp_intersection++; //計算交集數
if (interval[j][1]<tmp_upper) tmp_upper=interval[j][1];
if (interval[j][0]>interval[i][0]) tmp_lower=interval[j][0];
} } } //for j
if (!initial){ //若為第一回合則不用比較
if (tmp_intersection>intersection){ //交集數最大者優先存入長期記憶 intersection=tmp_intersection;
upper=tmp_upper;
lower=tmp_lower;
}
else if (tmp_intersection==intersection){ //交集數相同者取大區間存入長期記憶 if ((tmp_upper-tmp_lower)>(upper-lower)){
upper=tmp_upper;
lower=tmp_lower;
} } }
else initial=false;
//System.out.println(intersection + "," + upper + "," +lower);
} //for i
圖 4. 7 五個協商屬性之區間值
圖 4. 8 五個協商屬性之區間值系統畫面
依上述說明類推,可演算出本次實例中需做彈性調整的分別有 va2_Cost、
ua_Time、ia_Time,利用第三章研究方法之公式 3.1 及公式 3.2 進行區間值調整,
程式碼如下:
double mean_cost = (ua.getCostExpectedValue()+ia.getCostExpectedValue()+
va1.getCostExpectedValue()+va2.getCostExpectedValue()+va3.getCostExpectedValue())/5;//期望值之平均值 double cost_adj_factor= (va2.getCostExpectedValue()-mean_cost)*va2.getCostElasticity(); //公式 3.1 double getCostLowerUpper [] =
{va2.getCostLower()-Math.abs(cost_adj_factor),va2.getCostUpper()+Math.abs(cost_adj_factor)};//公式 3.2
在進行第一次屬性調整後,ia 的 Time 屬性及 va2 的 Cost 屬性仍沒有落在最大 集合,如代理人接到通知後仍要進行屬性調整,即會有第二次屬性調整,但本實 驗 設 定 ia 及 va2 因 此 放 棄 協 商 , 因 此 最 終 進 入 協 商 的 有 ua,va1,va3 。 yieldNegotiationupright 這個方法的參數共有六個,Lower 為各個代理人提出的屬性 下限、expected 為期望值、Upper 為屬性上限、slcountname 為進入協商的代理人名
稱、negotiationtime 為協商總次數、slcount 為進入協商的代理人個數,退讓協商程 式碼如下:
//定義退讓協商方法
yieldNegotiationupright(double [][] Lower,double [][] expected,
double [][] Upper, String [] slcountname, int negotiationtime, int slcount)
for (int ll=0; ll<(Lower.length+Upper.length)/2; ll++) { for (int sl=0; sl<slcount; sl++) {
if (ll==0){utility = Lower[ll][sl] + ((Upper[ll][sl] - Lower[ll][sl])*((double)negotiationtime/10));
}
if (ll==1 || ll==3 || ll==4){utility = Upper[ll][sl] - ((Upper[ll][sl] -
Lower[ll][sl])*((double)negotiationtime/10));}
if ((negotiationtime/2) !=0){
if (ll==2){utility = expected[ll][sl] + (expected[ll][sl] -
Lower[ll][sl])*((double)negotiationtime+1/10);}}
if ((negotiationtime/2) ==0){
if (ll==2){utility = expected[ll][sl] + ((expected[ll][sl] -
Lower[ll][sl])*((double)negotiationtime/10));}}
for (int llck=0; llck<slcount; llck++) {
if (utility <= Upper[ll][llck] && utility >= Lower[ll][llck]) {count[ll][sl]++;}
if (count[ll][sl] == slcount) {realize[sl] = realize[sl] + count[ll][sl];}
(negotiationtime==5){System.out.println(ll+","+sl
+","+count[ll][sl]+","+realize[ll]);}//debug if (realize[sl]==5*slcount) {rzname = rzname + " ; " + slcountname[sl];}
} } }
圖 4.9 及圖 4.10 為本實驗之驗證結果,設定之總協商次數為 10 次,因此在第 五次協商即產生第一次協商成功,本例進行到第十次協商仍只有一次成功,因此 va1 是本次實驗中唯一符合期待的專案組合,但如果協商有第二次成功仍可比較前 後次的成功協商最符合期待。
圖 4. 9 協商第五次成功之表示圖
圖 4. 10 協商第五次成功之系統畫面圖