Changeset 22
- Timestamp:
- 09/22/20 16:26:36 (4 years ago)
- Files:
-
- 48 edited
Legend:
- Unmodified
- Added
- Removed
-
bidspace/pom.xml
r21 r22 6 6 <groupId>geniusweb</groupId> 7 7 <artifactId>bidspace</artifactId> 8 <version>1.5. 0</version> <!-- must equal ${geniusweb.version} -->8 <version>1.5.1</version> <!-- must equal ${geniusweb.version} --> 9 9 <packaging>jar</packaging> 10 10 … … 16 16 <passwd>${env.ARTIFACTORY_PASS}</passwd> 17 17 <jackson-2-version>2.9.10</jackson-2-version> 18 <geniusweb.version>1.5. 0</geniusweb.version>18 <geniusweb.version>1.5.1</geniusweb.version> 19 19 </properties> 20 20 -
boa/pom.xml
r21 r22 6 6 <groupId>geniusweb</groupId> 7 7 <artifactId>boa</artifactId> 8 <version>1.5. 0</version> <!-- must equal ${geniusweb.version} -->8 <version>1.5.1</version> <!-- must equal ${geniusweb.version} --> 9 9 <packaging>jar</packaging> 10 10 … … 17 17 <passwd>${env.ARTIFACTORY_PASS}</passwd> 18 18 <jackson-2-version>2.9.10</jackson-2-version> 19 <geniusweb.version>1.5. 0</geniusweb.version>19 <geniusweb.version>1.5.1</geniusweb.version> 20 20 </properties> 21 21 -
collectparties.sh
r21 r22 7 7 rm -rf collectedparties 8 8 mkdir collectedparties 9 VERSION=1.5. 09 VERSION=1.5.1 10 10 11 11 cp "exampleparties/anac2019/agentgg/target/agentgg-${VERSION}-jar-with-dependencies.jar" collectedparties -
events/pom.xml
r21 r22 6 6 <groupId>geniusweb</groupId> 7 7 <artifactId>events</artifactId> 8 <version>1.5. 0</version> <!-- must equal ${geniusweb.version} -->8 <version>1.5.1</version> <!-- must equal ${geniusweb.version} --> 9 9 <packaging>jar</packaging> 10 10 … … 17 17 <passwd>${env.ARTIFACTORY_PASS}</passwd> 18 18 <jackson-2-version>2.9.10</jackson-2-version> 19 <geniusweb.version>1.5. 0</geniusweb.version>19 <geniusweb.version>1.5.1</geniusweb.version> 20 20 </properties> 21 21 -
events/src/main/java/geniusweb/actions/Vote.java
r21 r22 14 14 public class Vote extends ActionWithBid { 15 15 private final Integer minPower; 16 private final Integer maxPower; 16 17 17 18 /** … … 19 20 * @param bid the bid that is voted on 20 21 * @param minPower the minimum power this bid must get in order for the vote 21 * to be valid. If power=1 for all participants (usually the 22 * default) power can be interpreted as number of votes 22 * to be valid. Power is the sum of the powers of the 23 * parties that are in the deal. If power=1 for all 24 * participants (usually the default) power can be 25 * interpreted as number of votes 26 * @param maxPower the maximum power this bid must get in order for the vote 27 * to be valid. See {@link #minPower} 23 28 */ 24 29 @JsonCreator 25 30 public Vote(@JsonProperty("actor") PartyId id, @JsonProperty("bid") Bid bid, 26 @JsonProperty("minPower") Integer minPower) { 31 @JsonProperty("minPower") Integer minPower, 32 @JsonProperty("maxPower") Integer maxPower) { 27 33 super(id, bid); 28 34 this.minPower = minPower; 29 if (bid == null || minPower == null || minPower < 1) { 35 this.maxPower = maxPower; 36 if (bid == null || minPower == null || minPower < 1 || maxPower == null 37 || maxPower < minPower) { 30 38 throw new IllegalArgumentException( 31 "Vote must have non-null bid and minVotes, and min Votes must be >=1");39 "Vote must have non-null bid and minVotes, and minPower must be >=1 and maxPower must be >=minPower"); 32 40 } 33 41 } … … 35 43 /** 36 44 * 37 * @return the minimum number of votes this bid must get in order for the38 * v ote to be valid.45 * @return the minimum power this bid must get in order for the vote to be 46 * valid. 39 47 */ 40 48 public Integer getMinPower() { … … 42 50 } 43 51 52 /** 53 * 54 * @return the max power this bid must get in order for the vote to be 55 * valid. 56 */ 57 58 public Integer getMaxPower() { 59 return maxPower; 60 } 61 44 62 @Override 45 63 public String toString() { 46 return "Vote[" + getActor() + "," + getBid() + "," + minPower + "]"; 64 return "Vote[" + getActor() + "," + getBid() + "," + minPower + "," 65 + maxPower + "]"; 47 66 } 48 67 … … 51 70 final int prime = 31; 52 71 int result = super.hashCode(); 72 result = prime * result 73 + ((maxPower == null) ? 0 : maxPower.hashCode()); 53 74 result = prime * result 54 75 + ((minPower == null) ? 0 : minPower.hashCode()); … … 65 86 return false; 66 87 Vote other = (Vote) obj; 88 if (maxPower == null) { 89 if (other.maxPower != null) 90 return false; 91 } else if (!maxPower.equals(other.maxPower)) 92 return false; 67 93 if (minPower == null) { 68 94 if (other.minPower != null) -
events/src/test/java/actions/PartyIdTest.java
r1 r22 26 26 } 27 27 28 @SuppressWarnings("unused") 28 29 @Test(expected = IllegalArgumentException.class) 29 30 public void testRestrictions() { … … 31 32 } 32 33 34 @SuppressWarnings("unused") 33 35 @Test(expected = IllegalArgumentException.class) 34 36 public void testRestrictions2() { … … 36 38 } 37 39 40 @SuppressWarnings("unused") 38 41 @Test(expected = IllegalArgumentException.class) 39 42 public void testRestrictions3() { … … 41 44 } 42 45 46 @SuppressWarnings("unused") 43 47 @Test(expected = IllegalArgumentException.class) 44 48 public void testRestrictions4() { … … 46 50 } 47 51 52 @SuppressWarnings("unused") 48 53 @Test(expected = IllegalArgumentException.class) 49 54 public void testRestrictions5() { … … 56 61 } 57 62 63 @SuppressWarnings("unused") 58 64 @Test 59 65 public void testRestrictions6() { … … 61 67 } 62 68 69 @SuppressWarnings("unused") 63 70 @Test 64 71 public void testRestrictions7() { -
events/src/test/java/actions/PartyIdTest1.java
r1 r22 43 43 } 44 44 45 @SuppressWarnings("unused") 45 46 @Test(expected = IllegalArgumentException.class) 46 47 public void smokeTest() throws URISyntaxException { … … 48 49 } 49 50 51 @SuppressWarnings("unused") 50 52 @Test(expected = IllegalArgumentException.class) 51 53 public void nullTest() throws URISyntaxException { -
events/src/test/java/actions/VoteTest.java
r21 r22 6 6 import java.util.Arrays; 7 7 import java.util.HashMap; 8 import java.util.LinkedList;9 8 import java.util.List; 10 9 import java.util.Map; … … 39 38 private final static Value VALUE2 = new NumberValue("10"); 40 39 // issue 2 is NUMBER and thus serializes with leading '=' 41 private final String votestring = "{\"vote\":{\"actor\":\"party1\",\"bid\":{\"issuevalues\":{\"issue2\":10,\"issue1\":\"value1\"}},\"minPower\":1 }}";40 private final String votestring = "{\"vote\":{\"actor\":\"party1\",\"bid\":{\"issuevalues\":{\"issue2\":10,\"issue1\":\"value1\"}},\"minPower\":1,\"maxPower\":2}}"; 42 41 43 private static Vote vote1, vote1a, vote2, vote3, vote4 ;42 private static Vote vote1, vote1a, vote2, vote3, vote4, vote5; 44 43 45 44 static { … … 47 46 issuevalues.put(ISSUE2, VALUE2); 48 47 bid = new Bid(issuevalues); 49 vote1 = new Vote(id, bid, 1 );50 vote1a = new Vote(id, bid, 1 );48 vote1 = new Vote(id, bid, 1, 2); 49 vote1a = new Vote(id, bid, 1, 2); 51 50 52 vote2 = new Vote(id2, bid, 1 );51 vote2 = new Vote(id2, bid, 1, 2); 53 52 54 53 // values swapped, so different issuevalues. … … 56 55 issuevaluesb.put(ISSUE2, VALUE2); 57 56 bidb = new Bid(issuevaluesb); 58 vote3 = new Vote(id, bidb, 1 );57 vote3 = new Vote(id, bidb, 1, 2); 59 58 60 vote4 = new Vote(id, bid, 2); 59 vote4 = new Vote(id, bid, 2, 2); 60 vote5 = new Vote(id, bid, 1, 3); 61 61 62 62 } … … 64 64 @Override 65 65 public List<List<Vote>> getGeneralTestData() { 66 List<List<Vote>> list = new LinkedList<>(); 67 list.add(Arrays.asList(vote1, vote1a)); 68 list.add(Arrays.asList(vote2)); 69 list.add(Arrays.asList(vote3)); 70 list.add(Arrays.asList(vote4)); 71 return list; 66 return Arrays.asList(Arrays.asList(vote1, vote1a), Arrays.asList(vote2), 67 Arrays.asList(vote3), Arrays.asList(vote4), 68 Arrays.asList(vote5)); 72 69 } 73 70 74 71 @Override 75 72 public List<String> getGeneralTestStrings() { 76 return Arrays.asList("Vote.*party1.*issue2=10.*issue1=.value1.*1.*", 77 "Vote.*party2.*issue2=10.*issue1=.value1.*1.*", 78 "Vote.*party1.*issue2=10.*issue1=10.*1.*", 79 "Vote.*party1.*issue2=10.*issue1=.value1.*2.*"); 73 return Arrays.asList("Vote.*party1.*issue2=10.*issue1=.value1.*1.*2.*", 74 "Vote.*party2.*issue2=10.*issue1=.value1.*1.*2.*", 75 "Vote.*party1.*issue2=10.*issue1=10.*1.*2.*", 76 "Vote.*party1.*issue2=10.*issue1=.value1.*2.*2.*", 77 "Vote.*party1.*issue2=10.*issue1=.value1.*1.*3.*"); 80 78 } 81 79 -
events/src/test/java/actions/VotesTest.java
r21 r22 24 24 public class VotesTest extends GeneralTests<Votes> { 25 25 private final ObjectMapper jackson = new ObjectMapper(); 26 private final String votestring = "{\"Votes\":{\"actor\":\"partyA\",\"votes\":[{\"vote\":{\"actor\":\"partyA\",\"bid\":{\"issuevalues\":{\"is1\":\"val1\"}},\"minPower\":2 }},{\"vote\":{\"actor\":\"partyA\",\"bid\":{\"issuevalues\":{\"is1\":\"val2\"}},\"minPower\":2}}]}}";26 private final String votestring = "{\"Votes\":{\"actor\":\"partyA\",\"votes\":[{\"vote\":{\"actor\":\"partyA\",\"bid\":{\"issuevalues\":{\"is1\":\"val1\"}},\"minPower\":2,\"maxPower\":9}},{\"vote\":{\"actor\":\"partyA\",\"bid\":{\"issuevalues\":{\"is1\":\"val2\"}},\"minPower\":2,\"maxPower\":9}}]}}"; 27 27 28 28 private PartyId partyA = new PartyId("partyA"); … … 30 30 private Bid bid1 = new Bid("is1", new DiscreteValue("val1")), 31 31 bid2 = new Bid("is1", new DiscreteValue("val2")); 32 private Vote voteA1 = new Vote(partyA, bid1, 2 );33 private Vote voteA2 = new Vote(partyA, bid2, 2 );34 private Vote voteB1 = new Vote(partyB, bid1, 2 );35 private Vote voteB2 = new Vote(partyB, bid2, 2 );32 private Vote voteA1 = new Vote(partyA, bid1, 2, 9); 33 private Vote voteA2 = new Vote(partyA, bid2, 2, 9); 34 private Vote voteB1 = new Vote(partyB, bid1, 2, 9); 35 private Vote voteB2 = new Vote(partyB, bid2, 2, 9); 36 36 37 37 private Votes votes1 = new Votes(partyA, Arrays.asList(voteA1, voteA2)); … … 95 95 @Test 96 96 public void isExtendingTestLessPower() { 97 Vote powervoteA1 = new Vote(partyA, bid1, 3 );97 Vote powervoteA1 = new Vote(partyA, bid1, 3, 9); 98 98 Votes powerVotes = new Votes(partyA, Arrays.asList(powervoteA1)); 99 99 assertFalse(powerVotes.isExtending(votes1)); … … 103 103 @Test(expected = IllegalArgumentException.class) 104 104 public void testDuplicateBidsNotAllowed() { 105 Vote voteA1similar = new Vote(partyA, bid1, 3 );105 Vote voteA1similar = new Vote(partyA, bid1, 3, 9); 106 106 Votes votes = new Votes(partyA, Arrays.asList(voteA1, voteA1similar)); 107 107 } -
exampleparties/anac2019/agentgg/pom.xml
r21 r22 6 6 <groupId>geniusweb.exampleparties.anac2019</groupId> 7 7 <artifactId>agentgg</artifactId> 8 <version>1.5. 0</version> <!-- must equal ${geniusweb.version} -->8 <version>1.5.1</version> <!-- must equal ${geniusweb.version} --> 9 9 <packaging>jar</packaging> 10 10 … … 17 17 <passwd>${env.ARTIFACTORY_PASS}</passwd> 18 18 <jackson-2-version>2.9.6</jackson-2-version> 19 <geniusweb.version>1.5. 0</geniusweb.version>19 <geniusweb.version>1.5.1</geniusweb.version> 20 20 </properties> 21 21 -
exampleparties/anac2019/winkyagent/pom.xml
r21 r22 6 6 <groupId>geniusweb.exampleparties.anac2019</groupId> 7 7 <artifactId>winkyagent</artifactId> 8 <version>1.5. 0</version> <!-- must equal ${geniusweb.version} -->8 <version>1.5.1</version> <!-- must equal ${geniusweb.version} --> 9 9 <packaging>jar</packaging> 10 10 … … 17 17 <passwd>${env.ARTIFACTORY_PASS}</passwd> 18 18 <jackson-2-version>2.9.6</jackson-2-version> 19 <geniusweb.version>1.5. 0</geniusweb.version>19 <geniusweb.version>1.5.1</geniusweb.version> 20 20 </properties> 21 21 -
exampleparties/boulware/pom.xml
r21 r22 6 6 <groupId>geniusweb.exampleparties</groupId> 7 7 <artifactId>boulware</artifactId> 8 <version>1.5. 0</version> <!-- must equal ${geniusweb.version} -->8 <version>1.5.1</version> <!-- must equal ${geniusweb.version} --> 9 9 <packaging>jar</packaging> 10 10 … … 17 17 <passwd>${env.ARTIFACTORY_PASS}</passwd> 18 18 <jackson-2-version>2.9.10</jackson-2-version> 19 <geniusweb.version>1.5. 0</geniusweb.version>19 <geniusweb.version>1.5.1</geniusweb.version> 20 20 </properties> 21 21 -
exampleparties/comparebids/pom.xml
r21 r22 6 6 <groupId>geniusweb.exampleparties</groupId> 7 7 <artifactId>comparebids</artifactId> 8 <version>1.5. 0</version> <!-- must equal ${geniusweb.version} -->8 <version>1.5.1</version> <!-- must equal ${geniusweb.version} --> 9 9 <packaging>jar</packaging> 10 10 … … 17 17 <passwd>${env.ARTIFACTORY_PASS}</passwd> 18 18 <jackson-2-version>2.9.6</jackson-2-version> 19 <geniusweb.version>1.5. 0</geniusweb.version>19 <geniusweb.version>1.5.1</geniusweb.version> 20 20 </properties> 21 21 -
exampleparties/conceder/pom.xml
r21 r22 6 6 <groupId>geniusweb.exampleparties</groupId> 7 7 <artifactId>conceder</artifactId> 8 <version>1.5. 0</version> <!-- must equal ${geniusweb.version} -->8 <version>1.5.1</version> <!-- must equal ${geniusweb.version} --> 9 9 <packaging>jar</packaging> 10 10 … … 17 17 <passwd>${env.ARTIFACTORY_PASS}</passwd> 18 18 <jackson-2-version>2.9.10</jackson-2-version> 19 <geniusweb.version>1.5. 0</geniusweb.version>19 <geniusweb.version>1.5.1</geniusweb.version> 20 20 </properties> 21 21 -
exampleparties/hardliner/pom.xml
r21 r22 6 6 <groupId>geniusweb.exampleparties</groupId> 7 7 <artifactId>hardliner</artifactId> 8 <version>1.5. 0</version> <!-- must equal ${geniusweb.version} -->8 <version>1.5.1</version> <!-- must equal ${geniusweb.version} --> 9 9 <packaging>jar</packaging> 10 10 … … 17 17 <passwd>${env.ARTIFACTORY_PASS}</passwd> 18 18 <jackson-2-version>2.9.10</jackson-2-version> 19 <geniusweb.version>1.5. 0</geniusweb.version>19 <geniusweb.version>1.5.1</geniusweb.version> 20 20 </properties> 21 21 -
exampleparties/humangui/pom.xml
r21 r22 6 6 <groupId>geniusweb.exampleparties</groupId> 7 7 <artifactId>humangui</artifactId> 8 <version>1.5. 0</version> <!-- must equal ${geniusweb.version} -->8 <version>1.5.1</version> <!-- must equal ${geniusweb.version} --> 9 9 <packaging>jar</packaging> 10 10 … … 17 17 <passwd>${env.ARTIFACTORY_PASS}</passwd> 18 18 <jackson-2-version>2.9.6</jackson-2-version> 19 <geniusweb.version>1.5. 0</geniusweb.version>19 <geniusweb.version>1.5.1</geniusweb.version> 20 20 </properties> 21 21 -
exampleparties/linear/pom.xml
r21 r22 6 6 <groupId>geniusweb.exampleparties</groupId> 7 7 <artifactId>linear</artifactId> 8 <version>1.5. 0</version> <!-- must equal ${geniusweb.version} -->8 <version>1.5.1</version> <!-- must equal ${geniusweb.version} --> 9 9 <packaging>jar</packaging> 10 10 … … 17 17 <passwd>${env.ARTIFACTORY_PASS}</passwd> 18 18 <jackson-2-version>2.9.10</jackson-2-version> 19 <geniusweb.version>1.5. 0</geniusweb.version>19 <geniusweb.version>1.5.1</geniusweb.version> 20 20 </properties> 21 21 -
exampleparties/randomparty/pom.xml
r21 r22 6 6 <groupId>geniusweb.exampleparties</groupId> 7 7 <artifactId>randomparty</artifactId> 8 <version>1.5. 0</version> <!-- must equal ${geniusweb.version} -->8 <version>1.5.1</version> <!-- must equal ${geniusweb.version} --> 9 9 <packaging>jar</packaging> 10 10 … … 17 17 <passwd>${env.ARTIFACTORY_PASS}</passwd> 18 18 <jackson-2-version>2.9.6</jackson-2-version> 19 <geniusweb.version>1.5. 0</geniusweb.version>19 <geniusweb.version>1.5.1</geniusweb.version> 20 20 </properties> 21 21 -
exampleparties/randomparty/src/main/java/geniusweb/exampleparties/randomparty/RandomParty.java
r21 r22 39 39 * A simple party that places random bids and accepts when it receives an offer 40 40 * with sufficient utility. 41 * <h2>voting</h2> If the party receives a parameter "minPower", it will 42 * {@link Vote} using that minPower instead of the default value 2 if it 43 * receives a {@link Voting} request. 41 * <h2>parameters</h2> 42 * <table> 43 * <tr> 44 * <td>minPower</td> 45 * <td>This value is used as minPower for placed {@link Vote}s. Default value is 46 * 2.</td> 47 * </tr> 48 * <tr> 49 * <td>maxPower</td> 50 * <td>This value is used as maxPower for placed {@link Vote}s. Default value is 51 * infinity.</td> 52 * </tr> 53 * </table> 44 54 */ 45 55 public class RandomParty extends DefaultParty { … … 109 119 @Override 110 120 public String getDescription() { 111 return "places random bids until it can accept an offer with utility >0.6"; 121 return "places random bids until it can accept an offer with utility >0.6. " 122 + "Parameters minPower and maxPower can be used to control voting behaviour."; 112 123 } 113 124 … … 164 175 */ 165 176 private Votes vote(Voting voting) throws IOException { 166 Object val = settings.getParameters().get("minPow wer");167 Integer n= (val instanceof Integer) ? (Integer) val : 2;168 for (Bid bid : voting.getBids()) {169 System.out.println("Bid " + bid + "="170 + ((UtilitySpace) profileint.getProfile()).getUtility(bid));171 } 177 Object val = settings.getParameters().get("minPower"); 178 Integer minpower = (val instanceof Integer) ? (Integer) val : 2; 179 val = settings.getParameters().get("maxPower"); 180 Integer maxpower = (val instanceof Integer) ? (Integer) val 181 : Integer.MAX_VALUE; 182 172 183 List<Vote> votes = voting.getBids().stream().distinct() 173 .filter(bid -> isGood(bid)).map(bid -> new Vote(me, bid, n)) 184 .filter(bid -> isGood(bid)) 185 .map(bid -> new Vote(me, bid, minpower, maxpower)) 174 186 .collect(Collectors.toList()); 175 187 return new Votes(me, votes); -
exampleparties/randompartypy/pom.xml
r21 r22 6 6 <groupId>geniusweb.exampleparties</groupId> 7 7 <artifactId>randompyparty</artifactId> 8 <version>1.5. 0</version> <!-- must equal ${geniusweb.version} -->8 <version>1.5.1</version> <!-- must equal ${geniusweb.version} --> 9 9 <packaging>jar</packaging> 10 10 … … 17 17 <passwd>${env.ARTIFACTORY_PASS}</passwd> 18 18 <jackson-2-version>2.9.10</jackson-2-version> 19 <geniusweb.version>1.5. 0</geniusweb.version>19 <geniusweb.version>1.5.1</geniusweb.version> 20 20 </properties> 21 21 -
exampleparties/simpleboa/pom.xml
r21 r22 6 6 <groupId>geniusweb.exampleparties</groupId> 7 7 <artifactId>simpleboaparty</artifactId> 8 <version>1.5. 0</version> <!-- must equal ${geniusweb.version} -->8 <version>1.5.1</version> <!-- must equal ${geniusweb.version} --> 9 9 <packaging>jar</packaging> 10 10 … … 17 17 <passwd>${env.ARTIFACTORY_PASS}</passwd> 18 18 <jackson-2-version>2.9.6</jackson-2-version> 19 <geniusweb.version>1.5. 0</geniusweb.version>19 <geniusweb.version>1.5.1</geniusweb.version> 20 20 </properties> 21 21 -
exampleparties/simpleshaop/pom.xml
r21 r22 6 6 <groupId>geniusweb.exampleparties</groupId> 7 7 <artifactId>simpleshaop</artifactId> 8 <version>1.5. 0</version> <!-- must equal ${geniusweb.version} -->8 <version>1.5.1</version> <!-- must equal ${geniusweb.version} --> 9 9 <packaging>jar</packaging> 10 10 … … 17 17 <passwd>${env.ARTIFACTORY_PASS}</passwd> 18 18 <jackson-2-version>2.9.6</jackson-2-version> 19 <geniusweb.version>1.5. 0</geniusweb.version>19 <geniusweb.version>1.5.1</geniusweb.version> 20 20 </properties> 21 21 -
exampleparties/timedependentparty/pom.xml
r21 r22 6 6 <groupId>geniusweb.exampleparties</groupId> 7 7 <artifactId>timedependentparty</artifactId> 8 <version>1.5. 0</version> <!-- must equal ${geniusweb.version} -->8 <version>1.5.1</version> <!-- must equal ${geniusweb.version} --> 9 9 <packaging>jar</packaging> 10 10 … … 17 17 <passwd>${env.ARTIFACTORY_PASS}</passwd> 18 18 <jackson-2-version>2.9.10</jackson-2-version> 19 <geniusweb.version>1.5. 0</geniusweb.version>19 <geniusweb.version>1.5.1</geniusweb.version> 20 20 </properties> 21 21 -
issuevalue/pom.xml
r21 r22 6 6 <groupId>geniusweb</groupId> 7 7 <artifactId>issuevalue</artifactId> 8 <version>1.5. 0</version> <!-- must equal ${geniusweb.version} -->8 <version>1.5.1</version> <!-- must equal ${geniusweb.version} --> 9 9 <packaging>jar</packaging> 10 10 … … 17 17 <passwd>${env.ARTIFACTORY_PASS}</passwd> 18 18 <jackson-2-version>2.9.10</jackson-2-version> 19 <geniusweb.version>1.5. 0</geniusweb.version>19 <geniusweb.version>1.5.1</geniusweb.version> 20 20 </properties> 21 21 -
issuevalue/src/test/java/geniusweb/issuevalue/BidTest.java
r4 r22 83 83 } 84 84 85 @SuppressWarnings("unused") 85 86 @Test 86 87 public void bidTestSimple() { … … 89 90 } 90 91 92 @SuppressWarnings("unused") 91 93 @Test(expected = IllegalArgumentException.class) 92 94 public void bidTestNull() { … … 96 98 } 97 99 100 @SuppressWarnings("unused") 98 101 @Test 99 102 public void bidTestOkIssueValue() { … … 148 151 } 149 152 153 @SuppressWarnings("unused") 150 154 @Test 151 155 public void smokeTestConstructor2() { … … 153 157 } 154 158 159 @SuppressWarnings("unused") 155 160 @Test 156 161 public void smokeTestConstructor2b() { … … 158 163 } 159 164 165 @SuppressWarnings("unused") 160 166 @Test(expected = NullPointerException.class) 161 167 public void smokeTestConstructor2Null1() { … … 163 169 } 164 170 171 @SuppressWarnings("unused") 165 172 @Test(expected = NullPointerException.class) 166 173 public void smokeTestConstructor2Null2() { -
issuevalue/src/test/java/geniusweb/issuevalue/NumberValueTest.java
r1 r22 17 17 import com.fasterxml.jackson.databind.ObjectMapper; 18 18 19 import geniusweb.issuevalue.NumberValue;20 import geniusweb.issuevalue.Value;21 19 import tudelft.utilities.junit.GeneralTests; 22 20 … … 88 86 public void testDeserializeShorts() throws IOException { 89 87 ObjectMapper jackson = new ObjectMapper(); 90 ArrayList list = jackson.readValue("[1,2,3,4,5]", ArrayList.class); 88 @SuppressWarnings("unchecked") 89 ArrayList<Integer> list = jackson.readValue("[1,2,3,4,5]", 90 ArrayList.class); 91 91 System.out.println(list); 92 92 System.out.println(list.get(0).getClass()); … … 97 97 public void testDeserializeMix() throws IOException { 98 98 ObjectMapper jackson = new ObjectMapper(); 99 ArrayList list = jackson.readValue("[\"short\",1,2,3,4,5]", 99 @SuppressWarnings("unchecked") 100 ArrayList<Object> list = jackson.readValue("[\"short\",1,2,3,4,5]", 100 101 ArrayList.class); 101 102 System.out.println(list); -
opponentmodel/pom.xml
r21 r22 6 6 <groupId>geniusweb</groupId> 7 7 <artifactId>opponentmodel</artifactId> 8 <version>1.5. 0</version> <!-- must equal ${geniusweb.version} -->8 <version>1.5.1</version> <!-- must equal ${geniusweb.version} --> 9 9 <packaging>jar</packaging> 10 10 … … 17 17 <passwd>${env.ARTIFACTORY_PASS}</passwd> 18 18 <jackson-2-version>2.9.10</jackson-2-version> 19 <geniusweb.version>1.5. 0</geniusweb.version>19 <geniusweb.version>1.5.1</geniusweb.version> 20 20 </properties> 21 21 -
party/pom.xml
r21 r22 6 6 <groupId>geniusweb</groupId> 7 7 <artifactId>party</artifactId> 8 <version>1.5. 0</version> <!-- must equal ${geniusweb.version} -->8 <version>1.5.1</version> <!-- must equal ${geniusweb.version} --> 9 9 <packaging>jar</packaging> 10 10 … … 17 17 <passwd>${env.ARTIFACTORY_PASS}</passwd> 18 18 <jackson-2-version>2.9.10</jackson-2-version> 19 <geniusweb.version>1.5. 0</geniusweb.version>19 <geniusweb.version>1.5.1</geniusweb.version> 20 20 </properties> 21 21 -
party/src/test/java/geniusweb/party/inform/ActionDoneTest.java
r21 r22 76 76 } 77 77 78 @SuppressWarnings("unused") 78 79 @Test 79 80 public void nullTest() throws URISyntaxException { -
party/src/test/java/geniusweb/party/inform/OptInTest.java
r21 r22 30 30 private PartyId partyB = new PartyId("partyB"); 31 31 32 private final Vote voteA1 = new Vote(partyA, bid1, 2 );33 private final Vote voteB1 = new Vote(partyB, bid1, 2 );34 private final Vote voteB2 = new Vote(partyB, bid2, 2 );32 private final Vote voteA1 = new Vote(partyA, bid1, 2, 9); 33 private final Vote voteB1 = new Vote(partyB, bid1, 2, 9); 34 private final Vote voteB2 = new Vote(partyB, bid2, 2, 9); 35 35 36 36 private Votes votesA = new Votes(partyA, Arrays.asList(voteA1)); … … 41 41 private final OptIn optIn2 = new OptIn(Arrays.asList(votesA)); 42 42 43 private String asJson = "{\"OptIn\":{\"votes\":[{\"Votes\":{\"actor\":\"partyA\",\"votes\":[{\"vote\":{\"actor\":\"partyA\",\"bid\":{\"issuevalues\":{\"iss\":\"val1\"}},\"minPower\":2 }}]}},{\"Votes\":{\"actor\":\"partyB\",\"votes\":[{\"vote\":{\"actor\":\"partyB\",\"bid\":{\"issuevalues\":{\"iss\":\"val1\"}},\"minPower\":2}},{\"vote\":{\"actor\":\"partyB\",\"bid\":{\"issuevalues\":{\"iss\":\"val2\"}},\"minPower\":2}}]}}]}}";43 private String asJson = "{\"OptIn\":{\"votes\":[{\"Votes\":{\"actor\":\"partyA\",\"votes\":[{\"vote\":{\"actor\":\"partyA\",\"bid\":{\"issuevalues\":{\"iss\":\"val1\"}},\"minPower\":2,\"maxPower\":9}}]}},{\"Votes\":{\"actor\":\"partyB\",\"votes\":[{\"vote\":{\"actor\":\"partyB\",\"bid\":{\"issuevalues\":{\"iss\":\"val1\"}},\"minPower\":2,\"maxPower\":9}},{\"vote\":{\"actor\":\"partyB\",\"bid\":{\"issuevalues\":{\"iss\":\"val2\"}},\"minPower\":2,\"maxPower\":9}}]}}]}}"; 44 44 45 45 @Override -
profile/pom.xml
r21 r22 6 6 <groupId>geniusweb</groupId> 7 7 <artifactId>profile</artifactId> 8 <version>1.5. 0</version> <!-- must equal ${geniusweb.version} -->8 <version>1.5.1</version> <!-- must equal ${geniusweb.version} --> 9 9 <packaging>jar</packaging> 10 10 … … 17 17 <passwd>${env.ARTIFACTORY_PASS}</passwd> 18 18 <jackson-2-version>2.9.10</jackson-2-version> 19 <geniusweb.version>1.5. 0</geniusweb.version>19 <geniusweb.version>1.5.1</geniusweb.version> 20 20 </properties> 21 21 -
profile/src/test/java/geniusweb/profile/utilityspace/DiscreteValueSetUtilitiesTest.java
r9 r22 88 88 } 89 89 90 @SuppressWarnings("unused") 90 91 @Test 91 92 public void smokeTest() { … … 94 95 } 95 96 97 @SuppressWarnings("unused") 96 98 @Test(expected = IllegalArgumentException.class) 97 99 public void testTooLargeUtility() { … … 102 104 } 103 105 106 @SuppressWarnings("unused") 104 107 @Test(expected = IllegalArgumentException.class) 105 108 public void testNegativeUtility() { … … 110 113 } 111 114 115 @SuppressWarnings("unused") 112 116 @Test(expected = IllegalArgumentException.class) 113 117 public void testNullUtility() { … … 118 122 } 119 123 124 @SuppressWarnings("unused") 120 125 @Test(expected = NullPointerException.class) 121 126 public void testNullValueUtils() { … … 124 129 } 125 130 131 @SuppressWarnings("unused") 126 132 @Test(expected = NullPointerException.class) 127 133 public void testNullIssue() { -
profileconnection/pom.xml
r21 r22 6 6 <groupId>geniusweb</groupId> 7 7 <artifactId>profileconnection</artifactId> 8 <version>1.5. 0</version> <!-- must equal ${geniusweb.version} -->8 <version>1.5.1</version> <!-- must equal ${geniusweb.version} --> 9 9 <packaging>jar</packaging> 10 10 … … 17 17 <passwd>${env.ARTIFACTORY_PASS}</passwd> 18 18 <jackson-2-version>2.9.10</jackson-2-version> 19 <geniusweb.version>1.5. 0</geniusweb.version>19 <geniusweb.version>1.5.1</geniusweb.version> 20 20 </properties> 21 21 -
protocol/pom.xml
r21 r22 6 6 <groupId>geniusweb</groupId> 7 7 <artifactId>protocol</artifactId> 8 <version>1.5. 0</version> <!-- must equal ${geniusweb.version} -->8 <version>1.5.1</version> <!-- must equal ${geniusweb.version} --> 9 9 <packaging>jar</packaging> 10 10 … … 17 17 <passwd>${env.ARTIFACTORY_PASS}</passwd> 18 18 <jackson-2-version>2.9.10</jackson-2-version> 19 <geniusweb.version>1.5. 0</geniusweb.version>19 <geniusweb.version>1.5.1</geniusweb.version> 20 20 </properties> 21 21 -
protocol/src/main/java/geniusweb/protocol/session/mopac/MOPAC.java
r21 r22 145 145 ProtocolToPartyConnFactory connectionfactory) { 146 146 try { 147 System.out.println("starting MOPAC");147 //System.out.println("starting MOPAC"); 148 148 // we're in Phase.INIT still 149 149 connect(connectionfactory); … … 314 314 final ProtocolToPartyConn partyconn, final Action action, 315 315 long now) { 316 System.out.println("received " + action);316 //System.out.println("received " + action); 317 317 state = state.with(partyconn.getParty(), action, now); 318 318 checkEndPhase(System.currentTimeMillis()); … … 341 341 342 342 state = state.nextPhase(now); 343 343 344 startPhase(now); 344 345 } … … 351 352 */ 352 353 private void broadcastNegotiators(Inform info) { 353 System.out.println("broadcasting " + info);354 //System.out.println("broadcasting " + info); 354 355 for (PartyId party : state.getPhase().getPartyStates() 355 356 .getNegotiatingParties()) { -
protocol/src/main/java/geniusweb/protocol/session/mopac/MOPACState.java
r21 r22 14 14 import geniusweb.actions.PartyId; 15 15 import geniusweb.inform.Agreements; 16 import geniusweb.inform.OptIn; 16 17 import geniusweb.progress.Progress; 17 18 import geniusweb.progress.ProgressRounds; … … 22 23 import geniusweb.protocol.session.SessionState; 23 24 import geniusweb.protocol.session.mopac.phase.OfferPhase; 25 import geniusweb.protocol.session.mopac.phase.OptInPhase; 24 26 import geniusweb.protocol.session.mopac.phase.Phase; 25 27 import geniusweb.protocol.session.saop.SAOPSettings; … … 127 129 /** 128 130 * @param now current time ms since 1970 129 * @return the max possible duration in ms of th is phase. Maybe negative if130 * ew are past deadline131 * @return the max possible duration in ms of the NEXT phase. Maybe 0 or 132 * negative if past deadline. 131 133 */ 132 134 private Long getAvailablePhaseTime(long now) { 135 // explicit check, to check also the round counts. 136 if (incrementProgress().isPastDeadline(now + Phase.PHASE_MINTIME)) 137 return 0l; 133 138 return Math.min(progress.getTerminationTime().getTime() - now, 134 139 Phase.PHASE_MAXTIME); … … 196 201 Phase newphase = phase.next(now, 197 202 Math.min(remainingNegoTime, Phase.PHASE_MAXTIME)); 198 Progress newprogress = progress; 199 if (newphase instanceof OfferPhase 200 && progress instanceof ProgressRounds) 201 newprogress = ((ProgressRounds) progress).advance(); 202 203 return new MOPACState(newphase, actions, connections, newprogress, 204 getSettings(), partyprofiles); 203 204 return new MOPACState(newphase, actions, connections, 205 incrementProgress(), getSettings(), partyprofiles); 206 } 207 208 /** 209 * 210 * @return the next progress. Progress round advances if phase is 211 * {@link OptIn}. 212 */ 213 private Progress incrementProgress() { 214 if (progress instanceof ProgressRounds && phase instanceof OptInPhase) 215 return ((ProgressRounds) progress).advance(); 216 return progress; 205 217 } 206 218 … … 217 229 */ 218 230 public boolean isNewPhasePossible(long now) { 219 return phase.getPartyStates().getNegotiatingParties().size() >= 2 231 // System.out.println("phase=" + phase); 232 boolean a = phase.getPartyStates().getNegotiatingParties().size() >= 2 220 233 && getAvailablePhaseTime(now) > Phase.PHASE_MINTIME; 234 // System.out.println("newstate possible:" + a); 235 return a; 221 236 } 222 237 -
protocol/src/test/java/geniusweb/protocol/session/amop/AMOPSettingsTest.java
r21 r22 97 97 } 98 98 99 @SuppressWarnings("unused") 99 100 @Test(expected = IllegalArgumentException.class) 100 101 public void constructorNoDeadlineTest() { -
protocol/src/test/java/geniusweb/protocol/session/amop/AMOPStateTest.java
r21 r22 172 172 } 173 173 174 @SuppressWarnings("unused") 174 175 @Test 175 176 public void constructWithNullConnection() { … … 375 376 @Test 376 377 public void testCollectVotes() { 377 Votes vote1AB = new Votes(party1, 378 Arrays.asList(new Vote(party1, a, 2), new Vote(party1, b, 2))); 379 Votes vote2AB = new Votes(party2, 380 Arrays.asList(new Vote(party2, a, 2), new Vote(party2, b, 2))); 381 Votes vote3C = new Votes(party3, Arrays.asList(new Vote(party3, c, 2))); 382 Votes vote4AC = new Votes(party4, 383 Arrays.asList(new Vote(party4, a, 2), new Vote(party4, c, 2))); 378 Votes vote1AB = new Votes(party1, Arrays 379 .asList(new Vote(party1, a, 2, 9), new Vote(party1, b, 2, 9))); 380 Votes vote2AB = new Votes(party2, Arrays 381 .asList(new Vote(party2, a, 2, 9), new Vote(party2, b, 2, 9))); 382 Votes vote3C = new Votes(party3, 383 Arrays.asList(new Vote(party3, c, 2, 9))); 384 Votes vote4AC = new Votes(party4, Arrays 385 .asList(new Vote(party4, a, 2, 9), new Vote(party4, c, 2, 9))); 384 386 // party 1,2,4 vote for A, party 1,2 vote for B, party 3,4 vote for C. 385 387 // the biggest vote is P,Q,S … … 407 409 public void testNextPhase() { 408 410 // copy of above. todo cleanup 409 Votes vote1AB = new Votes(party1, 410 Arrays.asList(new Vote(party1, a, 2), new Vote(party1, b, 2))); 411 Votes vote2AB = new Votes(party2, 412 Arrays.asList(new Vote(party2, a, 2), new Vote(party2, b, 2))); 413 Votes vote3C = new Votes(party3, Arrays.asList(new Vote(party3, c, 2))); 414 Votes vote4AC = new Votes(party4, 415 Arrays.asList(new Vote(party4, a, 2), new Vote(party4, c, 2))); 411 Votes vote1AB = new Votes(party1, Arrays 412 .asList(new Vote(party1, a, 2, 9), new Vote(party1, b, 2, 9))); 413 Votes vote2AB = new Votes(party2, Arrays 414 .asList(new Vote(party2, a, 2, 9), new Vote(party2, b, 2, 9))); 415 Votes vote3C = new Votes(party3, 416 Arrays.asList(new Vote(party3, c, 2, 9))); 417 Votes vote4AC = new Votes(party4, Arrays 418 .asList(new Vote(party4, a, 2, 9), new Vote(party4, c, 2, 9))); 416 419 // party 1,2,4 vote for A, party 1,2 vote for B, party 3,4 vote for C. 417 420 // the biggest vote is P,Q,S -
protocol/src/test/java/geniusweb/protocol/tournament/allpermutations/AllPermutationsSettingsTest.java
r18 r22 68 68 profile2 = new ProfileRef("profile2"); 69 69 profile3 = new ProfileRef("profile3"); 70 ProfileListprofiles1 = new ProfileList(Arrays.asList(profile1));71 ProfileListprofiles2 = new ProfileList(Arrays.asList(profile2));72 ProfileListprofiles3 = new ProfileList(Arrays.asList(profile3));70 profiles1 = new ProfileList(Arrays.asList(profile1)); 71 profiles2 = new ProfileList(Arrays.asList(profile2)); 72 profiles3 = new ProfileList(Arrays.asList(profile3)); 73 73 74 74 List<ProfileList> profiles = Arrays.asList(profiles1, profiles2, … … 137 137 } 138 138 139 @SuppressWarnings("unused") 139 140 @Test(expected = IllegalArgumentException.class) 140 141 public void testNullParties() { … … 145 146 } 146 147 148 @SuppressWarnings("unused") 147 149 @Test(expected = IllegalArgumentException.class) 148 150 public void testNoParties() { … … 153 155 } 154 156 157 @SuppressWarnings("unused") 155 158 @Test(expected = IllegalArgumentException.class) 156 159 public void testNullProfiles() { … … 159 162 } 160 163 164 @SuppressWarnings("unused") 161 165 @Test(expected = IllegalArgumentException.class) 162 166 public void testInsufficientProfiles() { … … 167 171 } 168 172 173 @SuppressWarnings("unused") 169 174 @Test(expected = IllegalArgumentException.class) 170 175 public void testNullSessionSettings() { … … 175 180 } 176 181 182 @SuppressWarnings("unused") 177 183 @Test(expected = IllegalArgumentException.class) 178 184 public void testOnePartyPerSession() { … … 189 195 } 190 196 191 // @Test192 // public void makeCobTest() throws URISyntaxException {193 // // Check that the cob party gets profile without the query part194 // String profilebase = "ws://1.2.3.4:8080/profilesserver-a.b.c/websocket/get/someprofile";195 // String partybase = "http://131.180.202.213:8080/partiesserver/run/";196 // String query = "?a=2&partial=4";197 // PartyWithProfile partyprofile = AllPermutationsSettings.makeCob(198 // new PartyRef(partybase + AllPermutationsSettings.COB_PARTY),199 // new ProfileRef(profilebase + query));200 // assertEquals(profilebase,201 // partyprofile.getProfile().getURI().toString());202 // assertEquals(partybase + AllPermutationsSettings.COB_PARTY,203 // partyprofile.getParty().getPartyRef().getURI().toString());204 // }205 206 197 } -
pythonadapter/pom.xml
r21 r22 6 6 <groupId>geniusweb</groupId> 7 7 <artifactId>pythonadapter</artifactId> 8 <version>1.5. 0</version> <!-- must equal ${geniusweb.version} -->8 <version>1.5.1</version> <!-- must equal ${geniusweb.version} --> 9 9 <packaging>jar</packaging> 10 10 … … 17 17 <passwd>${env.ARTIFACTORY_PASS}</passwd> 18 18 <jackson-2-version>2.9.10</jackson-2-version> 19 <geniusweb.version>1.5. 0</geniusweb.version>19 <geniusweb.version>1.5.1</geniusweb.version> 20 20 </properties> 21 21 -
references/pom.xml
r21 r22 6 6 <groupId>geniusweb</groupId> 7 7 <artifactId>references</artifactId> 8 <version>1.5. 0</version> <!-- must equal ${geniusweb.version} -->8 <version>1.5.1</version> <!-- must equal ${geniusweb.version} --> 9 9 <packaging>jar</packaging> 10 10 … … 17 17 <passwd>${env.ARTIFACTORY_PASS}</passwd> 18 18 <jackson-2-version>2.9.10</jackson-2-version> 19 <geniusweb.version>1.5. 0</geniusweb.version>19 <geniusweb.version>1.5.1</geniusweb.version> 20 20 </properties> 21 21 -
simplerunner/pom.xml
r21 r22 6 6 <groupId>geniusweb</groupId> 7 7 <artifactId>simplerunner</artifactId> 8 <version>1.5. 0</version> <!-- must equal ${geniusweb.version} -->8 <version>1.5.1</version> <!-- must equal ${geniusweb.version} --> 9 9 <packaging>jar</packaging> 10 10 … … 17 17 <passwd>${env.ARTIFACTORY_PASS}</passwd> 18 18 <jackson-2-version>2.9.10</jackson-2-version> 19 <geniusweb.version>1.5. 0</geniusweb.version>19 <geniusweb.version>1.5.1</geniusweb.version> 20 20 </properties> 21 21 -
timeline/pom.xml
r21 r22 6 6 <groupId>geniusweb</groupId> 7 7 <artifactId>timeline</artifactId> 8 <version>1.5. 0</version> <!-- must equal ${geniusweb.version} -->8 <version>1.5.1</version> <!-- must equal ${geniusweb.version} --> 9 9 <packaging>jar</packaging> 10 10 … … 16 16 <passwd>${env.ARTIFACTORY_PASS}</passwd> 17 17 <jackson-2-version>2.9.10</jackson-2-version> 18 <geniusweb.version>1.5. 0</geniusweb.version>18 <geniusweb.version>1.5.1</geniusweb.version> 19 19 </properties> 20 20 -
timeline/src/test/java/geniusweb/deadline/DeadlineTest.java
r1 r22 14 14 import com.fasterxml.jackson.databind.ObjectMapper; 15 15 16 import geniusweb.deadline.Deadline;17 import geniusweb.deadline.DeadlineRounds;18 import geniusweb.deadline.DeadlineTime;19 16 import tudelft.utilities.junit.GeneralTests; 20 17 … … 71 68 } 72 69 70 @SuppressWarnings("unused") 73 71 @Test(expected = IllegalArgumentException.class) 74 72 public void testIllegalArg() { … … 76 74 } 77 75 76 @SuppressWarnings("unused") 78 77 @Test(expected = IllegalArgumentException.class) 79 78 public void testIllegalArg2() { -
voting/pom.xml
r21 r22 6 6 <groupId>geniusweb</groupId> 7 7 <artifactId>voting</artifactId> 8 <version>1.5. 0</version> <!-- must equal ${geniusweb.version} -->8 <version>1.5.1</version> <!-- must equal ${geniusweb.version} --> 9 9 <packaging>jar</packaging> 10 10 … … 17 17 <passwd>${env.ARTIFACTORY_PASS}</passwd> 18 18 <jackson-2-version>2.9.10</jackson-2-version> 19 <geniusweb.version>1.5. 0</geniusweb.version>19 <geniusweb.version>1.5.1</geniusweb.version> 20 20 </properties> 21 21 -
voting/src/main/java/geniusweb/voting/CollectedVotes.java
r21 r22 4 4 import java.util.HashMap; 5 5 import java.util.HashSet; 6 import java.util.List;7 6 import java.util.Map; 8 7 import java.util.Set; 9 import java.util.stream.Collectors;10 8 11 9 import geniusweb.actions.PartyId; … … 31 29 * 32 30 * @param votesMap the {@link Votes} done for each party 33 * @param power the power of each party. The power is an integer number. In34 * the voting process, the party powers add up to form the35 * total voting power. This set may contain parties that are36 * not in newmap.31 * @param power the power of each party. The power is an integer number. 32 * In the voting process, the party powers add up to form 33 * the total voting power. This set may contain parties that 34 * are not in newmap. 37 35 */ 38 36 public CollectedVotes(Map<PartyId, Votes> votesMap, … … 132 130 * @param votes a list of all votes for a particular bid. The parties that 133 131 * placed the votes are called 'voters' 134 * @return a subset of the voters for which holds (1) the min-power 135 * condition of all these voters is satisfied (2) the power of this 136 * subset of voters is maximal (no other satisfied set of voters 137 * with bigger power exists) maximum-power that placed votes with 138 * holding conditions.This algorithm works in quadratic time. 132 * @return a consensusgroup with maximum power, so there is no other 133 * consensus group that has more power (but there may be other 134 * groups with same power). 139 135 */ 140 136 protected Set<PartyId> getMaxPowerGroup(Set<Vote> votes) { … … 142 138 Integer maxpower = 0; 143 139 144 for (Vote vote : votes) { 145 int target = vote.getMinPower(); 146 147 // find parties that would join if we reach that power 148 Set<PartyId> group = votes.stream() 149 .filter(v -> target >= v.getMinPower()) 150 .map(v -> v.getActor()).collect(Collectors.toSet()); 151 // check what the group's power is 152 Integer groupPower = getTotalPower(group); 153 if (groupPower >= target && groupPower > maxpower) { 154 maxgroup = group; 155 maxpower = groupPower; 140 for (Set<PartyId> parties : getConsensusGroups(votes)) { 141 Integer power = getTotalPower(parties); 142 if (power > maxpower) { 143 maxgroup = parties; 144 maxpower = power; 156 145 } 157 146 } … … 169 158 * input size. 170 159 */ 171 protected Set<Set<PartyId>> getConsensusGroups( List<Vote> votes) {160 protected Set<Set<PartyId>> getConsensusGroups(Set<Vote> votes) { 172 161 Set<Set<PartyId>> groups = new HashSet<>(); 173 162 … … 177 166 for (ImmutableList<Vote> voteList : allVotePermutations) { 178 167 Set<PartyId> parties = getParties(voteList); 179 if (parties.size() >= 2 180 && getTotalPower(parties) >= getMinPower(voteList)) { 168 Integer totalpower = getTotalPower(parties); 169 if (parties.size() >= 2 && totalpower >= getMinPower(voteList) 170 && totalpower <= getMaxPower(voteList)) { 181 171 groups.add(parties); 182 172 } … … 210 200 } 211 201 return max; 202 } 203 204 /** 205 * 206 * @param votes a list of {@link Vote}s on one Bid. All parties must be 207 * known 208 * @return the maximum voting power needed for this group, so that all can 209 * accept. This is equal to the min of the vote.getMaxPower 210 */ 211 private Integer getMaxPower(ImmutableList<Vote> votes) { 212 int min = Integer.MAX_VALUE; 213 for (Vote vote : votes) { 214 min = Math.min(min, vote.getMaxPower()); 215 } 216 return min; 212 217 } 213 218 -
voting/src/test/java/geniusweb/voting/CollectedVotesTest.java
r21 r22 2 2 3 3 import static org.junit.Assert.assertEquals; 4 import static org.junit.Assert.assertTrue; 4 5 import static org.mockito.Mockito.mock; 5 6 … … 35 36 private final PartyId partyQ = new PartyId("partyQ"); 36 37 private final PartyId partyR = new PartyId("partyR"); 37 38 private final Vote votePA2 = new Vote(partyP, bidA, 2); 39 private final Vote voteQA2 = new Vote(partyQ, bidA, 2); 40 private final Vote voteQB3 = new Vote(partyQ, bidB, 3); 41 private final Vote voteQB2 = new Vote(partyQ, bidB, 2); 42 private final Vote voteRA2 = new Vote(partyR, bidA, 2); 43 private final Vote voteRA3 = new Vote(partyR, bidA, 3); 44 private final Vote voteRA4 = new Vote(partyR, bidA, 4); 45 private final Vote voteRB2 = new Vote(partyR, bidB, 2); 38 private final PartyId partyS = new PartyId("partyS"); 39 40 private final Vote votePA2 = new Vote(partyP, bidA, 2, 9); 41 private final Vote voteQA2 = new Vote(partyQ, bidA, 2, 9); 42 private final Vote voteQB3 = new Vote(partyQ, bidB, 3, 9); 43 private final Vote voteQB2 = new Vote(partyQ, bidB, 2, 9); 44 private final Vote voteRA2 = new Vote(partyR, bidA, 2, 9); 45 private final Vote voteRA3 = new Vote(partyR, bidA, 3, 9); 46 private final Vote voteRA4 = new Vote(partyR, bidA, 4, 9); 47 private final Vote voteRB2 = new Vote(partyR, bidB, 2, 9); 46 48 47 49 private Map<PartyId, Integer> allpowers = new HashMap<>(); … … 73 75 allpowers.put(partyQ, 1); 74 76 allpowers.put(partyR, 1); 77 allpowers.put(partyS, 1); 75 78 } 76 79 … … 156 159 allpowers); 157 160 158 Set<Set<PartyId>> consensus = cv 159 .getConsensusGroups(Arrays.asList(votePA2, voteQA2));161 Set<Set<PartyId>> consensus = cv.getConsensusGroups( 162 new HashSet<>(Arrays.asList(votePA2, voteQA2))); 160 163 // should give 1 solution: both parties join in. 161 164 System.out.println(consensus); … … 169 172 allpowers); 170 173 171 Set<Set<PartyId>> consensus = cv 172 .getConsensusGroups(Arrays.asList(votePA2, voteQA2, voteRA4));174 Set<Set<PartyId>> consensus = cv.getConsensusGroups( 175 new HashSet<>(Arrays.asList(votePA2, voteQA2, voteRA4))); 173 176 // should give 1 solution: P and Q join in. 4 is unreachable. 174 177 System.out.println(consensus); … … 182 185 allpowers); 183 186 184 Set<Set<PartyId>> consensus = cv 185 .getConsensusGroups(Arrays.asList(votePA2, voteQA2, voteRA2));187 Set<Set<PartyId>> consensus = cv.getConsensusGroups( 188 new HashSet<>(Arrays.asList(votePA2, voteQA2, voteRA2))); 186 189 // should give 4 solutions: P+Q, P+R, Q+R and P+Q+R 187 190 System.out.println(consensus); … … 200 203 allpowers); 201 204 202 Set<Set<PartyId>> consensus = cv 203 .getConsensusGroups(Arrays.asList(votePA2, voteQA2, voteRA4));205 Set<Set<PartyId>> consensus = cv.getConsensusGroups( 206 new HashSet<>(Arrays.asList(votePA2, voteQA2, voteRA4))); 204 207 // should give solutions P+Q and P+Q+R 205 208 System.out.println(consensus); … … 244 247 } 245 248 249 @Test 250 public void getConsensusGroupMaxPower() { 251 Vote P = new Vote(partyP, bidA, 2, 3); 252 Vote Q = new Vote(partyQ, bidA, 2, 3); 253 Vote R = new Vote(partyR, bidA, 2, 3); 254 Vote S = new Vote(partyS, bidA, 2, 3); 255 Map<PartyId, Votes> allvotes = new HashMap<>(); 256 allvotes.put(partyP, new Votes(partyP, Arrays.asList(P))); 257 allvotes.put(partyQ, new Votes(partyQ, Arrays.asList(Q))); 258 allvotes.put(partyR, new Votes(partyR, Arrays.asList(R))); 259 allvotes.put(partyS, new Votes(partyS, Arrays.asList(S))); 260 261 CollectedVotes cv = new CollectedVotes(allvotes, allpowers); 262 Set<Set<PartyId>> consensus = cv.getConsensusGroups( 263 new HashSet<Vote>(Arrays.asList(P, Q, R, S))); 264 System.out.println(consensus); 265 // check that all are size 2 or 3. 266 for (Set<PartyId> set : consensus) { 267 assertTrue(set.size() == 2 || set.size() == 3); 268 } 269 270 } 271 272 @Test 273 public void getConsensusGroupMaxPowerModifiedPartyPowers() { 274 // party R gets power 2. 275 Vote P = new Vote(partyP, bidA, 2, 3); 276 Vote Q = new Vote(partyQ, bidA, 2, 3); 277 Vote R = new Vote(partyR, bidA, 2, 3); 278 Map<PartyId, Votes> allvotes = new HashMap<>(); 279 allvotes.put(partyP, new Votes(partyP, Arrays.asList(P))); 280 allvotes.put(partyQ, new Votes(partyQ, Arrays.asList(Q))); 281 allvotes.put(partyR, new Votes(partyR, Arrays.asList(R))); 282 283 Map<PartyId, Integer> powers = new HashMap<PartyId, Integer>(); 284 powers.put(partyP, 1); 285 powers.put(partyQ, 1); 286 powers.put(partyR, 2); 287 288 CollectedVotes cv = new CollectedVotes(allvotes, powers); 289 Set<Set<PartyId>> consensus = cv 290 .getConsensusGroups(new HashSet<Vote>(Arrays.asList(P, Q, R))); 291 System.out.println(consensus); 292 // R has power 2 now. That means groups of size 3 are not posisble. 293 // check that all are size 2. 294 for (Set<PartyId> set : consensus) { 295 assertTrue(set.size() == 2); 296 } 297 298 } 299 246 300 } -
voting/src/test/java/geniusweb/voting/votingevaluators/LargestAgreementsLoopTest.java
r21 r22 74 74 @Test 75 75 public void testCollectVotes() { 76 Votes vote1AB = new Votes(party1, 77 Arrays.asList(new Vote(party1, a, 2), new Vote(party1, b, 2))); 78 Votes vote2AB = new Votes(party2, 79 Arrays.asList(new Vote(party2, a, 2), new Vote(party2, b, 2))); 80 Votes vote3C = new Votes(party3, Arrays.asList(new Vote(party3, c, 2))); 81 Votes vote4AC = new Votes(party4, 82 Arrays.asList(new Vote(party4, a, 2), new Vote(party4, c, 2))); 76 Votes vote1AB = new Votes(party1, Arrays 77 .asList(new Vote(party1, a, 2, 9), new Vote(party1, b, 2, 9))); 78 Votes vote2AB = new Votes(party2, Arrays 79 .asList(new Vote(party2, a, 2, 9), new Vote(party2, b, 2, 9))); 80 Votes vote3C = new Votes(party3, 81 Arrays.asList(new Vote(party3, c, 2, 9))); 82 Votes vote4AC = new Votes(party4, Arrays 83 .asList(new Vote(party4, a, 2, 9), new Vote(party4, c, 2, 9))); 83 84 // party 1,2,4 vote for A, party 1,2 vote for B, party 3,4 vote for C. 84 85 // the biggest vote is P,Q,S
Note:
See TracChangeset
for help on using the changeset viewer.