Ejemplo n.º 1
0
  /**
   * AHPによる提案の評価値を取得
   *
   * @param Bid 予測対象提案
   * @return double 予測評価値(効用値)
   */
  private double getAHPEvaluation(Bid targetBid) {

    double utility = 0.0;
    if (targetBid != null && isEstimated(partyNum)) {

      for (int i = 1; i <= issueNum; i++) {

        try {
          // 合算した効用空間から効用を取得
          String valName = targetBid.getValue(i).toString();
          utility += (addupValueHash[i - 1].get(valName) * addupWeightArray[i - 1]);

        } catch (Exception e) {
          System.out.println("getValue Error !\n");
        }
        ;
      }
    }

    return utility;
  }
Ejemplo n.º 2
0
  /**
   * 自分以外の参加者の効用値予測を取得
   *
   * @param String 参加者名
   * @param Bid 予測対象提案
   * @return double 予測効用値
   */
  private double getTargetUtility(String name, Bid targetBid) {

    int partyID = getSenderID(name);
    double utility = 0.0;
    if (targetBid != null && partyID >= 0) {

      for (int i = 1; i <= issueNum; i++) {

        try {
          // 相手の提案を元に予測効用空間から効用を取得し重み掛けて加算
          String valName = targetBid.getValue(i).toString();
          utility +=
              (logBidValueHash[partyID][i - 1].get(valName) * issueWeightArray[partyID][i - 1]);

        } catch (Exception e) {
          System.out.println("getValue Error !\n");
        }
        ;
      }
    }

    return utility;
  }
  /** This function updates the statistics of the bids that were received from the opponent. */
  private void updateStatistics(Bid bidToUpdate, boolean toRemove, Domain domain) {
    try {
      ArrayList<Issue> issues = domain.getIssues();

      // counters for each type of the issues
      int realIndex = 0;
      int discreteIndex = 0;
      int integerIndex = 0;
      for (Issue lIssue : issues) {
        int issueNum = lIssue.getNumber();
        Value v = bidToUpdate.getValue(issueNum);
        switch (lIssue.getType()) {
          case DISCRETE:
            if (opponentBidsStatisticsDiscrete == null) {
              System.out.println("opponentBidsStatisticsDiscrete is NULL");
            } else if (opponentBidsStatisticsDiscrete.get(discreteIndex) != null) {
              int counterPerValue = opponentBidsStatisticsDiscrete.get(discreteIndex).get(v);
              if (toRemove) {
                counterPerValue--;
              } else {
                counterPerValue++;
              }
              opponentBidsStatisticsDiscrete.get(discreteIndex).put(v, counterPerValue);
            }
            discreteIndex++;
            break;

          case REAL:
            IssueReal lIssueReal = (IssueReal) lIssue;
            int lNumOfPossibleRealValues = lIssueReal.getNumberOfDiscretizationSteps();
            double lOneStep =
                (lIssueReal.getUpperBound() - lIssueReal.getLowerBound())
                    / lNumOfPossibleRealValues;
            double first = lIssueReal.getLowerBound();
            double last = lIssueReal.getLowerBound() + lOneStep;
            double valueReal = ((ValueReal) v).getValue();
            boolean found = false;

            for (int i = 0;
                !found && i < opponentBidsStatisticsForReal.get(realIndex).size();
                i++) {
              if (valueReal >= first && valueReal <= last) {
                int countPerValue = opponentBidsStatisticsForReal.get(realIndex).get(i);
                if (toRemove) {
                  countPerValue--;
                } else {
                  countPerValue++;
                }

                opponentBidsStatisticsForReal.get(realIndex).set(i, countPerValue);
                found = true;
              }
              first = last;
              last = last + lOneStep;
            }
            // If no matching value was found, update the last cell
            if (found == false) {
              int i = opponentBidsStatisticsForReal.get(realIndex).size() - 1;
              int countPerValue = opponentBidsStatisticsForReal.get(realIndex).get(i);
              if (toRemove) {
                countPerValue--;
              } else {
                countPerValue++;
              }

              opponentBidsStatisticsForReal.get(realIndex).set(i, countPerValue);
            }
            realIndex++;
            break;

          case INTEGER:
            IssueInteger lIssueInteger = (IssueInteger) lIssue;
            int valueInteger = ((ValueInteger) v).getValue();

            int valueIndex =
                valueInteger
                    - lIssueInteger
                        .getLowerBound(); // For ex. LowerBound index is 0, and the lower bound is
            // 2, the value is 4, so the index of 4 would be 2 which
            // is exactly 4-2
            int countPerValue = opponentBidsStatisticsForInteger.get(integerIndex).get(valueIndex);
            if (toRemove) {
              countPerValue--;
            } else {
              countPerValue++;
            }
            opponentBidsStatisticsForInteger.get(integerIndex).set(valueIndex, countPerValue);
            integerIndex++;
            break;
        }
      }
    } catch (Exception e) {
      System.out.println("Exception in updateStatistics: " + e.getMessage());
    }
  }