Changeset 2


Ignore:
Timestamp:
08/28/19 11:35:52 (5 years ago)
Author:
bart
Message:

Added new parties : linear, hardliner, conceder, boulware

Files:
66 added
13 edited

Legend:

Unmodified
Added
Removed
  • bidspace/pom.xml

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

    r1 r2  
    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>
    2025        </modules>
    2126</project>
  • exampleparties/randomparty/pom.xml

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

    r1 r2  
    2323import geniusweb.party.inform.Settings;
    2424import geniusweb.party.inform.YourTurn;
     25import geniusweb.profile.PartialOrdering;
     26import geniusweb.profile.Profile;
    2527import geniusweb.profile.utilityspace.LinearAdditiveUtilitySpace;
    2628import geniusweb.profileconnection.ProfileConnectionFactory;
     
    5557                        if (info instanceof Settings) {
    5658                                Settings settings = (Settings) info;
    57                                 this.profileint = ProfileConnectionFactory
    58                                                 .create(settings.getProfile().getURI(), getReporter());
     59                                this.profileint = ProfileConnectionFactory.create(settings.getProfile().getURI(), getReporter());
    5960                                this.me = settings.getID();
    6061                                this.progress = settings.getProgress();
     
    8081        public Capabilities getCapabilities() {
    8182                try {
    82                         return new Capabilities(new HashSet<>(
    83                                         Arrays.asList(new ProtocolRef(new URI("SAOP")))));
     83                        return new Capabilities(new HashSet<>(Arrays.asList(new ProtocolRef(new URI("SAOP")))));
    8484                } catch (URISyntaxException e) {
    85                         getReporter().log(Level.SEVERE, "Failed to create capabilities URI",
    86                                         e);
     85                        getReporter().log(Level.SEVERE, "Failed to create capabilities URI", e);
    8786                        return null;
    8887                }
     
    10099                } else {
    101100                        // for demo. Obviously full bids have higher util in general
    102                         AllPartialBidsList bidspace = new AllPartialBidsList(
    103                                         profileint.getProfile().getDomain());
     101                        AllPartialBidsList bidspace = new AllPartialBidsList(profileint.getProfile().getDomain());
    104102                        Bid bid = null;
    105103                        for (int attempt = 0; attempt < 20 && !isGood(bid); attempt++) {
     
    114112
    115113        private boolean isGood(Bid bid) {
    116                 return bid != null
    117                                 && ((LinearAdditiveUtilitySpace) profileint.getProfile())
    118                                                 .getUtility(bid).doubleValue() > 0.6;
     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());
    119124        }
    120125
  • exampleparties/randompartypy/pom.xml

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

    r1 r2  
    2323import geniusweb.party.DefaultParty as DefaultParty
    2424import geniusweb.profile.Profile as Profile
     25import geniusweb.profile.PartialOrdering as PartialOrdering
    2526import geniusweb.profile.utilityspace.LinearAdditiveUtilitySpace as LinearAdditiveUtilitySpace
    2627import geniusweb.references.ProfileRef as ProfileRef
     
    2930import geniusweb.profileconnection.ProfileInterface as ProfileInterface
    3031import geniusweb.progress.ProgressRounds as ProgressRounds
     32
    3133
    3234import com.fasterxml.jackson.databind.ObjectMapper as ObjectMapper
     
    9294
    9395        def _isGood(self, bid):
    94                 return bid != None and self.profile.getProfile().getUtility(bid).doubleValue() > 0.6;
     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")
  • issuevalue/pom.xml

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

    r1 r2  
    2121import com.fasterxml.jackson.databind.ObjectMapper;
    2222
    23 import geniusweb.issuevalue.Bid;
    24 import geniusweb.issuevalue.DiscreteValue;
    25 import geniusweb.issuevalue.DiscreteValueSet;
    26 import geniusweb.issuevalue.Domain;
    27 import geniusweb.issuevalue.NumberValue;
    28 import geniusweb.issuevalue.NumberValueSet;
    29 import geniusweb.issuevalue.ValueSet;
    3023import tudelft.utilities.junit.GeneralTests;
    3124
     
    3831        private static final String ISSUE3 = "issue3";
    3932        private static final ObjectMapper jackson = new ObjectMapper();
    40         private static final String domainstring = "{\"name\":\"testdomain\",\"issuesValues\":{\"issue2\":{\"range\":[\"2\",\"3\",\"0.22\"]},\"issue1\":{\"values\":[\"i1v1\",\"i1v2\"]}}}";
     33        private static final String domainstring = "{\"name\":\"testdomain\",\"issuesValues\":{\"issue2\":{\"range\":[2,3,0.22]},\"issue1\":{\"values\":[\"i1v1\",\"i1v2\"]}}}";
    4134
    42         private static final String jobsstring = "{\"name\":\"jobs\","
    43                         + "\"issuesValues\":{"
    44                         + "\"lease car\":{\"values\":[\"yes\",\"no\"]},"
    45                         + "\"permanent contract\":{\"values\":[\"yes\",\"no\"]},"
     35        private static final String jobsstring = "{\"name\":\"jobs\"," + "\"issuesValues\":{"
     36                        + "\"lease car\":{\"values\":[\"yes\",\"no\"]}," + "\"permanent contract\":{\"values\":[\"yes\",\"no\"]},"
    4637                        + "\"career development opportunities\":{\"values\":[\"low\",\"medium\",\"high\"]},"
    4738                        + "\"fte\":{\"values\":[\"0.6\",\"0.8\",\"1.0\"]},"
     
    7364                Map<String, ValueSet> issues1 = new HashMap<>();
    7465                issues1.put(ISSUE1, values1);
    75                 issues1.put(ISSUE2, new NumberValueSet(BigDecimal.ONE, TWO,
    76                                 new BigDecimal("0.22")));
     66                issues1.put(ISSUE2, new NumberValueSet(BigDecimal.ONE, TWO, new BigDecimal("0.22")));
    7767                domain3 = new Domain(DOMAINNAME, issues1);
    7868
     
    8171        @Override
    8272        public List<List<Domain>> getGeneralTestData() {
    83                 return Arrays.asList(Arrays.asList(domain, domain1),
    84                                 Arrays.asList(domain2), Arrays.asList(domain3));
     73                return Arrays.asList(Arrays.asList(domain, domain1), Arrays.asList(domain2), Arrays.asList(domain3));
    8574        }
    8675
    8776        @Override
    8877        public List<String> getGeneralTestStrings() {
    89                 return Arrays.asList("Domain.*testdomain.*", "Domain.*testdomain1.*",
    90                                 "Domain.*testdomain.*");
     78                return Arrays.asList("Domain.*testdomain.*", "Domain.*testdomain1.*", "Domain.*testdomain.*");
    9179        }
    9280
     
    10997                System.out.println(jobsstring);
    11098                Domain jobsdomain = jackson.readValue(jobsstring, Domain.class);
    111                 assertEquals(new HashSet<>(Arrays.asList("lease car",
    112                                 "permanent contract", "career development opportunities", "fte",
    113                                 "salary", "work from home")), jobsdomain.getIssues());
     99                assertEquals(new HashSet<>(Arrays.asList("lease car", "permanent contract", "career development opportunities",
     100                                "fte", "salary", "work from home")), jobsdomain.getIssues());
    114101
    115102        }
     
    134121        public void testIsCompleteNoIssuesDefined() {
    135122                Bid bid = mock(Bid.class);
    136                 assertThat(domain.isComplete(bid), new PatternMatch(
    137                                 "Issues in bid .* do not match issues in domain .*"));
     123                assertThat(domain.isComplete(bid), new PatternMatch("Issues in bid .* do not match issues in domain .*"));
    138124        }
    139125
     
    154140                // THREE is NOT a possible value in the NumberValueSet.
    155141                when(bid.getValue(ISSUE2)).thenReturn(new NumberValue(THREE));
    156                 assertThat(domain.isComplete(bid),
    157                                 new PatternMatch("bid issue issue2 has illegal value 3"));
     142                assertThat(domain.isComplete(bid), new PatternMatch("bid issue issue2 has illegal value 3"));
    158143        }
    159144
     
    167152                // THREE is NOT a possible value in the NumberValueSet.
    168153                when(bid.getValue(ISSUE2)).thenReturn(new NumberValue(THREE));
    169                 assertThat(domain.isComplete(bid), new PatternMatch(
    170                                 "Issues in bid .* do not match issues in domain .*"));
     154                assertThat(domain.isComplete(bid), new PatternMatch("Issues in bid .* do not match issues in domain .*"));
    171155        }
    172156
  • issuevalue/src/test/java/geniusweb/issuevalue/NumberValueSetTest.java

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

    r1 r2  
    1616 */
    1717@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.WRAPPER_OBJECT)
    18 @JsonSubTypes({ @JsonSubTypes.Type(value = LinearAdditiveUtilitySpace.class) })
     18@JsonSubTypes({ @JsonSubTypes.Type(value = LinearAdditiveUtilitySpace.class),
     19                @JsonSubTypes.Type(value = DefaultPartialOrdering.class) })
    1920public interface Profile {
    2021
     
    3233        /**
    3334         *
    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
     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
    3939         *         "reservation value" and is more general. If null, there is no
    4040         *         reservation bid and any agreement is better than no agreement.
  • profileconnection/src/main/java/geniusweb/profileconnection/FileProfileConnector.java

    r1 r2  
    1010
    1111import geniusweb.profile.Profile;
    12 import geniusweb.profile.utilityspace.LinearAdditiveUtilitySpace;
    1312
    1413/**
     
    1716public class FileProfileConnector implements ProfileInterface {
    1817        private final static ObjectMapper jackson = new ObjectMapper();
    19         private final LinearAdditiveUtilitySpace profile;
     18        private final Profile profile;
    2019
    2120        /**
     
    2625        public FileProfileConnector(String filename) throws IOException {
    2726                Path path = new File(filename).toPath();
    28                 String serialized = new String(Files.readAllBytes(path),
    29                                 StandardCharsets.UTF_8);
    30                 profile = (LinearAdditiveUtilitySpace) jackson.readValue(serialized,
    31                                 Profile.class);
     27                String serialized = new String(Files.readAllBytes(path), StandardCharsets.UTF_8);
     28                profile = jackson.readValue(serialized, Profile.class);
    3229        }
    3330
    3431        @Override
    35         public LinearAdditiveUtilitySpace getProfile() {
     32        public Profile getProfile() {
    3633                return profile;
    3734        }
  • protocol/pom.xml

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

    r1 r2  
    55import java.nio.file.Files;
    66import java.nio.file.Paths;
     7import java.util.Arrays;
     8import java.util.Collection;
    79
    810import org.junit.Before;
    911import org.junit.Test;
     12import org.junit.runner.RunWith;
     13import org.junit.runners.Parameterized;
     14import org.junit.runners.Parameterized.Parameters;
    1015
    1116import com.fasterxml.jackson.databind.ObjectMapper;
    1217
    1318import geniusweb.protocol.session.SessionSettings;
    14 import geniusweb.simplerunner.ClassPathConnectionFactory;
    15 import geniusweb.simplerunner.NegoRunner;
    1619import tudelft.utilities.logging.ReportToLogger;
    1720import tudelft.utilities.logging.Reporter;
     
    2225 * this module.
    2326 */
     27@RunWith(Parameterized.class)
    2428public class SessionRunnerE2ETest {
    25         private static final String SESSION_SETTINGS = "src/test/resources/settings.json";
    2629        private final ObjectMapper jackson = new ObjectMapper();
    2730        private NegoRunner runner;
    2831        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        }
    2943
    3044        @Before
    3145        public void before() throws IOException {
    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);
     46                String serialized = new String(Files.readAllBytes(Paths.get(filename)), StandardCharsets.UTF_8);
     47                SessionSettings settings = jackson.readValue(serialized, SessionSettings.class);
    3748
    38                 runner = new NegoRunner(settings, new ClassPathConnectionFactory(),
    39                                 logger);
     49                runner = new NegoRunner(settings, new ClassPathConnectionFactory(), logger);
    4050
    4151        }
     
    5262        @Test
    5363        public void runTestMainFunction() throws IOException {
    54                 NegoRunner.main(new String[] { SESSION_SETTINGS });
     64                NegoRunner.main(new String[] { filename });
    5565        }
    5666}
Note: See TracChangeset for help on using the changeset viewer.