source: src/main/java/agents/UtilityBasedAcceptor.java@ 127

Last change on this file since 127 was 127, checked in by Wouter Pasman, 6 years ago

#41 ROLL BACK of rev.126 . So this version is equal to rev. 125

File size: 1.4 KB
RevLine 
[127]1package agents;
2
3import java.util.ArrayList;
4import java.util.List;
5
6import genius.core.Bid;
7import genius.core.BidIterator;
8import genius.core.SupportedNegotiationSetting;
9
10/**
11 * This agent does not concede, but will accept anything equal to or above the
12 * reservation value. For undiscounted domain only.
13 */
14public class UtilityBasedAcceptor extends TimeDependentAgent {
15
16 private List<Bid> acceptableBids;
17
18 @Override
19 public double getE() {
20 return 0;
21 }
22
23 @Override
24 public String getName() {
25 return "Utility Based Acceptor";
26 }
27
28 @Override
29 public void init() {
30 super.init();
31 acceptableBids = new ArrayList<Bid>();
32
33 BidIterator iter = new BidIterator(this.utilitySpace.getDomain());
34 while (iter.hasNext()) {
35 Bid bid = iter.next();
36 try {
37
38 if (getUtility(bid) >= utilitySpace.getReservationValue() && (Math.random() <= getUtility(bid)))
39 this.acceptableBids.add(bid);
40
41 } catch (Exception e) {
42 e.printStackTrace();
43 }
44 }
45
46 }
47
48 @Override
49 public boolean isAcceptable(Bid plannedBid) {
50 Bid opponentLastBid = getOpponentLastBid();
51 if (this.acceptableBids.contains(opponentLastBid))
52 return true;
53 else
54 return false;
55 }
56
57 @Override
58 public SupportedNegotiationSetting getSupportedNegotiationSetting() {
59 return SupportedNegotiationSetting.getLinearUtilitySpaceInstance();
60 }
61
62 @Override
63 public String getDescription() {
64 return "Utility Based Acceptor";
65 }
66}
Note: See TracBrowser for help on using the repository browser.