public Bid chooseBestFromHistory(UtilitySpace utilitySpace) { double max = -1; Bid maxBid = null; try { for (Bid bid : bidHistory) { if (max < utilitySpace.getUtility(bid)) { max = utilitySpace.getUtility(bid); maxBid = bid; } } } catch (Exception e) { System.out.println("ChooseBestfromhistory exception"); } return maxBid; }
public void updateOppRec(Bid oppbid, Object sender) { if (partyOrder.size() < partyNum - 1) { partyOrder.add(sender); oppMax.add(oppbid); } else { try { if (fUtilitySpace.getUtility(oppMax.get(partyOrder.indexOf(sender))) < fUtilitySpace.getUtility(oppbid)) oppMax.set(partyOrder.indexOf(sender), oppbid); } catch (Exception e) { System.out.println("error in updateOppRec method" + e.getMessage()); } } }
public void addBid(Bid bid, UtilitySpace utilitySpace) { if (bidHistory.indexOf(bid) == -1) { bidHistory.add(bid); } try { if (bidHistory.size() == 1) { this.bid_maximum_from_opponent = bidHistory.get(0); } else { if (utilitySpace.getUtility(bid) > utilitySpace.getUtility(this.bid_maximum_from_opponent)) { this.bid_maximum_from_opponent = bid; } } } catch (Exception e) { System.out.println("error in addBid method" + e.getMessage()); } }
public Bid getMiniBestOpp() { // Bid bid = null; // int temp = 0; Bid bid = oppMax.get(0); for (int i = 0; i < partyNum - 1; i++) { try { // System.out.println("test in method // getMiniBestOpp"+oppMax.get(0)+","+fUtilitySpace.getUtility(oppMax.get(0))); // System.out.println("test in method // getMiniBestOpp"+oppMax.get(1)+","+fUtilitySpace.getUtility(oppMax.get(1))); if (fUtilitySpace.getUtility(bid) > fUtilitySpace.getUtility(oppMax.get(i))) bid = oppMax.get(i); } catch (Exception e) { System.out.println("error in method getMiniBestOpp"); } } return bid; }
// one way to predict the concession degree of the opponent public double concedeDegree(UtilitySpace utilitySpace) { int numOfBids = bidHistory.size(); HashMap<Bid, Integer> bidCounter = new HashMap<Bid, Integer>(); try { for (int i = 0; i < numOfBids; i++) { if (bidCounter.get(bidHistory.get(i)) == null) { bidCounter.put(bidHistory.get(i), 1); } else { int counter = bidCounter.get(bidHistory.get(i)); counter++; bidCounter.put(bidHistory.get(i), counter); } } } catch (Exception e) { System.out.println("ChooseBestfromhistory exception"); } // System.out.println("the opponent's toughness degree is " + bidCounter.size() + " divided by " // + utilitySpace.getDomain().getNumberOfPossibleBids()); return ((double) bidCounter.size() / utilitySpace.getDomain().getNumberOfPossibleBids()); }
/** * コンストラクタ(geniusから呼び出し) * * @param utilitySpace 自分の効用空間 * @param deadlines 交渉の制限時間 * @param timeline 経過時間(0~1) * @param randomSeed 乱数用シード */ public AgentHP( UtilitySpace utilitySpace, Deadline deadlines, Timeline timeline, long randomSeed) { // 親クラスコンストラクタ super(utilitySpace, deadlines, timeline, randomSeed); // 予約値取得 reservationValue = utilitySpace.getReservationValueUndiscounted(); // 初期化 partyNum = 0; issueNum = 0; targetBid = null; underlimitUtility = 0.0; logNum = null; TemplateLogBidCountHash = null; TemplateLogBidValueHash = null; logBid = null; logBidCountHash = null; logBidValueHash = null; participantList = null; compareSize = 0; compareResultArray = null; issueWeightArray = null; estimateCount = null; weightUtilSpace = 0.0; addupValueHash = null; addupWeightArray = null; prevAddupTiming = 0; sumUtility = null; sumUtility2 = null; estimateMax = 0.0; utilityBarometer = 0.0; // 論点数取得 issueNum = utilitySpace.getDomain().getIssues().size(); // 提案保存Hashテンプレ&合算効用空間保存Hash作成 TemplateLogBidCountHash = new HashMap[issueNum]; TemplateLogBidValueHash = new HashMap[issueNum]; addupValueHash = new HashMap[issueNum]; for (Issue tmp : utilitySpace.getDomain().getIssues()) { int issue_num = tmp.getNumber(); // 論点番号 IssueDiscrete tmpDiscrete = (IssueDiscrete) tmp; TemplateLogBidValueHash[issue_num - 1] = new HashMap<String, Double>(); TemplateLogBidCountHash[issue_num - 1] = new HashMap<String, Integer>(); addupValueHash[issue_num - 1] = new HashMap<String, Double>(); for (int j = 0; j < tmpDiscrete.getNumberOfValues(); j++) { TemplateLogBidValueHash[issue_num - 1].put(tmpDiscrete.getValue(j).toString(), 0.0); TemplateLogBidCountHash[issue_num - 1].put(tmpDiscrete.getValue(j).toString(), 0); addupValueHash[issue_num - 1].put(tmpDiscrete.getValue(j).toString(), 0.0); } } // 参加者名と配列要素数対応Hash作成 participantList = new HashMap<String, Integer>(); // 提案作成最低効用値初期値 underlimitUtility = 1.0; // 効用空間合算の自分の重み初期値 weightUtilSpace = 1.0; }