Line | |
---|
1 | package negotiator.onetomany;
|
---|
2 |
|
---|
3 | import java.util.ArrayList;
|
---|
4 | import java.util.Iterator;
|
---|
5 |
|
---|
6 | import org.apache.commons.math3.analysis.function.Abs;
|
---|
7 |
|
---|
8 | public class Utility
|
---|
9 | {
|
---|
10 | Bid bid;
|
---|
11 |
|
---|
12 | public Utility()
|
---|
13 | {
|
---|
14 | Product redProduct = new Product("Red");
|
---|
15 | Product pinkProduct = new Product("Pink");
|
---|
16 | Product blueProduct = new Product("Blue");
|
---|
17 |
|
---|
18 | Bid desiredBid = new Bid();
|
---|
19 | desiredBid.setQuantity(redProduct, 4);
|
---|
20 | desiredBid.setQuantity(pinkProduct, 4);
|
---|
21 | desiredBid.setQuantity(blueProduct, 2);
|
---|
22 |
|
---|
23 |
|
---|
24 |
|
---|
25 |
|
---|
26 | for (Product product : portfolio.getPortfolio())
|
---|
27 | demandPlan.setQuantity(product, (int)(Math.random()*numType+1));
|
---|
28 |
|
---|
29 |
|
---|
30 | double weight[]= {0.6,0.3,0.1};
|
---|
31 |
|
---|
32 | for (Product product : bid.getBid().keySet())
|
---|
33 | {
|
---|
34 | Integer q = bid.getQuantity(product);
|
---|
35 |
|
---|
36 | int sum += Abs(desierdQTY[bid.getKeys()]-q)*weight[product];
|
---|
37 | }
|
---|
38 |
|
---|
39 | this.getUtility=sum
|
---|
40 |
|
---|
41 | this.utility = new ArrayList<Product>();
|
---|
42 | }
|
---|
43 |
|
---|
44 | double getUtility(Bid b)
|
---|
45 | {
|
---|
46 |
|
---|
47 | return
|
---|
48 | }
|
---|
49 |
|
---|
50 |
|
---|
51 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.