source: anac2020/AhBuNeAgent/src/main/java/negotiator/ahbuneagent/linearorder/OppSimpleLinearOrdering.java

Last change on this file was 1, checked in by wouter, 4 years ago

#1910 added anac2020 parties

File size: 1.6 KB
Line 
1package negotiator.ahbuneagent.linearorder;
2
3import geniusweb.issuevalue.Bid;
4
5import java.math.BigDecimal;
6import java.util.ArrayList;
7import java.util.Collections;
8import java.util.List;
9
10public class OppSimpleLinearOrdering {
11
12 private List<Bid> bids; // worst bid first, best bid last.
13
14 public OppSimpleLinearOrdering() {
15 this.bids = new ArrayList<>();
16 }
17
18 public BigDecimal getUtility(Bid bid) {
19 if (!bids.contains(bid)) {
20 return BigDecimal.ZERO;
21 }
22 return new BigDecimal(bids.indexOf(bid) + 1);
23 }
24
25 public Bid getMaxBid(){
26 if(bids.size() > 0){
27 return bids.get(bids.size() - 1);
28 }
29 return null;
30 }
31
32 public int getKnownBidsSize(){
33 return bids.size();
34 }
35
36 public boolean isAvailable(){
37 if(bids.size() < 6){
38 return false;
39 }
40 return true;
41 }
42
43 public boolean contains(Bid bid) {
44 return bids.contains(bid);
45 }
46
47 public List<Bid> getBids() {
48 return Collections.unmodifiableList(bids);
49 }
50 public Bid getBidByIndex(int index) {
51 if(index < bids.size()){
52 return bids.get(index);
53 }
54 return null;
55 }
56
57 // if a bid is not changing at first, it means it is important for opponent,
58 // bids are going to be conceded after a while due to importance decreases
59 public void updateBid(Bid bid) {
60 if(!contains(bid))
61 //add the bid at the beginning of the array if not offered before
62 this.bids.add(0, bid);
63 }
64}
Note: See TracBrowser for help on using the repository browser.