source: src/main/java/bargainingchips/tests/BundleTest.java@ 341

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

BargainingChips creates bob calling BargainingBuyer. OutcomeSpace is Iterable<Bundle>, also getAllBids, getRandom, getRandom(r), getAverageUtility(u), size(), checkReadyForNegotiation, getName(), getUtility(u, b), getReservationValue(u), and getDiscountFactor added. An update on Bid getSampleBid type. An update on Agent. A history' package of BidEvent, BidEventHistory, BidEventHisoryKeeper, BidEventSortedUtility, and BidEventStrictSortedUtility added. HistoryAgent added. An analysis' package of BundleUtilityPoint, BundleUtilitySpace, and ParetoFrontier added. BargainingAgent added. TitForTatNegotiationAgent. Now, Buyer extended to BargainingBuyer which is created using Boulware or TitForTatNegotiationAgent using one among 9 utility functions. Name of strategy added toDescription in BoulwareAgent. A few small updates on several utility function classes.

File size: 2.3 KB
Line 
1package bargainingchips.tests;
2
3import static org.junit.Assert.assertEquals;
4
5import org.junit.Test;
6
7import bargainingchips.Stack;
8import bargainingchips.Bundle;
9import bargainingchips.BundleBuilder;
10
11
12public class BundleTest
13{
14
15 @Test
16 public void testConstructor()
17 {
18
19 Bundle a = new BundleBuilder()
20 .addStack("White", 4.0, 30)
21 .addStack("Yellow", 6.0, 20)
22 .build();
23
24 Bundle b = new BundleBuilder()
25 .addStack("Red", 1.0, 10)
26 .addStack("Blue", 8.0, 30)
27 .addStack("Orange", 4.0, 30)
28 .addStack("Pink", 8.0, 80)
29 .build();
30
31 assertEquals(a.size(), 2);
32
33 assertEquals(b.size(), 4);
34
35 assertEquals(a.getTotalPrice(), 240.0 , 0.0);
36
37 assertEquals(b.getTotalPrice(), 1010.0 , 0.0);
38 }
39
40 @Test
41 public void testAggregationSymmetry()
42 {
43
44 System.out.println("7 Agrregation tests: ");
45
46 Bundle a = new BundleBuilder()
47 .addStack("White", 4.0, 30)
48 .addStack("Yellow", 6.0, 20)
49 .build();
50
51 Bundle b = new BundleBuilder()
52 .addStack("Red", 1.0, 10)
53 .addStack("Blue", 8.0, 30)
54 .addStack("Orange", 4.0, 30)
55 .addStack("Pink", 8.0, 80)
56 .build();
57
58 Bundle aPlusb = a.aggregateWith(b);
59 System.out.println("1. " + a + " + " + b + " = " + aPlusb);
60
61 Bundle bPlusa = b.aggregateWith(a);
62 System.out.println("2. " + b + " + " + a + " = " + bPlusa);
63
64 Stack s = new Stack("Green", 7.0, 5);
65
66 Bundle aPluss = a.aggregateWith(s);
67 System.out.println("3. " + a + " + " + s + " = " + aPluss);
68
69
70 Bundle c = new BundleBuilder()
71 .addStack("Green", 7.0, 5)
72 .addStack("Yellow", 6.0, 20)
73 .build();
74
75 Stack t = new Stack("White", 4.0, 30);
76 Bundle cPlust = c.aggregateWith(t);
77 System.out.println("4. " + c + " + " + t + " = " + cPlust);
78
79 assertEquals(aPluss.getTotalPrice(), cPlust.getTotalPrice());
80
81
82 Stack u = new Stack("Red", 3.0, 20);
83
84 Bundle bPlusu = b.aggregateWith(u);
85 System.out.println("5. " + b + " + " + u + " = " + bPlusu);
86
87
88 Bundle d = null;
89 Bundle aPlusd = a.aggregateWith(d);
90 System.out.println("6. " + a + " + " + d + " = " + aPlusd);
91
92
93
94 Stack v = null;
95
96 Bundle bPlusv = b.aggregateWith(v);
97 System.out.println("7. " + b + " + " + v + " = " + bPlusv);
98
99
100 }
101
102}
Note: See TracBrowser for help on using the repository browser.