source: src/main/java/onetomany/bargainingchipsgame/players/utilityfunction/UF_Peaked.java@ 290

Last change on this file since 290 was 290, checked in by Faria Nassiri Mofakham, 5 years ago

UF_Peaked class created, by creating a class for ChipMappingType (more functionality than ChipMapping), and adding a method for getUnitPrice to Bundle class. Some comments added to UtilityFunction interface.

File size: 4.0 KB
Line 
1/**
2 * UF_Peaked class
3 */
4package onetomany.bargainingchipsgame.players.utilityfunction;
5
6
7import onetomany.bargainingchipsgame.Bundle;
8import onetomany.bargainingchipsgame.Chip;
9import onetomany.bargainingchipsgame.ChipMappingType;
10import onetomany.bargainingchipsgame.Stack;
11import onetomany.bargainingchipsgame.WishList;
12
13/**
14 *
15 * According to Equation (1) [1], the buyer with peaked utility function evaluates bundles with price 0, as 1.0, and any price greater than the total break even unit price of the chips in the bundle, as 0.0.
16 * For any other price between the two, she follows a linear downward function. However, regarding the quantity she checks per chip, so that if the quantity of the chip is equal to that she wished, it gets 1.0.
17 * She may tolerate a deviation around this desired quantity. Any quantity outside this range would be evaluated as 0.0. The quantities within this range would be evaluated via a linear downward function and linear
18 * upward function respectively for quantities greater than or less that the desired quantity, both with a peak at the desired quantity.
19 *
20 * UF_peaked ignores any color which is not introduced in wishlist (i.e., free disposal) and takes the following values as input:
21 * \phi_c, \kappa_c, \sigma_c, and \lambda_c, respectively the break even unit price, the exact quantity, the acceptable deviation around \kappa_c,
22 * the importance of the chip with color c,
23 * p_c, q_c, \lambda_q, and \lambda_p, respectively the unit price, quantity of the chip with color c and the importance of quantity and price in offer \omega
24 *
25 * And outputs u(\omega), where \omega is the offer to evaluate.
26 *
27 *
28 * Equation (1):
29 *
30 * UF_Peacked(Bundle \omega) = \lambda_p [ 1 - ( \sum{\lambda_c * p_c * q_c} / \sum{\lambda_c * \phi_c * \kappa_c} ) ]
31 * + \lambda_q [ 1+ (-1)^\psi_c * (q_c - \kappa_c) / \sigma_c ]
32 *
33 * where,
34 * \psi_c = 1, if q_c >= \kappa_c, otherwise, 0.
35 * \lambda_p + \lambda_q = 1
36 * \sum{\lambda_c} = 1
37 *
38 *
39 *
40 * Reference:
41 * [1] T. Baarslag and F. Nassiri-Mofakham, `Bargaining Chips: A Test-bed for Multi-Deal One-to-Many Negotiations', AAMAS'20, May 2020, Auckland, New Zeland.
42 *
43 *
44 *
45 * @author Faria Nassiri-Mofakham
46 *
47 */
48public class UF_Peaked implements UtilityFunction {
49
50 private WishList wishlist; //q_c
51 private ChipMappingType<Integer> qtyDeviation; // sigma_c. Assuming a symmetric deviation. Of course, two different deviation could also be considered for quantities less or more than the exact qty per chip
52 private ChipMappingType<Double> breakEvenPrice, lambdaC; // kappa_c and lambda_c
53 private double lambdaP,lambdaQ; // lambda_p and lambda_q
54
55
56 public UF_Peaked(WishList w, ChipMappingType<Integer> qtyDev, ChipMappingType<Double> bEP, ChipMappingType<Double> lc, double lp, double lq)
57 {
58 wishlist=w;
59 qtyDeviation=qtyDev;
60 breakEvenPrice=bEP;
61 lambdaC=lc;
62 lambdaP=lp;
63 lambdaQ=lq;
64 }
65
66
67 @Override
68 public Double getUtility(Bundle b)
69 {
70 // TODO Auto-generated method stub
71 //int num=wishlist.size();
72
73 double sum1=0.0;
74 double sum2=0.0;
75 double sum3=0.0;
76
77 if (b!=null)
78 {
79 for (Chip c : wishlist)
80 {
81 int desiredQ = wishlist.getQuantity(c);
82 Double desiredP= breakEvenPrice.getUnitValue(c);
83 Double importanceC= lambdaC.getUnitValue(c);
84 int devC= qtyDeviation.getUnitValue(c);
85
86
87 for (Stack s : b)
88 {
89 Integer offeredQ = b.getQuantity(c);
90 Double offeredP= b.getUnitPrice(c);
91
92 int sign = ((offeredQ >= desiredQ) ? 1 : 0);
93
94 if (s.getChip().equals(c) && offeredQ != null)
95 {
96 sum1 += importanceC * offeredP * offeredQ;
97 sum2 += importanceC * desiredP * desiredQ;
98 sum3 += importanceC * (1+ Math.pow(-1,sign)*(offeredQ - desiredQ)/devC);
99 }
100 }
101 }
102 return lambdaP * (1-sum1/sum2) + lambdaQ * sum3;
103 }
104 return 0.0;
105 }
106
107
108 @Override
109 public String toString()
110 {
111 return this.getClass().getSimpleName();
112 }
113 }
Note: See TracBrowser for help on using the repository browser.