[338] | 1 | package bargainingchips.utilityfunctions;
|
---|
| 2 |
|
---|
| 3 | import java.util.Random;
|
---|
| 4 | import bargainingchips.Bundle;
|
---|
| 5 | import bargainingchips.ChipIssueValue;
|
---|
| 6 | import bargainingchips.utilityfunctions.UF_BezierPriceBezierQuantity;
|
---|
| 7 | import bargainingchips.utilityfunctions.UF_BezierPriceGaussianQuantity;
|
---|
| 8 | import bargainingchips.utilityfunctions.UF_CloseToQuantity;
|
---|
| 9 | import bargainingchips.utilityfunctions.UF_IntensifiedLessPriceCloseToQuantity;
|
---|
| 10 | import bargainingchips.utilityfunctions.UF_LessPrice;
|
---|
| 11 | import bargainingchips.utilityfunctions.UF_LessPriceCloseToQuantity;
|
---|
| 12 | import bargainingchips.utilityfunctions.UF_PeakedFlatCurvePriceGaussianQuantity;
|
---|
| 13 | import bargainingchips.utilityfunctions.UF_PeakedFlatPricePeakedFlatQuantity;
|
---|
| 14 | import bargainingchips.utilityfunctions.UF_PeakedPricePeakedQuantity;
|
---|
[340] | 15 | import bargainingchips.wishlist.WishList;
|
---|
[338] | 16 |
|
---|
| 17 | /**
|
---|
| 18 | *
|
---|
| 19 | * This class works to pick a random utility function and pass the buyer's preferences to.
|
---|
| 20 | *
|
---|
| 21 | * Besides the buyer operator, it is useful for the experiments in which it is required
|
---|
| 22 | * to create several random agents to negotiate on behalf of the buyer.
|
---|
| 23 | *
|
---|
| 24 | * The utility functions are UF_CloseToQuantity, UF_LessPrice, UF_LessPriceCloseToQuantity,
|
---|
| 25 | * UF_IntensifiedLessPriceCloseToQuantity, UF_PeakedPricePeakedQuantity, UF_PeakedFlatPricePeakedFlatQuantity,
|
---|
| 26 | * UF_PeakedFlatCurvePriceGaussianQuantity, UF_BezierPriceBezierQuantity, and UF_BezierPriceGaussianQuantity.
|
---|
| 27 | *
|
---|
| 28 | * They receive different number and types of parameters.
|
---|
| 29 | *
|
---|
| 30 | *
|
---|
| 31 | * @author Faria Nassiri-Mofakham
|
---|
| 32 | *
|
---|
| 33 | */
|
---|
| 34 | public class UF implements UtilityFunction
|
---|
| 35 | {
|
---|
| 36 | WishList wishlist; // example: {Yellow=6, Orange=40, Green=4}
|
---|
| 37 | ChipIssueValue<Double> breakEvenPrices; // example: {Yellow=5.0, Orange=1.0, Green=3.0}
|
---|
| 38 | ChipIssueValue<Double[]> prices1; // example: ChipIssueValueBuilder<Double[]>().addIssue("Green", new Double[] {3.0, 4.8}).addIssue("Yellow", new Double[] {5.0, 8.0}).addIssue("Orange", new Double[] {1.0, 2.5}).build();
|
---|
| 39 | ChipIssueValue<Double> uPrices1; // example: ChipIssueValueBuilder<Double>().addIssue("Green", 1.0).addIssue("Yellow", 0.8).addIssue("Orange", 0.75).build();
|
---|
| 40 | ChipIssueValue<Integer> deviations1; // example: {Yellow=1, Orange=10, Green=1}
|
---|
| 41 | ChipIssueValue<Double[]> prices2; // example: { Yellow={5.0, 5.2, 6.2, 8.0} Orange={1.0, 1.8, 2.5, 3.0} Green={3.0, 3.5, 4.8, 5.0} }
|
---|
| 42 | ChipIssueValue<Double[]> uPrices2; // example: { Yellow={0.8, 0.1} Orange={0.9, 0.3} Green={0.7, 0.2} }
|
---|
| 43 | ChipIssueValue<Double[]> deviations2; // example: { Yellow={50.0, 30.0, 30.0, 50.0} Orange={200.0, 40.0, 60.0, 1000.0} Green={100.0, 20.0, 50.0, 500.0} }
|
---|
| 44 | ChipIssueValue<Double[]> uDev2; // example: { Yellow={0.3, 0.7, 0.7, 0.3} Orange={0.15, 0.95, 0.85, 0.3} Green={0.25, 0.8, 0.9, 0.1} }
|
---|
| 45 | ChipIssueValue<Integer[]> deviations3; // example: { Yellow={3, 2, 2, 3} Orange={10, 2, 5, 10} Green={2, 1, 2, 3} }
|
---|
| 46 | ChipIssueValue<Double> wC; // example: {Yellow=0.3, Orange=0.2, Green=0.5}
|
---|
| 47 | double wP; // example: 0.6;
|
---|
| 48 | double wQ; // example: 0.4;
|
---|
| 49 | boolean pVq; // example: true; true, if less price is more important; false, if close to quantity is important.
|
---|
| 50 | int m; // example: 4; input Bezier points
|
---|
| 51 |
|
---|
| 52 | UtilityFunction u = null;
|
---|
| 53 |
|
---|
| 54 | public UF (
|
---|
| 55 | WishList wish,
|
---|
| 56 | ChipIssueValue<Double> breakEvenP,
|
---|
| 57 | ChipIssueValue<Double[]> pr1,
|
---|
| 58 | ChipIssueValue<Double> uPr1,
|
---|
| 59 | ChipIssueValue<Integer> dev1,
|
---|
| 60 | ChipIssueValue<Double[]> pr2,
|
---|
| 61 | ChipIssueValue<Double[]> uPr2,
|
---|
| 62 | ChipIssueValue<Double[]> dev2,
|
---|
| 63 | ChipIssueValue<Double[]> uDv2,
|
---|
| 64 | ChipIssueValue<Integer[]> dev3,
|
---|
| 65 | ChipIssueValue<Double> c,
|
---|
| 66 | double p,
|
---|
| 67 | double q,
|
---|
| 68 | boolean pq,
|
---|
| 69 | int n
|
---|
| 70 | )
|
---|
| 71 | {
|
---|
| 72 | wishlist = wish;
|
---|
| 73 | breakEvenPrices = breakEvenP;
|
---|
| 74 | prices1 = pr1;
|
---|
| 75 | uPrices1 = uPr1;
|
---|
| 76 | deviations1 = dev1;
|
---|
| 77 | prices2 = pr2;
|
---|
| 78 | uPrices2 = uPr2;
|
---|
| 79 | deviations2 = dev2;
|
---|
| 80 | uDev2 = uDv2;
|
---|
| 81 | deviations3 = dev3;
|
---|
| 82 | wC = c;
|
---|
| 83 | wP = p;
|
---|
| 84 | wQ = q;
|
---|
| 85 | pVq = pq;
|
---|
| 86 | m = n;
|
---|
| 87 | }
|
---|
| 88 |
|
---|
| 89 | @Override
|
---|
| 90 | public Double getUtility(Bundle b)
|
---|
| 91 | {
|
---|
| 92 | // boolean priceVSQuantity = ((new Random().nextInt(2)+1 == 1) ? true : false);
|
---|
| 93 | switch(new Random().nextInt(9)+1)
|
---|
| 94 | {
|
---|
| 95 | case 1: u = new UF_CloseToQuantity(wishlist); break;
|
---|
| 96 | case 2: u = new UF_LessPrice(wishlist, breakEvenPrices); break;
|
---|
| 97 | case 3: u = new UF_LessPriceCloseToQuantity(wishlist, breakEvenPrices); break;
|
---|
| 98 | case 4: u = new UF_IntensifiedLessPriceCloseToQuantity(wishlist, breakEvenPrices, pVq); break;
|
---|
| 99 | case 5: u = new UF_PeakedPricePeakedQuantity(wishlist, breakEvenPrices, deviations1, wC, wP, wQ); break;
|
---|
| 100 | case 6: u = new UF_PeakedFlatPricePeakedFlatQuantity(wishlist, deviations2, uDev2, prices2, uPrices2, wC, wP, wQ); break;
|
---|
| 101 | case 7: u = new UF_PeakedFlatCurvePriceGaussianQuantity<Double>(wishlist, prices1, uPrices1, deviations1, wC, wP, wQ); break;
|
---|
| 102 | case 8: u = new UF_BezierPriceBezierQuantity<Double> (wishlist, m, prices2, deviations3, wC, wP, wQ); break;
|
---|
| 103 | case 9: u = new UF_BezierPriceGaussianQuantity<Double> (wishlist, m, prices2, deviations1, wC, wP, wQ); break;
|
---|
| 104 | }
|
---|
| 105 | return u.getUtility(b);
|
---|
| 106 | }
|
---|
| 107 |
|
---|
| 108 | @Override
|
---|
| 109 | public String toString()
|
---|
| 110 | {
|
---|
| 111 | return u.toString();
|
---|
| 112 | }
|
---|
| 113 |
|
---|
| 114 | // public static void main(String[] args)
|
---|
| 115 | // {
|
---|
| 116 | // System.out.println(u.getClass().getName());
|
---|
| 117 | // }
|
---|
| 118 |
|
---|
| 119 | }
|
---|