[1] | 1 | package agents.anac.y2015.DrageKnight.etc;
|
---|
| 2 |
|
---|
| 3 | import java.util.ArrayList;
|
---|
| 4 |
|
---|
| 5 | import genius.core.Bid;
|
---|
| 6 | import genius.core.utility.AdditiveUtilitySpace;
|
---|
| 7 |
|
---|
| 8 | public class strategy {
|
---|
| 9 | private AdditiveUtilitySpace utilitySpace;
|
---|
| 10 | private negotiatingInfo negotiatingInfo;
|
---|
| 11 |
|
---|
| 12 | private double df = 0.0; // 割引係数
|
---|
| 13 | private double rv = 0.0; // 留保価格
|
---|
| 14 |
|
---|
| 15 | public strategy(AdditiveUtilitySpace utilitySpace, negotiatingInfo negotiatingInfo) {
|
---|
| 16 | this.utilitySpace = utilitySpace;
|
---|
| 17 | this.negotiatingInfo = negotiatingInfo;
|
---|
| 18 | df = utilitySpace.getDiscountFactor(); // 割引効用を取得してる?
|
---|
| 19 | rv = utilitySpace.getReservationValue(); // 留保価格を取得してる?
|
---|
| 20 | }
|
---|
| 21 |
|
---|
| 22 | // 受容判定
|
---|
| 23 | public boolean selectAccept(Bid offeredBid, double time) {
|
---|
| 24 | try {
|
---|
| 25 | double offeredBidUtil = utilitySpace.getUtility(offeredBid);
|
---|
| 26 |
|
---|
| 27 | double ff = 1.0; //割引効用を考慮した均一化関数
|
---|
| 28 | if(df <= 0.75 && df > 0.5) { // 割引効用が0.75ならこれ
|
---|
| 29 | ff = 1 - (0.25 * time);
|
---|
| 30 | } else if(df <= 0.5 && df > 0.25) { // 割引効用が0.5ならこれ
|
---|
| 31 | ff = 1 - (0.5 * time);
|
---|
| 32 | } else if(df <= 0.25){ // 割引効用が0.25ならこれ
|
---|
| 33 | ff = 1 - (0.75 * time);
|
---|
| 34 | }
|
---|
| 35 |
|
---|
| 36 | if((offeredBidUtil * ff) >= getThreshold(time)){ // threshold < 効用*ff ならAccept
|
---|
| 37 | return true;
|
---|
| 38 | } else {
|
---|
| 39 | return false;
|
---|
| 40 | }
|
---|
| 41 | } catch (Exception e) {
|
---|
| 42 | System.out.println("受容判定に失敗しました");
|
---|
| 43 | e.printStackTrace();
|
---|
| 44 | return false;
|
---|
| 45 | }
|
---|
| 46 | }
|
---|
| 47 |
|
---|
| 48 | // 交渉終了判定
|
---|
| 49 | public boolean selectEndNegotiation(double time) {
|
---|
| 50 | //メモ
|
---|
| 51 | //ここ最近の向こうの提案がクソすぎる かつ 留保価格が良ければEndNegoもあり?
|
---|
| 52 | return false;
|
---|
| 53 | }
|
---|
| 54 |
|
---|
| 55 | // メモ
|
---|
| 56 | //割引効用が0.75以上と未満でthresholdを変えたい
|
---|
| 57 |
|
---|
| 58 | // 相手の提案に対する閾値を返す
|
---|
| 59 | public double getThreshold(double time) {
|
---|
| 60 |
|
---|
| 61 | double e = 0.05; // 通常のthresholdはこのeを使って計算する
|
---|
| 62 | if(df <= 0.75 && df > 0.5) { // 割引効用が0.75ならこれ
|
---|
| 63 | e = 0.15;
|
---|
| 64 | } else if(df <= 0.5 && df > 0.25) { // 割引効用が0.5ならこれ
|
---|
| 65 | e = 0.3;
|
---|
| 66 | } else if(df <= 0.25){ // 割引効用が0.25ならこれ
|
---|
| 67 | e = 1.5;
|
---|
| 68 | }
|
---|
| 69 |
|
---|
| 70 | double threshold = 0.9 - Math.pow(time, 1/e); //いい感じに妥協していくけど、相手の提案にはちょっと厳しい
|
---|
| 71 |
|
---|
| 72 | if(threshold < 0.6 && df == 1){
|
---|
| 73 | threshold = 0.6; //時間ギリギリまで、0.6未満ではAcceptしない
|
---|
| 74 | } else if (threshold < 0.5 && df <= 0.75 && df > 0.5){
|
---|
| 75 | threshold = 0.5; //時間ギリギリまで、0.5未満ではAcceptしない
|
---|
| 76 | } else if (threshold < 0.4 && df <= 0.5) {
|
---|
| 77 | threshold = 0.4;
|
---|
| 78 | }
|
---|
| 79 |
|
---|
| 80 | /* 交渉戦略に基づきthreshold(t)を設計する */
|
---|
| 81 | /* negotiatingInfoから提案履歴の統計情報を取得できるので使っても良い */
|
---|
| 82 | // 例:
|
---|
| 83 | ArrayList<Object> opponents = negotiatingInfo.getOpponents();
|
---|
| 84 | for(Object sender:opponents){
|
---|
| 85 | double m = negotiatingInfo.getAverage(sender); //平均
|
---|
| 86 | double v = negotiatingInfo.getVariancer(sender); //分散
|
---|
| 87 | double sd = negotiatingInfo.getStandardDeviation(sender); //標準偏差
|
---|
| 88 | }
|
---|
| 89 |
|
---|
| 90 | return threshold;
|
---|
| 91 | }
|
---|
| 92 |
|
---|
| 93 | // 此方の提案に対する閾値を返す
|
---|
| 94 | public double getThreshold2(double time) {
|
---|
| 95 | double e = 0.08;
|
---|
| 96 | if(df <= 0.75 && df > 0.5) { // 割引効用が0.75ならこれ
|
---|
| 97 | e = 0.2;
|
---|
| 98 | } else if(df <= 0.5 && df > 0.25) { // 割引効用が0.5ならこれ
|
---|
| 99 | e = 0.35;
|
---|
| 100 | } else if(df <= 0.25){ // 割引効用が0.25ならこれ
|
---|
| 101 | e = 1.5;
|
---|
| 102 | }
|
---|
| 103 |
|
---|
| 104 | double threshold = 1.0 - Math.pow(time, 1/e); //いい感じに妥協していくけど
|
---|
| 105 |
|
---|
| 106 | if(df > 0.75){
|
---|
| 107 | if(time > 0.8){
|
---|
| 108 | threshold = 0.8;
|
---|
| 109 | }
|
---|
| 110 | if(time > 0.9){
|
---|
| 111 | threshold = 0.6;
|
---|
| 112 | } //提案の時はちょっとだけ強気
|
---|
| 113 | }
|
---|
| 114 |
|
---|
| 115 | // 全体的に強気思考だけど、強気同士でもなんとかなる?
|
---|
| 116 |
|
---|
| 117 | /* 交渉戦略に基づきthreshold(t)を設計する */
|
---|
| 118 | /* negotiatingInfoから提案履歴の統計情報を取得できるので使っても良い */
|
---|
| 119 | // 例:
|
---|
| 120 | ArrayList<Object> opponents = negotiatingInfo.getOpponents();
|
---|
| 121 | for(Object sender:opponents){
|
---|
| 122 | double m = negotiatingInfo.getAverage(sender); //平均
|
---|
| 123 | double v = negotiatingInfo.getVariancer(sender); //分散
|
---|
| 124 | double sd = negotiatingInfo.getStandardDeviation(sender); //標準偏差
|
---|
| 125 | }
|
---|
| 126 |
|
---|
| 127 | return threshold;
|
---|
| 128 | }
|
---|
| 129 | }
|
---|