Changeset 22


Ignore:
Timestamp:
09/22/20 16:26:36 (4 years ago)
Author:
bart
Message:

Minor fixes

Files:
48 edited

Legend:

Unmodified
Added
Removed
  • bidspace/pom.xml

    r21 r22  
    66        <groupId>geniusweb</groupId>
    77        <artifactId>bidspace</artifactId>
    8         <version>1.5.0</version> <!-- must equal ${geniusweb.version} -->
     8        <version>1.5.1</version> <!-- must equal ${geniusweb.version} -->
    99        <packaging>jar</packaging>
    1010
     
    1616                <passwd>${env.ARTIFACTORY_PASS}</passwd>
    1717                <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>
    1919        </properties>
    2020
  • boa/pom.xml

    r21 r22  
    66        <groupId>geniusweb</groupId>
    77        <artifactId>boa</artifactId>
    8         <version>1.5.0</version> <!-- must equal ${geniusweb.version} -->
     8        <version>1.5.1</version> <!-- must equal ${geniusweb.version} -->
    99        <packaging>jar</packaging>
    1010
     
    1717                <passwd>${env.ARTIFACTORY_PASS}</passwd>
    1818                <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>
    2020        </properties>
    2121
  • collectparties.sh

    r21 r22  
    77rm -rf collectedparties
    88mkdir collectedparties
    9 VERSION=1.5.0
     9VERSION=1.5.1
    1010
    1111cp "exampleparties/anac2019/agentgg/target/agentgg-${VERSION}-jar-with-dependencies.jar" collectedparties
  • events/pom.xml

    r21 r22  
    66        <groupId>geniusweb</groupId>
    77        <artifactId>events</artifactId>
    8         <version>1.5.0</version> <!-- must equal ${geniusweb.version} -->
     8        <version>1.5.1</version> <!-- must equal ${geniusweb.version} -->
    99        <packaging>jar</packaging>
    1010
     
    1717                <passwd>${env.ARTIFACTORY_PASS}</passwd>
    1818                <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>
    2020        </properties>
    2121
  • events/src/main/java/geniusweb/actions/Vote.java

    r21 r22  
    1414public class Vote extends ActionWithBid {
    1515        private final Integer minPower;
     16        private final Integer maxPower;
    1617
    1718        /**
     
    1920         * @param bid      the bid that is voted on
    2021         * @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}
    2328         */
    2429        @JsonCreator
    2530        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) {
    2733                super(id, bid);
    2834                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) {
    3038                        throw new IllegalArgumentException(
    31                                         "Vote must have non-null bid and minVotes, and minVotes must be >=1");
     39                                        "Vote must have non-null bid and minVotes, and minPower must be >=1 and maxPower must be >=minPower");
    3240                }
    3341        }
     
    3543        /**
    3644         *
    37          * @return the minimum number of votes this bid must get in order for the
    38          *         vote to be valid.
     45         * @return the minimum power this bid must get in order for the vote to be
     46         *         valid.
    3947         */
    4048        public Integer getMinPower() {
     
    4250        }
    4351
     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
    4462        @Override
    4563        public String toString() {
    46                 return "Vote[" + getActor() + "," + getBid() + "," + minPower + "]";
     64                return "Vote[" + getActor() + "," + getBid() + "," + minPower + ","
     65                                + maxPower + "]";
    4766        }
    4867
     
    5170                final int prime = 31;
    5271                int result = super.hashCode();
     72                result = prime * result
     73                                + ((maxPower == null) ? 0 : maxPower.hashCode());
    5374                result = prime * result
    5475                                + ((minPower == null) ? 0 : minPower.hashCode());
     
    6586                        return false;
    6687                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;
    6793                if (minPower == null) {
    6894                        if (other.minPower != null)
  • events/src/test/java/actions/PartyIdTest.java

    r1 r22  
    2626        }
    2727
     28        @SuppressWarnings("unused")
    2829        @Test(expected = IllegalArgumentException.class)
    2930        public void testRestrictions() {
     
    3132        }
    3233
     34        @SuppressWarnings("unused")
    3335        @Test(expected = IllegalArgumentException.class)
    3436        public void testRestrictions2() {
     
    3638        }
    3739
     40        @SuppressWarnings("unused")
    3841        @Test(expected = IllegalArgumentException.class)
    3942        public void testRestrictions3() {
     
    4144        }
    4245
     46        @SuppressWarnings("unused")
    4347        @Test(expected = IllegalArgumentException.class)
    4448        public void testRestrictions4() {
     
    4650        }
    4751
     52        @SuppressWarnings("unused")
    4853        @Test(expected = IllegalArgumentException.class)
    4954        public void testRestrictions5() {
     
    5661        }
    5762
     63        @SuppressWarnings("unused")
    5864        @Test
    5965        public void testRestrictions6() {
     
    6167        }
    6268
     69        @SuppressWarnings("unused")
    6370        @Test
    6471        public void testRestrictions7() {
  • events/src/test/java/actions/PartyIdTest1.java

    r1 r22  
    4343        }
    4444
     45        @SuppressWarnings("unused")
    4546        @Test(expected = IllegalArgumentException.class)
    4647        public void smokeTest() throws URISyntaxException {
     
    4849        }
    4950
     51        @SuppressWarnings("unused")
    5052        @Test(expected = IllegalArgumentException.class)
    5153        public void nullTest() throws URISyntaxException {
  • events/src/test/java/actions/VoteTest.java

    r21 r22  
    66import java.util.Arrays;
    77import java.util.HashMap;
    8 import java.util.LinkedList;
    98import java.util.List;
    109import java.util.Map;
     
    3938        private final static Value VALUE2 = new NumberValue("10");
    4039        // 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}}";
    4241
    43         private static Vote vote1, vote1a, vote2, vote3, vote4;
     42        private static Vote vote1, vote1a, vote2, vote3, vote4, vote5;
    4443
    4544        static {
     
    4746                issuevalues.put(ISSUE2, VALUE2);
    4847                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);
    5150
    52                 vote2 = new Vote(id2, bid, 1);
     51                vote2 = new Vote(id2, bid, 1, 2);
    5352
    5453                // values swapped, so different issuevalues.
     
    5655                issuevaluesb.put(ISSUE2, VALUE2);
    5756                bidb = new Bid(issuevaluesb);
    58                 vote3 = new Vote(id, bidb, 1);
     57                vote3 = new Vote(id, bidb, 1, 2);
    5958
    60                 vote4 = new Vote(id, bid, 2);
     59                vote4 = new Vote(id, bid, 2, 2);
     60                vote5 = new Vote(id, bid, 1, 3);
    6161
    6262        }
     
    6464        @Override
    6565        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));
    7269        }
    7370
    7471        @Override
    7572        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.*");
    8078        }
    8179
  • events/src/test/java/actions/VotesTest.java

    r21 r22  
    2424public class VotesTest extends GeneralTests<Votes> {
    2525        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}}]}}";
    2727
    2828        private PartyId partyA = new PartyId("partyA");
     
    3030        private Bid bid1 = new Bid("is1", new DiscreteValue("val1")),
    3131                        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);
    3636
    3737        private Votes votes1 = new Votes(partyA, Arrays.asList(voteA1, voteA2));
     
    9595        @Test
    9696        public void isExtendingTestLessPower() {
    97                 Vote powervoteA1 = new Vote(partyA, bid1, 3);
     97                Vote powervoteA1 = new Vote(partyA, bid1, 3, 9);
    9898                Votes powerVotes = new Votes(partyA, Arrays.asList(powervoteA1));
    9999                assertFalse(powerVotes.isExtending(votes1));
     
    103103        @Test(expected = IllegalArgumentException.class)
    104104        public void testDuplicateBidsNotAllowed() {
    105                 Vote voteA1similar = new Vote(partyA, bid1, 3);
     105                Vote voteA1similar = new Vote(partyA, bid1, 3, 9);
    106106                Votes votes = new Votes(partyA, Arrays.asList(voteA1, voteA1similar));
    107107        }
  • exampleparties/anac2019/agentgg/pom.xml

    r21 r22  
    66        <groupId>geniusweb.exampleparties.anac2019</groupId>
    77        <artifactId>agentgg</artifactId>
    8         <version>1.5.0</version> <!-- must equal ${geniusweb.version} -->
     8        <version>1.5.1</version> <!-- must equal ${geniusweb.version} -->
    99        <packaging>jar</packaging>
    1010
     
    1717                <passwd>${env.ARTIFACTORY_PASS}</passwd>
    1818                <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>
    2020        </properties>
    2121
  • exampleparties/anac2019/winkyagent/pom.xml

    r21 r22  
    66        <groupId>geniusweb.exampleparties.anac2019</groupId>
    77        <artifactId>winkyagent</artifactId>
    8         <version>1.5.0</version> <!-- must equal ${geniusweb.version} -->
     8        <version>1.5.1</version> <!-- must equal ${geniusweb.version} -->
    99        <packaging>jar</packaging>
    1010
     
    1717                <passwd>${env.ARTIFACTORY_PASS}</passwd>
    1818                <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>
    2020        </properties>
    2121
  • exampleparties/boulware/pom.xml

    r21 r22  
    66        <groupId>geniusweb.exampleparties</groupId>
    77        <artifactId>boulware</artifactId>
    8         <version>1.5.0</version> <!-- must equal ${geniusweb.version} -->
     8        <version>1.5.1</version> <!-- must equal ${geniusweb.version} -->
    99        <packaging>jar</packaging>
    1010
     
    1717                <passwd>${env.ARTIFACTORY_PASS}</passwd>
    1818                <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>
    2020        </properties>
    2121
  • exampleparties/comparebids/pom.xml

    r21 r22  
    66        <groupId>geniusweb.exampleparties</groupId>
    77        <artifactId>comparebids</artifactId>
    8         <version>1.5.0</version> <!-- must equal ${geniusweb.version} -->
     8        <version>1.5.1</version> <!-- must equal ${geniusweb.version} -->
    99        <packaging>jar</packaging>
    1010
     
    1717                <passwd>${env.ARTIFACTORY_PASS}</passwd>
    1818                <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>
    2020        </properties>
    2121
  • exampleparties/conceder/pom.xml

    r21 r22  
    66        <groupId>geniusweb.exampleparties</groupId>
    77        <artifactId>conceder</artifactId>
    8         <version>1.5.0</version> <!-- must equal ${geniusweb.version} -->
     8        <version>1.5.1</version> <!-- must equal ${geniusweb.version} -->
    99        <packaging>jar</packaging>
    1010
     
    1717                <passwd>${env.ARTIFACTORY_PASS}</passwd>
    1818                <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>
    2020        </properties>
    2121
  • exampleparties/hardliner/pom.xml

    r21 r22  
    66        <groupId>geniusweb.exampleparties</groupId>
    77        <artifactId>hardliner</artifactId>
    8         <version>1.5.0</version> <!-- must equal ${geniusweb.version} -->
     8        <version>1.5.1</version> <!-- must equal ${geniusweb.version} -->
    99        <packaging>jar</packaging>
    1010
     
    1717                <passwd>${env.ARTIFACTORY_PASS}</passwd>
    1818                <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>
    2020        </properties>
    2121
  • exampleparties/humangui/pom.xml

    r21 r22  
    66        <groupId>geniusweb.exampleparties</groupId>
    77        <artifactId>humangui</artifactId>
    8         <version>1.5.0</version> <!-- must equal ${geniusweb.version} -->
     8        <version>1.5.1</version> <!-- must equal ${geniusweb.version} -->
    99        <packaging>jar</packaging>
    1010
     
    1717                <passwd>${env.ARTIFACTORY_PASS}</passwd>
    1818                <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>
    2020        </properties>
    2121
  • exampleparties/linear/pom.xml

    r21 r22  
    66        <groupId>geniusweb.exampleparties</groupId>
    77        <artifactId>linear</artifactId>
    8         <version>1.5.0</version> <!-- must equal ${geniusweb.version} -->
     8        <version>1.5.1</version> <!-- must equal ${geniusweb.version} -->
    99        <packaging>jar</packaging>
    1010
     
    1717                <passwd>${env.ARTIFACTORY_PASS}</passwd>
    1818                <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>
    2020        </properties>
    2121
  • exampleparties/randomparty/pom.xml

    r21 r22  
    66        <groupId>geniusweb.exampleparties</groupId>
    77        <artifactId>randomparty</artifactId>
    8         <version>1.5.0</version> <!-- must equal ${geniusweb.version} -->
     8        <version>1.5.1</version> <!-- must equal ${geniusweb.version} -->
    99        <packaging>jar</packaging>
    1010
     
    1717                <passwd>${env.ARTIFACTORY_PASS}</passwd>
    1818                <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>
    2020        </properties>
    2121
  • exampleparties/randomparty/src/main/java/geniusweb/exampleparties/randomparty/RandomParty.java

    r21 r22  
    3939 * A simple party that places random bids and accepts when it receives an offer
    4040 * 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>
    4454 */
    4555public class RandomParty extends DefaultParty {
     
    109119        @Override
    110120        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.";
    112123        }
    113124
     
    164175         */
    165176        private Votes vote(Voting voting) throws IOException {
    166                 Object val = settings.getParameters().get("minPowwer");
    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
    172183                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))
    174186                                .collect(Collectors.toList());
    175187                return new Votes(me, votes);
  • exampleparties/randompartypy/pom.xml

    r21 r22  
    66        <groupId>geniusweb.exampleparties</groupId>
    77        <artifactId>randompyparty</artifactId>
    8         <version>1.5.0</version> <!-- must equal ${geniusweb.version} -->
     8        <version>1.5.1</version> <!-- must equal ${geniusweb.version} -->
    99        <packaging>jar</packaging>
    1010
     
    1717                <passwd>${env.ARTIFACTORY_PASS}</passwd>
    1818                <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>
    2020        </properties>
    2121
  • exampleparties/simpleboa/pom.xml

    r21 r22  
    66        <groupId>geniusweb.exampleparties</groupId>
    77        <artifactId>simpleboaparty</artifactId>
    8         <version>1.5.0</version> <!-- must equal ${geniusweb.version} -->
     8        <version>1.5.1</version> <!-- must equal ${geniusweb.version} -->
    99        <packaging>jar</packaging>
    1010
     
    1717                <passwd>${env.ARTIFACTORY_PASS}</passwd>
    1818                <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>
    2020        </properties>
    2121
  • exampleparties/simpleshaop/pom.xml

    r21 r22  
    66        <groupId>geniusweb.exampleparties</groupId>
    77        <artifactId>simpleshaop</artifactId>
    8         <version>1.5.0</version> <!-- must equal ${geniusweb.version} -->
     8        <version>1.5.1</version> <!-- must equal ${geniusweb.version} -->
    99        <packaging>jar</packaging>
    1010
     
    1717                <passwd>${env.ARTIFACTORY_PASS}</passwd>
    1818                <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>
    2020        </properties>
    2121
  • exampleparties/timedependentparty/pom.xml

    r21 r22  
    66        <groupId>geniusweb.exampleparties</groupId>
    77        <artifactId>timedependentparty</artifactId>
    8         <version>1.5.0</version> <!-- must equal ${geniusweb.version} -->
     8        <version>1.5.1</version> <!-- must equal ${geniusweb.version} -->
    99        <packaging>jar</packaging>
    1010
     
    1717                <passwd>${env.ARTIFACTORY_PASS}</passwd>
    1818                <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>
    2020        </properties>
    2121
  • issuevalue/pom.xml

    r21 r22  
    66        <groupId>geniusweb</groupId>
    77        <artifactId>issuevalue</artifactId>
    8         <version>1.5.0</version> <!-- must equal ${geniusweb.version} -->
     8        <version>1.5.1</version> <!-- must equal ${geniusweb.version} -->
    99        <packaging>jar</packaging>
    1010
     
    1717                <passwd>${env.ARTIFACTORY_PASS}</passwd>
    1818                <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>
    2020        </properties>
    2121
  • issuevalue/src/test/java/geniusweb/issuevalue/BidTest.java

    r4 r22  
    8383        }
    8484
     85        @SuppressWarnings("unused")
    8586        @Test
    8687        public void bidTestSimple() {
     
    8990        }
    9091
     92        @SuppressWarnings("unused")
    9193        @Test(expected = IllegalArgumentException.class)
    9294        public void bidTestNull() {
     
    9698        }
    9799
     100        @SuppressWarnings("unused")
    98101        @Test
    99102        public void bidTestOkIssueValue() {
     
    148151        }
    149152
     153        @SuppressWarnings("unused")
    150154        @Test
    151155        public void smokeTestConstructor2() {
     
    153157        }
    154158
     159        @SuppressWarnings("unused")
    155160        @Test
    156161        public void smokeTestConstructor2b() {
     
    158163        }
    159164
     165        @SuppressWarnings("unused")
    160166        @Test(expected = NullPointerException.class)
    161167        public void smokeTestConstructor2Null1() {
     
    163169        }
    164170
     171        @SuppressWarnings("unused")
    165172        @Test(expected = NullPointerException.class)
    166173        public void smokeTestConstructor2Null2() {
  • issuevalue/src/test/java/geniusweb/issuevalue/NumberValueTest.java

    r1 r22  
    1717import com.fasterxml.jackson.databind.ObjectMapper;
    1818
    19 import geniusweb.issuevalue.NumberValue;
    20 import geniusweb.issuevalue.Value;
    2119import tudelft.utilities.junit.GeneralTests;
    2220
     
    8886        public void testDeserializeShorts() throws IOException {
    8987                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);
    9191                System.out.println(list);
    9292                System.out.println(list.get(0).getClass());
     
    9797        public void testDeserializeMix() throws IOException {
    9898                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]",
    100101                                ArrayList.class);
    101102                System.out.println(list);
  • opponentmodel/pom.xml

    r21 r22  
    66        <groupId>geniusweb</groupId>
    77        <artifactId>opponentmodel</artifactId>
    8         <version>1.5.0</version> <!-- must equal ${geniusweb.version} -->
     8        <version>1.5.1</version> <!-- must equal ${geniusweb.version} -->
    99        <packaging>jar</packaging>
    1010
     
    1717                <passwd>${env.ARTIFACTORY_PASS}</passwd>
    1818                <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>
    2020        </properties>
    2121
  • party/pom.xml

    r21 r22  
    66        <groupId>geniusweb</groupId>
    77        <artifactId>party</artifactId>
    8         <version>1.5.0</version> <!-- must equal ${geniusweb.version} -->
     8        <version>1.5.1</version> <!-- must equal ${geniusweb.version} -->
    99        <packaging>jar</packaging>
    1010
     
    1717                <passwd>${env.ARTIFACTORY_PASS}</passwd>
    1818                <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>
    2020        </properties>
    2121
  • party/src/test/java/geniusweb/party/inform/ActionDoneTest.java

    r21 r22  
    7676        }
    7777
     78        @SuppressWarnings("unused")
    7879        @Test
    7980        public void nullTest() throws URISyntaxException {
  • party/src/test/java/geniusweb/party/inform/OptInTest.java

    r21 r22  
    3030        private PartyId partyB = new PartyId("partyB");
    3131
    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);
    3535
    3636        private Votes votesA = new Votes(partyA, Arrays.asList(voteA1));
     
    4141        private final OptIn optIn2 = new OptIn(Arrays.asList(votesA));
    4242
    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}}]}}]}}";
    4444
    4545        @Override
  • profile/pom.xml

    r21 r22  
    66        <groupId>geniusweb</groupId>
    77        <artifactId>profile</artifactId>
    8         <version>1.5.0</version> <!-- must equal ${geniusweb.version} -->
     8        <version>1.5.1</version> <!-- must equal ${geniusweb.version} -->
    99        <packaging>jar</packaging>
    1010
     
    1717                <passwd>${env.ARTIFACTORY_PASS}</passwd>
    1818                <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>
    2020        </properties>
    2121
  • profile/src/test/java/geniusweb/profile/utilityspace/DiscreteValueSetUtilitiesTest.java

    r9 r22  
    8888        }
    8989
     90        @SuppressWarnings("unused")
    9091        @Test
    9192        public void smokeTest() {
     
    9495        }
    9596
     97        @SuppressWarnings("unused")
    9698        @Test(expected = IllegalArgumentException.class)
    9799        public void testTooLargeUtility() {
     
    102104        }
    103105
     106        @SuppressWarnings("unused")
    104107        @Test(expected = IllegalArgumentException.class)
    105108        public void testNegativeUtility() {
     
    110113        }
    111114
     115        @SuppressWarnings("unused")
    112116        @Test(expected = IllegalArgumentException.class)
    113117        public void testNullUtility() {
     
    118122        }
    119123
     124        @SuppressWarnings("unused")
    120125        @Test(expected = NullPointerException.class)
    121126        public void testNullValueUtils() {
     
    124129        }
    125130
     131        @SuppressWarnings("unused")
    126132        @Test(expected = NullPointerException.class)
    127133        public void testNullIssue() {
  • profileconnection/pom.xml

    r21 r22  
    66        <groupId>geniusweb</groupId>
    77        <artifactId>profileconnection</artifactId>
    8         <version>1.5.0</version> <!-- must equal ${geniusweb.version} -->
     8        <version>1.5.1</version> <!-- must equal ${geniusweb.version} -->
    99        <packaging>jar</packaging>
    1010
     
    1717                <passwd>${env.ARTIFACTORY_PASS}</passwd>
    1818                <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>
    2020        </properties>
    2121
  • protocol/pom.xml

    r21 r22  
    66        <groupId>geniusweb</groupId>
    77        <artifactId>protocol</artifactId>
    8         <version>1.5.0</version> <!-- must equal ${geniusweb.version} -->
     8        <version>1.5.1</version> <!-- must equal ${geniusweb.version} -->
    99        <packaging>jar</packaging>
    1010
     
    1717                <passwd>${env.ARTIFACTORY_PASS}</passwd>
    1818                <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>
    2020        </properties>
    2121
  • protocol/src/main/java/geniusweb/protocol/session/mopac/MOPAC.java

    r21 r22  
    145145                        ProtocolToPartyConnFactory connectionfactory) {
    146146                try {
    147                         System.out.println("starting MOPAC");
     147                        //System.out.println("starting MOPAC");
    148148                        // we're in Phase.INIT still
    149149                        connect(connectionfactory);
     
    314314                        final ProtocolToPartyConn partyconn, final Action action,
    315315                        long now) {
    316                 System.out.println("received " + action);
     316                //System.out.println("received " + action);
    317317                state = state.with(partyconn.getParty(), action, now);
    318318                checkEndPhase(System.currentTimeMillis());
     
    341341
    342342                state = state.nextPhase(now);
     343
    343344                startPhase(now);
    344345        }
     
    351352         */
    352353        private void broadcastNegotiators(Inform info) {
    353                 System.out.println("broadcasting " + info);
     354                //System.out.println("broadcasting " + info);
    354355                for (PartyId party : state.getPhase().getPartyStates()
    355356                                .getNegotiatingParties()) {
  • protocol/src/main/java/geniusweb/protocol/session/mopac/MOPACState.java

    r21 r22  
    1414import geniusweb.actions.PartyId;
    1515import geniusweb.inform.Agreements;
     16import geniusweb.inform.OptIn;
    1617import geniusweb.progress.Progress;
    1718import geniusweb.progress.ProgressRounds;
     
    2223import geniusweb.protocol.session.SessionState;
    2324import geniusweb.protocol.session.mopac.phase.OfferPhase;
     25import geniusweb.protocol.session.mopac.phase.OptInPhase;
    2426import geniusweb.protocol.session.mopac.phase.Phase;
    2527import geniusweb.protocol.session.saop.SAOPSettings;
     
    127129        /**
    128130         * @param now current time ms since 1970
    129          * @return the max possible duration in ms of this phase. Maybe negative if
    130          *         ew are past deadline
     131         * @return the max possible duration in ms of the NEXT phase. Maybe 0 or
     132         *         negative if past deadline.
    131133         */
    132134        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;
    133138                return Math.min(progress.getTerminationTime().getTime() - now,
    134139                                Phase.PHASE_MAXTIME);
     
    196201                Phase newphase = phase.next(now,
    197202                                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;
    205217        }
    206218
     
    217229         */
    218230        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
    220233                                && getAvailablePhaseTime(now) > Phase.PHASE_MINTIME;
     234                // System.out.println("newstate possible:" + a);
     235                return a;
    221236        }
    222237
  • protocol/src/test/java/geniusweb/protocol/session/amop/AMOPSettingsTest.java

    r21 r22  
    9797        }
    9898
     99        @SuppressWarnings("unused")
    99100        @Test(expected = IllegalArgumentException.class)
    100101        public void constructorNoDeadlineTest() {
  • protocol/src/test/java/geniusweb/protocol/session/amop/AMOPStateTest.java

    r21 r22  
    172172        }
    173173
     174        @SuppressWarnings("unused")
    174175        @Test
    175176        public void constructWithNullConnection() {
     
    375376        @Test
    376377        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)));
    384386                // party 1,2,4 vote for A, party 1,2 vote for B, party 3,4 vote for C.
    385387                // the biggest vote is P,Q,S
     
    407409        public void testNextPhase() {
    408410                // 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)));
    416419                // party 1,2,4 vote for A, party 1,2 vote for B, party 3,4 vote for C.
    417420                // the biggest vote is P,Q,S
  • protocol/src/test/java/geniusweb/protocol/tournament/allpermutations/AllPermutationsSettingsTest.java

    r18 r22  
    6868                profile2 = new ProfileRef("profile2");
    6969                profile3 = new ProfileRef("profile3");
    70                 ProfileList profiles1 = new ProfileList(Arrays.asList(profile1));
    71                 ProfileList profiles2 = new ProfileList(Arrays.asList(profile2));
    72                 ProfileList profiles3 = 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));
    7373
    7474                List<ProfileList> profiles = Arrays.asList(profiles1, profiles2,
     
    137137        }
    138138
     139        @SuppressWarnings("unused")
    139140        @Test(expected = IllegalArgumentException.class)
    140141        public void testNullParties() {
     
    145146        }
    146147
     148        @SuppressWarnings("unused")
    147149        @Test(expected = IllegalArgumentException.class)
    148150        public void testNoParties() {
     
    153155        }
    154156
     157        @SuppressWarnings("unused")
    155158        @Test(expected = IllegalArgumentException.class)
    156159        public void testNullProfiles() {
     
    159162        }
    160163
     164        @SuppressWarnings("unused")
    161165        @Test(expected = IllegalArgumentException.class)
    162166        public void testInsufficientProfiles() {
     
    167171        }
    168172
     173        @SuppressWarnings("unused")
    169174        @Test(expected = IllegalArgumentException.class)
    170175        public void testNullSessionSettings() {
     
    175180        }
    176181
     182        @SuppressWarnings("unused")
    177183        @Test(expected = IllegalArgumentException.class)
    178184        public void testOnePartyPerSession() {
     
    189195        }
    190196
    191 //      @Test
    192 //      public void makeCobTest() throws URISyntaxException {
    193 //              // Check that the cob party gets profile without the query part
    194 //              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 
    206197}
  • pythonadapter/pom.xml

    r21 r22  
    66        <groupId>geniusweb</groupId>
    77        <artifactId>pythonadapter</artifactId>
    8         <version>1.5.0</version> <!-- must equal ${geniusweb.version} -->
     8        <version>1.5.1</version> <!-- must equal ${geniusweb.version} -->
    99        <packaging>jar</packaging>
    1010
     
    1717                <passwd>${env.ARTIFACTORY_PASS}</passwd>
    1818                <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>
    2020        </properties>
    2121
  • references/pom.xml

    r21 r22  
    66        <groupId>geniusweb</groupId>
    77        <artifactId>references</artifactId>
    8         <version>1.5.0</version> <!-- must equal ${geniusweb.version} -->
     8        <version>1.5.1</version> <!-- must equal ${geniusweb.version} -->
    99        <packaging>jar</packaging>
    1010
     
    1717                <passwd>${env.ARTIFACTORY_PASS}</passwd>
    1818                <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>
    2020        </properties>
    2121
  • simplerunner/pom.xml

    r21 r22  
    66        <groupId>geniusweb</groupId>
    77        <artifactId>simplerunner</artifactId>
    8         <version>1.5.0</version> <!-- must equal ${geniusweb.version} -->
     8        <version>1.5.1</version> <!-- must equal ${geniusweb.version} -->
    99        <packaging>jar</packaging>
    1010
     
    1717                <passwd>${env.ARTIFACTORY_PASS}</passwd>
    1818                <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>
    2020        </properties>
    2121
  • timeline/pom.xml

    r21 r22  
    66        <groupId>geniusweb</groupId>
    77        <artifactId>timeline</artifactId>
    8         <version>1.5.0</version> <!-- must equal ${geniusweb.version} -->
     8        <version>1.5.1</version> <!-- must equal ${geniusweb.version} -->
    99        <packaging>jar</packaging>
    1010
     
    1616                <passwd>${env.ARTIFACTORY_PASS}</passwd>
    1717                <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>
    1919        </properties>
    2020
  • timeline/src/test/java/geniusweb/deadline/DeadlineTest.java

    r1 r22  
    1414import com.fasterxml.jackson.databind.ObjectMapper;
    1515
    16 import geniusweb.deadline.Deadline;
    17 import geniusweb.deadline.DeadlineRounds;
    18 import geniusweb.deadline.DeadlineTime;
    1916import tudelft.utilities.junit.GeneralTests;
    2017
     
    7168        }
    7269
     70        @SuppressWarnings("unused")
    7371        @Test(expected = IllegalArgumentException.class)
    7472        public void testIllegalArg() {
     
    7674        }
    7775
     76        @SuppressWarnings("unused")
    7877        @Test(expected = IllegalArgumentException.class)
    7978        public void testIllegalArg2() {
  • voting/pom.xml

    r21 r22  
    66        <groupId>geniusweb</groupId>
    77        <artifactId>voting</artifactId>
    8         <version>1.5.0</version> <!-- must equal ${geniusweb.version} -->
     8        <version>1.5.1</version> <!-- must equal ${geniusweb.version} -->
    99        <packaging>jar</packaging>
    1010
     
    1717                <passwd>${env.ARTIFACTORY_PASS}</passwd>
    1818                <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>
    2020        </properties>
    2121
  • voting/src/main/java/geniusweb/voting/CollectedVotes.java

    r21 r22  
    44import java.util.HashMap;
    55import java.util.HashSet;
    6 import java.util.List;
    76import java.util.Map;
    87import java.util.Set;
    9 import java.util.stream.Collectors;
    108
    119import geniusweb.actions.PartyId;
     
    3129         *
    3230         * @param votesMap the {@link Votes} done for each party
    33          * @param power  the power of each party. The power is an integer number. In
    34          *               the voting process, the party powers add up to form the
    35          *               total voting power. This set may contain parties that are
    36          *               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.
    3735         */
    3836        public CollectedVotes(Map<PartyId, Votes> votesMap,
     
    132130         * @param votes a list of all votes for a particular bid. The parties that
    133131         *              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).
    139135         */
    140136        protected Set<PartyId> getMaxPowerGroup(Set<Vote> votes) {
     
    142138                Integer maxpower = 0;
    143139
    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;
    156145                        }
    157146                }
     
    169158         *         input size.
    170159         */
    171         protected Set<Set<PartyId>> getConsensusGroups(List<Vote> votes) {
     160        protected Set<Set<PartyId>> getConsensusGroups(Set<Vote> votes) {
    172161                Set<Set<PartyId>> groups = new HashSet<>();
    173162
     
    177166                for (ImmutableList<Vote> voteList : allVotePermutations) {
    178167                        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)) {
    181171                                groups.add(parties);
    182172                        }
     
    210200                }
    211201                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;
    212217        }
    213218
  • voting/src/test/java/geniusweb/voting/CollectedVotesTest.java

    r21 r22  
    22
    33import static org.junit.Assert.assertEquals;
     4import static org.junit.Assert.assertTrue;
    45import static org.mockito.Mockito.mock;
    56
     
    3536        private final PartyId partyQ = new PartyId("partyQ");
    3637        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);
    4648
    4749        private Map<PartyId, Integer> allpowers = new HashMap<>();
     
    7375                allpowers.put(partyQ, 1);
    7476                allpowers.put(partyR, 1);
     77                allpowers.put(partyS, 1);
    7578        }
    7679
     
    156159                                allpowers);
    157160
    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)));
    160163                // should give 1 solution: both parties join in.
    161164                System.out.println(consensus);
     
    169172                                allpowers);
    170173
    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)));
    173176                // should give 1 solution: P and Q join in. 4 is unreachable.
    174177                System.out.println(consensus);
     
    182185                                allpowers);
    183186
    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)));
    186189                // should give 4 solutions: P+Q, P+R, Q+R and P+Q+R
    187190                System.out.println(consensus);
     
    200203                                allpowers);
    201204
    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)));
    204207                // should give solutions P+Q and P+Q+R
    205208                System.out.println(consensus);
     
    244247        }
    245248
     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
    246300}
  • voting/src/test/java/geniusweb/voting/votingevaluators/LargestAgreementsLoopTest.java

    r21 r22  
    7474        @Test
    7575        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)));
    8384                // party 1,2,4 vote for A, party 1,2 vote for B, party 3,4 vote for C.
    8485                // the biggest vote is P,Q,S
Note: See TracChangeset for help on using the changeset viewer.