source: src/main/java/agents/anac/y2015/group2/G2IssueSubSet.java

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

Initial import : Genius 9.0.0

File size: 1.4 KB
Line 
1package agents.anac.y2015.group2;
2
3import java.util.ArrayList;
4import java.util.Collections;
5import java.util.HashMap;
6import java.util.Iterator;
7import java.util.LinkedList;
8
9class G2IssueSubSet {
10 ArrayList<String> issues;
11 LinkedList<G2SubBid> subBids;
12
13 G2IssueSubSet (String issue, LinkedList<G2SubBid> subBids) {
14 issues = new ArrayList<String>(1);
15 issues.add(issue);
16
17 this.subBids = subBids;
18 }
19
20 G2IssueSubSet(G2IssueSubSet one, G2IssueSubSet two) {
21 issues = new ArrayList<String>(one.issues.size() + two.issues.size());
22 issues.addAll(one.issues);
23 issues.addAll(two.issues);
24
25 subBids = new LinkedList<G2SubBid>();
26 for(G2SubBid bidOne : one.subBids) {
27 for(G2SubBid bidTwo : two.subBids) {
28 subBids.add(new G2SubBid(bidOne, bidTwo));
29 }
30 }
31 }
32
33 ArrayList<G2Bid> generateBids() {
34 ArrayList<G2Bid> bids = new ArrayList<G2Bid>();
35 for(G2SubBid subBid: subBids) {
36 HashMap<String, String> map = new HashMap<String, String>();
37 for(int i=issues.size()-1;i>=0; i--) {
38 map.put(issues.get(i), subBid.getValue(i));
39 }
40 bids.add(new G2Bid(map));
41 }
42 return bids;
43 }
44
45 void trimSubBids() {
46 Collections.sort(subBids);
47 Iterator<G2SubBid> iter = subBids.descendingIterator();
48 G2SubBid previous = null;
49
50 while(iter.hasNext()) {
51 G2SubBid curr = iter.next();
52 if (!curr.hasHigherOtherUtilities(previous)) {
53 //System.out.println("Bid removed");
54 iter.remove();
55 }
56 previous = curr;
57 }
58 }
59}
Note: See TracBrowser for help on using the repository browser.