Changeset 2 for exampleparties


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

Added new parties : linear, hardliner, conceder, boulware

Location:
exampleparties
Files:
57 added
5 edited

Legend:

Unmodified
Added
Removed
  • 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")
Note: See TracChangeset for help on using the changeset viewer.