Changes in / [3:1]


Ignore:
Files:
14 deleted
16 edited

Legend:

Unmodified
Added
Removed
  • /bidspace/pom.xml

    r3 r1  
    4242                        <groupId>tudelft.utilities</groupId>
    4343                        <artifactId>immutablelist</artifactId>
    44                         <version>1.0.1</version>
     44                        <version>1.0.0</version>
    4545                </dependency>
    4646
  • /exampleparties/pom.xml

    r3 r1  
    1818                <module>randomparty</module>
    1919                <module>randompartypy</module>
    20                 <module>timedependentparty</module>
    21                 <module>conceder</module>
    22                 <module>hardliner</module>
    23                 <module>boulware</module>
    24                 <module>linear</module>
    2520        </modules>
    2621</project>
  • /exampleparties/randomparty/pom.xml

    r3 r1  
    5454                        <groupId>tudelft.utilities</groupId>
    5555                        <artifactId>immutablelist</artifactId>
    56                         <version>1.0.1</version>
     56                        <version>1.0.0</version>
    5757                </dependency>
    5858
  • /exampleparties/randomparty/src/main/java/geniusweb/exampleparties/randomparty/RandomParty.java

    r3 r1  
    2323import geniusweb.party.inform.Settings;
    2424import geniusweb.party.inform.YourTurn;
    25 import geniusweb.profile.PartialOrdering;
    26 import geniusweb.profile.Profile;
    2725import geniusweb.profile.utilityspace.LinearAdditiveUtilitySpace;
    2826import geniusweb.profileconnection.ProfileConnectionFactory;
     
    5755                        if (info instanceof Settings) {
    5856                                Settings settings = (Settings) info;
    59                                 this.profileint = ProfileConnectionFactory.create(settings.getProfile().getURI(), getReporter());
     57                                this.profileint = ProfileConnectionFactory
     58                                                .create(settings.getProfile().getURI(), getReporter());
    6059                                this.me = settings.getID();
    6160                                this.progress = settings.getProgress();
     
    8180        public Capabilities getCapabilities() {
    8281                try {
    83                         return new Capabilities(new HashSet<>(Arrays.asList(new ProtocolRef(new URI("SAOP")))));
     82                        return new Capabilities(new HashSet<>(
     83                                        Arrays.asList(new ProtocolRef(new URI("SAOP")))));
    8484                } catch (URISyntaxException e) {
    85                         getReporter().log(Level.SEVERE, "Failed to create capabilities URI", e);
     85                        getReporter().log(Level.SEVERE, "Failed to create capabilities URI",
     86                                        e);
    8687                        return null;
    8788                }
     
    99100                } else {
    100101                        // for demo. Obviously full bids have higher util in general
    101                         AllPartialBidsList bidspace = new AllPartialBidsList(profileint.getProfile().getDomain());
     102                        AllPartialBidsList bidspace = new AllPartialBidsList(
     103                                        profileint.getProfile().getDomain());
    102104                        Bid bid = null;
    103105                        for (int attempt = 0; attempt < 20 && !isGood(bid); attempt++) {
     
    112114
    113115        private boolean isGood(Bid bid) {
    114                 if (bid == null)
    115                         return false;
    116                 Profile profile = profileint.getProfile();
    117                 if (profile instanceof LinearAdditiveUtilitySpace) {
    118                         return ((LinearAdditiveUtilitySpace) profile).getUtility(bid).doubleValue() > 0.6;
    119                 }
    120                 if (profile instanceof PartialOrdering) {
    121                         return ((PartialOrdering) profile).isPreferredOrEqual(bid, profile.getReservationBid());
    122                 }
    123                 throw new IllegalArgumentException("Can not handle profile type " + profile.getClass());
     116                return bid != null
     117                                && ((LinearAdditiveUtilitySpace) profileint.getProfile())
     118                                                .getUtility(bid).doubleValue() > 0.6;
    124119        }
    125120
  • /exampleparties/randompartypy/pom.xml

    r3 r1  
    4747                        <groupId>tudelft.utilities</groupId>
    4848                        <artifactId>immutablelist</artifactId>
    49                         <version>1.0.1</version>
     49                        <version>1.0.0</version>
    5050                </dependency>
    5151
  • /exampleparties/randompartypy/src/main/resources/RandomParty.py

    r3 r1  
    2323import geniusweb.party.DefaultParty as DefaultParty
    2424import geniusweb.profile.Profile as Profile
    25 import geniusweb.profile.PartialOrdering as PartialOrdering
    2625import geniusweb.profile.utilityspace.LinearAdditiveUtilitySpace as LinearAdditiveUtilitySpace
    2726import geniusweb.references.ProfileRef as ProfileRef
     
    3029import geniusweb.profileconnection.ProfileInterface as ProfileInterface
    3130import geniusweb.progress.ProgressRounds as ProgressRounds
    32 
    3331
    3432import com.fasterxml.jackson.databind.ObjectMapper as ObjectMapper
     
    9492
    9593        def _isGood(self, bid):
    96                 if bid == None:
    97                         return false
    98                 profile = self.profile.getProfile()
    99                 if isinstance(profile, LinearAdditiveUtilitySpace):
    100                         return profile.getUtility(bid).doubleValue() > 0.6;
    101                 if isinstance(profile, PartialOrdering):
    102                         return profile.isPreferredOrEqual(bid, profile.getReservationBid())
    103                 raise Exception("Can not handle this type of profile")
     94                return bid != None and self.profile.getProfile().getUtility(bid).doubleValue() > 0.6;
  • /issuevalue/pom.xml

    r3 r1  
    9292                        <groupId>tudelft.utilities</groupId>
    9393                        <artifactId>immutablelist</artifactId>
    94                         <version>1.0.1</version>
     94                        <version>1.0.0</version>
    9595                </dependency>
    9696
  • /issuevalue/src/test/java/geniusweb/issuevalue/DomainTest.java

    r3 r1  
    2121import com.fasterxml.jackson.databind.ObjectMapper;
    2222
     23import geniusweb.issuevalue.Bid;
     24import geniusweb.issuevalue.DiscreteValue;
     25import geniusweb.issuevalue.DiscreteValueSet;
     26import geniusweb.issuevalue.Domain;
     27import geniusweb.issuevalue.NumberValue;
     28import geniusweb.issuevalue.NumberValueSet;
     29import geniusweb.issuevalue.ValueSet;
    2330import tudelft.utilities.junit.GeneralTests;
    2431
     
    3138        private static final String ISSUE3 = "issue3";
    3239        private static final ObjectMapper jackson = new ObjectMapper();
    33         private static final String domainstring = "{\"name\":\"testdomain\",\"issuesValues\":{\"issue2\":{\"range\":[2,3,0.22]},\"issue1\":{\"values\":[\"i1v1\",\"i1v2\"]}}}";
     40        private static final String domainstring = "{\"name\":\"testdomain\",\"issuesValues\":{\"issue2\":{\"range\":[\"2\",\"3\",\"0.22\"]},\"issue1\":{\"values\":[\"i1v1\",\"i1v2\"]}}}";
    3441
    35         private static final String jobsstring = "{\"name\":\"jobs\"," + "\"issuesValues\":{"
    36                         + "\"lease car\":{\"values\":[\"yes\",\"no\"]}," + "\"permanent contract\":{\"values\":[\"yes\",\"no\"]},"
     42        private static final String jobsstring = "{\"name\":\"jobs\","
     43                        + "\"issuesValues\":{"
     44                        + "\"lease car\":{\"values\":[\"yes\",\"no\"]},"
     45                        + "\"permanent contract\":{\"values\":[\"yes\",\"no\"]},"
    3746                        + "\"career development opportunities\":{\"values\":[\"low\",\"medium\",\"high\"]},"
    3847                        + "\"fte\":{\"values\":[\"0.6\",\"0.8\",\"1.0\"]},"
     
    6473                Map<String, ValueSet> issues1 = new HashMap<>();
    6574                issues1.put(ISSUE1, values1);
    66                 issues1.put(ISSUE2, new NumberValueSet(BigDecimal.ONE, TWO, new BigDecimal("0.22")));
     75                issues1.put(ISSUE2, new NumberValueSet(BigDecimal.ONE, TWO,
     76                                new BigDecimal("0.22")));
    6777                domain3 = new Domain(DOMAINNAME, issues1);
    6878
     
    7181        @Override
    7282        public List<List<Domain>> getGeneralTestData() {
    73                 return Arrays.asList(Arrays.asList(domain, domain1), Arrays.asList(domain2), Arrays.asList(domain3));
     83                return Arrays.asList(Arrays.asList(domain, domain1),
     84                                Arrays.asList(domain2), Arrays.asList(domain3));
    7485        }
    7586
    7687        @Override
    7788        public List<String> getGeneralTestStrings() {
    78                 return Arrays.asList("Domain.*testdomain.*", "Domain.*testdomain1.*", "Domain.*testdomain.*");
     89                return Arrays.asList("Domain.*testdomain.*", "Domain.*testdomain1.*",
     90                                "Domain.*testdomain.*");
    7991        }
    8092
     
    97109                System.out.println(jobsstring);
    98110                Domain jobsdomain = jackson.readValue(jobsstring, Domain.class);
    99                 assertEquals(new HashSet<>(Arrays.asList("lease car", "permanent contract", "career development opportunities",
    100                                 "fte", "salary", "work from home")), jobsdomain.getIssues());
     111                assertEquals(new HashSet<>(Arrays.asList("lease car",
     112                                "permanent contract", "career development opportunities", "fte",
     113                                "salary", "work from home")), jobsdomain.getIssues());
    101114
    102115        }
     
    121134        public void testIsCompleteNoIssuesDefined() {
    122135                Bid bid = mock(Bid.class);
    123                 assertThat(domain.isComplete(bid), new PatternMatch("Issues in bid .* do not match issues in domain .*"));
     136                assertThat(domain.isComplete(bid), new PatternMatch(
     137                                "Issues in bid .* do not match issues in domain .*"));
    124138        }
    125139
     
    140154                // THREE is NOT a possible value in the NumberValueSet.
    141155                when(bid.getValue(ISSUE2)).thenReturn(new NumberValue(THREE));
    142                 assertThat(domain.isComplete(bid), new PatternMatch("bid issue issue2 has illegal value 3"));
     156                assertThat(domain.isComplete(bid),
     157                                new PatternMatch("bid issue issue2 has illegal value 3"));
    143158        }
    144159
     
    152167                // THREE is NOT a possible value in the NumberValueSet.
    153168                when(bid.getValue(ISSUE2)).thenReturn(new NumberValue(THREE));
    154                 assertThat(domain.isComplete(bid), new PatternMatch("Issues in bid .* do not match issues in domain .*"));
     169                assertThat(domain.isComplete(bid), new PatternMatch(
     170                                "Issues in bid .* do not match issues in domain .*"));
    155171        }
    156172
  • /issuevalue/src/test/java/geniusweb/issuevalue/NumberValueSetTest.java

    r3 r1  
    1616import com.fasterxml.jackson.databind.ObjectMapper;
    1717
     18import geniusweb.issuevalue.NumberValue;
     19import geniusweb.issuevalue.NumberValueSet;
     20import geniusweb.issuevalue.ValueSet;
    1821import tudelft.utilities.immutablelist.Range;
    1922
     
    3033                        new BigDecimal("0.1"));
    3134
    32         private final String asString = "{\"range\":[12.2,12.6,0.3]}";
     35        private final String asString = "{\"range\":[\"12.2\",\"12.6\",\"0.3\"]}";
    3336        private final static NumberValueSet bigset = new NumberValueSet(BigDecimal.ZERO, BigDecimal.TEN,
    3437                        new BigDecimal("0.00003"));
  • /profile/src/main/java/geniusweb/profile/Profile.java

    r3 r1  
    1616 */
    1717@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.WRAPPER_OBJECT)
    18 @JsonSubTypes({ @JsonSubTypes.Type(value = LinearAdditiveUtilitySpace.class),
    19                 @JsonSubTypes.Type(value = DefaultPartialOrdering.class) })
     18@JsonSubTypes({ @JsonSubTypes.Type(value = LinearAdditiveUtilitySpace.class) })
    2019public interface Profile {
    2120
     
    3332        /**
    3433         *
    35          * @return a (hypothetical) bid that is the best alternative to a non-agreement.
    36          *         Only bids that are {@link #isPreferredOrEqual(Bid, Bid)} should be
    37          *         accepted. If a negotiation does not reach an agreement, the party can
    38          *         get this offer somewhere else. This replaces the older notion of a
     34         * @return a (hypothetical) bid that is the best alternative to a
     35         *         non-agreement. Only bids that are
     36         *         {@link #isPreferredOrEqual(Bid, Bid)} should be accepted. If a
     37         *         negotiation does not reach an agreement, the party can get this
     38         *         offer somewhere else. This replaces the older notion of a
    3939         *         "reservation value" and is more general. If null, there is no
    4040         *         reservation bid and any agreement is better than no agreement.
  • /profile/src/main/java/geniusweb/profile/utilityspace/NumberValueSetUtilities.java

    r3 r1  
    66import com.fasterxml.jackson.annotation.JsonAutoDetect;
    77import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility;
    8 import com.fasterxml.jackson.annotation.JsonCreator;
    9 import com.fasterxml.jackson.annotation.JsonProperty;
    10 import com.fasterxml.jackson.annotation.JsonTypeName;
    118
    129import geniusweb.issuevalue.NumberValue;
     
    1411import geniusweb.issuevalue.Value;
    1512import geniusweb.issuevalue.ValueSet;
     13
     14import com.fasterxml.jackson.annotation.JsonCreator;
     15import com.fasterxml.jackson.annotation.JsonProperty;
     16import com.fasterxml.jackson.annotation.JsonTypeName;
     17
    1618import tudelft.utilities.immutablelist.Range;
    1719
     
    98100                }
    99101                if (numvalset.getRange().getHigh().compareTo(highValue) != 0) {
    100                         return "the utilities are specified up to " + highValue
    101                                         + " but the valueset ends at "
     102                        return "the utilities are specified down to " + highValue
     103                                        + " but the valueset starts at "
    102104                                        + numvalset.getRange().getHigh();
    103105                }
  • /profile/src/test/java/geniusweb/profile/utilityspace/DiscreteValueSetUtilitiesTest.java

    r3 r1  
    11package geniusweb.profile.utilityspace;
    2 
    3 import static org.junit.Assert.assertEquals;
    42
    53import java.math.BigDecimal;
     
    1210
    1311import geniusweb.issuevalue.DiscreteValue;
    14 import geniusweb.issuevalue.DiscreteValueSet;
    15 import geniusweb.issuevalue.NumberValue;
    16 import geniusweb.issuevalue.NumberValueSet;
    17 import geniusweb.issuevalue.ValueSet;
     12import geniusweb.profile.utilityspace.DiscreteValueSetUtilities;
    1813import tudelft.utilities.junit.GeneralTests;
    1914
    20 public class DiscreteValueSetUtilitiesTest
    21                 extends GeneralTests<DiscreteValueSetUtilities> {
     15public class DiscreteValueSetUtilitiesTest extends GeneralTests<DiscreteValueSetUtilities> {
    2216
    2317        private final static DiscreteValue vala = new DiscreteValue("a");
    2418        private final static DiscreteValue vala1 = new DiscreteValue("a");
    2519        private final static DiscreteValue valb = new DiscreteValue("b");
    26         private final static NumberValue valn = new NumberValue("99");
    2720
    2821        private final static BigDecimal util = new BigDecimal("0.14");
     
    3023        private final static BigDecimal utilb = new BigDecimal("0.37");
    3124
    32         private final static BigDecimal badutil = new BigDecimal("1.37");
    33         private final static BigDecimal badutil2 = new BigDecimal("-0.37");
    34 
    35         private final static DiscreteValueSetUtilities utils, utils1, utilsb,
    36                         utils1b, utilsc1, utilsc2;
     25        private final static DiscreteValueSetUtilities utils, utils1, utilsb, utils1b, utilsc1, utilsc2;
    3726
    3827        static {
     
    6756        @Override
    6857        public List<List<DiscreteValueSetUtilities>> getGeneralTestData() {
    69                 return Arrays.asList(Arrays.asList(utils, utils1),
    70                                 Arrays.asList(utilsb), Arrays.asList(utils1b),
     58                return Arrays.asList(Arrays.asList(utils, utils1), Arrays.asList(utilsb), Arrays.asList(utils1b),
    7159                                Arrays.asList(utilsc1, utilsc2));
    7260        }
     
    7462        @Override
    7563        public List<String> getGeneralTestStrings() {
    76                 return Arrays.asList("ValueSetUtilities\\{\"a\"=0.14\\}",
    77                                 "ValueSetUtilities\\{\"b\"=0.37\\}",
    78                                 "ValueSetUtilities\\{\"a\"=0.37\\}",
    79                                 "ValueSetUtilities\\{\"a\"=0.14, \"b\"=0.37\\}");
     64                return Arrays.asList("ValueSetUtilities\\{\"a\"=0.14\\}", "ValueSetUtilities\\{\"b\"=0.37\\}",
     65                                "ValueSetUtilities\\{\"a\"=0.37\\}", "ValueSetUtilities\\{\"a\"=0.14, \"b\"=0.37\\}");
    8066        }
    8167
     
    8672        }
    8773
    88         @Test(expected = IllegalArgumentException.class)
    89         public void testTooLargeUtility() {
    90                 Map<DiscreteValue, BigDecimal> valueUtils = new HashMap<>();
    91                 valueUtils.put(vala, util);
    92                 valueUtils.put(valb, badutil);
    93                 new DiscreteValueSetUtilities(valueUtils);
    94         }
    95 
    96         @Test(expected = IllegalArgumentException.class)
    97         public void testNegativeUtility() {
    98                 Map<DiscreteValue, BigDecimal> valueUtils = new HashMap<>();
    99                 valueUtils.put(vala, util);
    100                 valueUtils.put(valb, badutil2);
    101                 new DiscreteValueSetUtilities(valueUtils);
    102         }
    103 
    104         @Test(expected = IllegalArgumentException.class)
    105         public void testNullUtility() {
    106                 Map<DiscreteValue, BigDecimal> valueUtils = new HashMap<>();
    107                 valueUtils.put(vala, null);
    108                 valueUtils.put(valb, util);
    109                 new DiscreteValueSetUtilities(valueUtils);
    110         }
    111 
    112         @Test(expected = NullPointerException.class)
    113         public void testNullValueUtils() {
    114                 new DiscreteValueSetUtilities(null);
    115 
    116         }
    117 
    118         @Test(expected = NullPointerException.class)
    119         public void testNullIssue() {
    120                 Map<DiscreteValue, BigDecimal> valueUtils = new HashMap<>();
    121                 valueUtils.put(vala, util);
    122                 valueUtils.put(null, utilb);
    123                 new DiscreteValueSetUtilities(valueUtils);
    124         }
    125 
    126         @Test
    127         public void testGetUtility() {
    128                 Map<DiscreteValue, BigDecimal> valueUtils = new HashMap<>();
    129                 valueUtils.put(vala, util);
    130                 valueUtils.put(valb, utilb);
    131                 DiscreteValueSetUtilities utilset = new DiscreteValueSetUtilities(
    132                                 valueUtils);
    133                 assertEquals(util, utilset.getUtility(vala));
    134                 assertEquals(utilb, utilset.getUtility(valb));
    135                 assertEquals(BigDecimal.ZERO,
    136                                 utilset.getUtility(new DiscreteValue("unknownIssue")));
    137 
    138         }
    139 
    140         @Test
    141         public void testIsFitting() {
    142                 ValueSet valueset = new DiscreteValueSet(Arrays.asList(vala, valb));
    143 
    144                 Map<DiscreteValue, BigDecimal> valueUtils = new HashMap<>();
    145                 valueUtils.put(vala, util);
    146                 DiscreteValueSetUtilities utilset = new DiscreteValueSetUtilities(
    147                                 valueUtils);
    148 
    149                 assertEquals(
    150                                 "The values in the set DiscreteValueSet[\"a\", \"b\"] do not match the values mapped to utilities [\"a\"]",
    151                                 utilset.isFitting(valueset));
    152 
    153                 valueUtils.put(valb, utilb);
    154                 utilset = new DiscreteValueSetUtilities(valueUtils);
    155                 assertEquals(null, utilset.isFitting(valueset));
    156 
    157                 valueUtils.put(new DiscreteValue("unknownIssue"), util1);
    158                 utilset = new DiscreteValueSetUtilities(valueUtils);
    159                 assertEquals(
    160                                 "The values in the set DiscreteValueSet[\"a\", \"b\"] do not match the values mapped to utilities [\"a\", \"b\", \"unknownIssue\"]",
    161                                 utilset.isFitting(valueset));
    162 
    163         }
    164 
    165         @Test
    166         public void testIsFittingWrongType() {
    167                 ValueSet valueset = new NumberValueSet(BigDecimal.ZERO, BigDecimal.ONE,
    168                                 new BigDecimal("0.3"));
    169 
    170                 Map<DiscreteValue, BigDecimal> valueUtils = new HashMap<>();
    171                 valueUtils.put(vala, util);
    172                 valueUtils.put(valb, utilb);
    173                 DiscreteValueSetUtilities utilset = new DiscreteValueSetUtilities(
    174                                 valueUtils);
    175 
    176                 assertEquals(
    177                                 "The utilities are for a discrete valueset but the given values are numberValueSet[0,1,0.3]",
    178                                 utilset.isFitting(valueset));
    179 
    180         }
    18174}
  • /profile/src/test/java/geniusweb/profile/utilityspace/NumberValueSetUtilTest.java

    r3 r1  
    99import org.junit.Test;
    1010
    11 import geniusweb.issuevalue.DiscreteValue;
    12 import geniusweb.issuevalue.DiscreteValueSet;
    1311import geniusweb.issuevalue.NumberValue;
    14 import geniusweb.issuevalue.NumberValueSet;
    15 import geniusweb.issuevalue.ValueSet;
    16 import tudelft.utilities.immutablelist.Range;
     12import geniusweb.profile.utilityspace.NumberValueSetUtilities;
    1713import tudelft.utilities.junit.GeneralTests;
    1814
    19 public class NumberValueSetUtilTest
    20                 extends GeneralTests<NumberValueSetUtilities> {
     15public class NumberValueSetUtilTest extends GeneralTests<NumberValueSetUtilities> {
    2116
    2217        private static final BigDecimal lowval1 = new BigDecimal("12.5");
     
    2621        private static final BigDecimal highvalb = new BigDecimal("18.4");
    2722        private static final BigDecimal highutil = new BigDecimal("0.9");
    28         private static final NumberValueSetUtilities valueset1 = new NumberValueSetUtilities(
    29                         lowval1, low1util, highval, highutil);
    30         private static final NumberValueSetUtilities valueset1b = new NumberValueSetUtilities(
    31                         lowval1, low1util, highval, highutil);
    32         private static final NumberValueSetUtilities valueset2 = new NumberValueSetUtilities(
    33                         lowval1, low1utilb, highval, highutil);
    34         private static final NumberValueSetUtilities valueset3 = new NumberValueSetUtilities(
    35                         lowval1, low1util, highvalb, highutil);
    36         private static final BigDecimal ZERO_1 = new BigDecimal("0.1");
     23        private static final NumberValueSetUtilities valueset1 = new NumberValueSetUtilities(lowval1, low1util, highval,
     24                        highutil);
     25        private static final NumberValueSetUtilities valueset1b = new NumberValueSetUtilities(lowval1, low1util, highval,
     26                        highutil);
     27        private static final NumberValueSetUtilities valueset2 = new NumberValueSetUtilities(lowval1, low1utilb, highval,
     28                        highutil);
     29        private static final NumberValueSetUtilities valueset3 = new NumberValueSetUtilities(lowval1, low1util, highvalb,
     30                        highutil);
    3731
    3832        @Override
    3933        public List<List<NumberValueSetUtilities>> getGeneralTestData() {
    40                 return Arrays.asList(Arrays.asList(valueset1, valueset1b),
    41                                 Arrays.asList(valueset2), Arrays.asList(valueset3));
     34                return Arrays.asList(Arrays.asList(valueset1, valueset1b), Arrays.asList(valueset2), Arrays.asList(valueset3));
    4235        }
    4336
    4437        @Override
    4538        public List<String> getGeneralTestStrings() {
    46                 return Arrays.asList("NumberValUtility\\(12.5->0.5,18.5->0.9\\)",
    47                                 "NumberValUtility\\(12.5->0.6,18.5->0.9\\)",
     39                return Arrays.asList("NumberValUtility\\(12.5->0.5,18.5->0.9\\)", "NumberValUtility\\(12.5->0.6,18.5->0.9\\)",
    4840                                "NumberValUtility\\(12.5->0.5,18.4->0.9\\)");
    4941        }
     
    5749        public void utilAscentingTest() {
    5850                NumberValueSetUtilities utils = valueset1;
    59                 assertEquals(0,
    60                                 low1util.compareTo(utils.getUtility(new NumberValue(lowval1))));
     51                assertEquals(0, low1util.compareTo(utils.getUtility(new NumberValue(lowval1))));
    6152        }
    6253
    6354        @Test
    6455        public void utilDescendingTest() {
    65                 NumberValueSetUtilities utils = new NumberValueSetUtilities(lowval1,
    66                                 highutil, highval, low1util);
    67                 assertEquals(0,
    68                                 highutil.compareTo(utils.getUtility(new NumberValue(lowval1))));
     56                NumberValueSetUtilities utils = new NumberValueSetUtilities(lowval1, highutil, highval, low1util);
     57                assertEquals(0, highutil.compareTo(utils.getUtility(new NumberValue(lowval1))));
    6958        }
    7059
    7160        @Test(expected = IllegalArgumentException.class)
    7261        public void reverserangetest() {
    73                 NumberValueSetUtilities utils = new NumberValueSetUtilities(highval,
    74                                 low1util, highval, highutil);
    75         }
    76 
    77         @Test(expected = NullPointerException.class)
    78         public void testNullHigh() {
    79                 NumberValueSetUtilities utils = new NumberValueSetUtilities(lowval1,
    80                                 low1util, null, highutil);
    81         }
    82 
    83         @Test(expected = NullPointerException.class)
    84         public void testNullHighUtil() {
    85                 NumberValueSetUtilities utils = new NumberValueSetUtilities(lowval1,
    86                                 low1util, highval, null);
    87         }
    88 
    89         @Test(expected = NullPointerException.class)
    90         public void testNullLow() {
    91                 NumberValueSetUtilities utils = new NumberValueSetUtilities(null,
    92                                 low1util, highval, highutil);
    93         }
    94 
    95         @Test(expected = NullPointerException.class)
    96         public void testNullLowUtil() {
    97                 NumberValueSetUtilities utils = new NumberValueSetUtilities(lowval1,
    98                                 null, highval, highutil);
    99         }
    100 
    101         @Test(expected = IllegalArgumentException.class)
    102         public void testLowUtilNegative() {
    103                 NumberValueSetUtilities utils = new NumberValueSetUtilities(lowval1,
    104                                 new BigDecimal("-0.2"), highval, highutil);
    105         }
    106 
    107         @Test(expected = IllegalArgumentException.class)
    108         public void testHighUtilNegative() {
    109                 NumberValueSetUtilities utils = new NumberValueSetUtilities(lowval1,
    110                                 low1util, highval, new BigDecimal("-0.000003"));
    111         }
    112 
    113         @Test
    114         public void getUtilTest() {
    115                 NumberValueSetUtilities utils = new NumberValueSetUtilities(lowval1,
    116                                 low1util, highval, highutil);
    117                 assertEquals(0,
    118                                 highutil.compareTo(utils.getUtility(new NumberValue(highval))));
    119                 assertEquals(0,
    120                                 low1util.compareTo(utils.getUtility(new NumberValue(lowval1))));
    121                 // linear interpolated , check center
    122                 BigDecimal middleutil = low1util.add(highutil)
    123                                 .divide(new BigDecimal("2"));
    124                 NumberValue middleval = new NumberValue(
    125                                 lowval1.add(highval).divide(new BigDecimal("2")));
    126                 assertEquals(0, middleutil.compareTo(utils.getUtility(middleval)));
    127 
    128         }
    129 
    130         @Test
    131         public void testIsNotFittingRange() {
    132                 ValueSet valueset = new NumberValueSet(
    133                                 new Range(low1util, highutil, new BigDecimal("0.02")));
    134                 ValueSetUtilities utilset = new NumberValueSetUtilities(lowval1,
    135                                 low1util, highval, highutil);
    136                 assertEquals(
    137                                 "the utilities are specified down to 12.5 but the valueset starts at 0.5",
    138                                 utilset.isFitting(valueset));
    139         }
    140 
    141         @Test
    142         public void testTopOfRangeTooLarge() {
    143                 ValueSet valueset = new NumberValueSet(
    144                                 new Range(lowval1, highval.subtract(ZERO_1), ZERO_1));
    145                 ValueSetUtilities utilset = new NumberValueSetUtilities(lowval1,
    146                                 low1util, highval, highutil);
    147                 assertEquals(
    148                                 "the utilities are specified up to 18.5 but the valueset ends at 18.4",
    149                                 utilset.isFitting(valueset));
    150         }
    151 
    152         @Test
    153         public void testIsFitting() {
    154                 ValueSet valueset = new NumberValueSet(
    155                                 new Range(lowval1, highval, BigDecimal.ONE));
    156                 ValueSetUtilities utilset = new NumberValueSetUtilities(lowval1,
    157                                 low1util, highval, highutil);
    158                 assertEquals(null, utilset.isFitting(valueset));
    159         }
    160 
    161         @Test
    162         public void testIsFittingWrongType() {
    163                 DiscreteValue vala = new DiscreteValue("a");
    164                 DiscreteValue valb = new DiscreteValue("b");
    165                 ValueSet valueset = new DiscreteValueSet(Arrays.asList(vala, valb));
    166 
    167                 NumberValueSetUtilities utilset = new NumberValueSetUtilities(lowval1,
    168                                 low1util, highval, highutil);
    169                 assertEquals(
    170                                 "The utilities are for a number valueset but the given values are DiscreteValueSet[\"a\", \"b\"]",
    171                                 utilset.isFitting(valueset));
    172 
     62                NumberValueSetUtilities utils = new NumberValueSetUtilities(highval, highutil, lowval1, low1util);
    17363        }
    17464
  • /profileconnection/src/main/java/geniusweb/profileconnection/FileProfileConnector.java

    r3 r1  
    1010
    1111import geniusweb.profile.Profile;
     12import geniusweb.profile.utilityspace.LinearAdditiveUtilitySpace;
    1213
    1314/**
     
    1617public class FileProfileConnector implements ProfileInterface {
    1718        private final static ObjectMapper jackson = new ObjectMapper();
    18         private final Profile profile;
     19        private final LinearAdditiveUtilitySpace profile;
    1920
    2021        /**
     
    2526        public FileProfileConnector(String filename) throws IOException {
    2627                Path path = new File(filename).toPath();
    27                 String serialized = new String(Files.readAllBytes(path), StandardCharsets.UTF_8);
    28                 profile = jackson.readValue(serialized, Profile.class);
     28                String serialized = new String(Files.readAllBytes(path),
     29                                StandardCharsets.UTF_8);
     30                profile = (LinearAdditiveUtilitySpace) jackson.readValue(serialized,
     31                                Profile.class);
    2932        }
    3033
    3134        @Override
    32         public Profile getProfile() {
     35        public LinearAdditiveUtilitySpace getProfile() {
    3336                return profile;
    3437        }
  • /protocol/pom.xml

    r3 r1  
    5656                        <groupId>tudelft.utilities</groupId>
    5757                        <artifactId>immutablelist</artifactId>
    58                         <version>1.0.1</version>
     58                        <version>1.0.0</version>
    5959                </dependency>
    6060                <dependency>
  • /simplerunner/src/test/java/geniusweb/simplerunner/SessionRunnerE2ETest.java

    r3 r1  
    55import java.nio.file.Files;
    66import java.nio.file.Paths;
    7 import java.util.Arrays;
    8 import java.util.Collection;
    97
    108import org.junit.Before;
    119import org.junit.Test;
    12 import org.junit.runner.RunWith;
    13 import org.junit.runners.Parameterized;
    14 import org.junit.runners.Parameterized.Parameters;
    1510
    1611import com.fasterxml.jackson.databind.ObjectMapper;
    1712
    1813import geniusweb.protocol.session.SessionSettings;
     14import geniusweb.simplerunner.ClassPathConnectionFactory;
     15import geniusweb.simplerunner.NegoRunner;
    1916import tudelft.utilities.logging.ReportToLogger;
    2017import tudelft.utilities.logging.Reporter;
     
    2522 * this module.
    2623 */
    27 @RunWith(Parameterized.class)
    2824public class SessionRunnerE2ETest {
     25        private static final String SESSION_SETTINGS = "src/test/resources/settings.json";
    2926        private final ObjectMapper jackson = new ObjectMapper();
    3027        private NegoRunner runner;
    3128        private Reporter logger = new ReportToLogger("test");
    32         private String filename;
    33 
    34         @Parameters
    35         public static Collection<Object[]> data() {
    36                 return Arrays.asList(
    37                                 new Object[][] { { "src/test/resources/settings.json" }, { "src/test/resources/settings2.json" } });
    38         }
    39 
    40         public SessionRunnerE2ETest(String file) {
    41                 this.filename = file;
    42         }
    4329
    4430        @Before
    4531        public void before() throws IOException {
    46                 String serialized = new String(Files.readAllBytes(Paths.get(filename)), StandardCharsets.UTF_8);
    47                 SessionSettings settings = jackson.readValue(serialized, SessionSettings.class);
     32                String serialized = new String(
     33                                Files.readAllBytes(Paths.get(SESSION_SETTINGS)),
     34                                StandardCharsets.UTF_8);
     35                SessionSettings settings = jackson.readValue(serialized,
     36                                SessionSettings.class);
    4837
    49                 runner = new NegoRunner(settings, new ClassPathConnectionFactory(), logger);
     38                runner = new NegoRunner(settings, new ClassPathConnectionFactory(),
     39                                logger);
    5040
    5141        }
     
    6252        @Test
    6353        public void runTestMainFunction() throws IOException {
    64                 NegoRunner.main(new String[] { filename });
     54                NegoRunner.main(new String[] { SESSION_SETTINGS });
    6555        }
    6656}
Note: See TracChangeset for help on using the changeset viewer.