Changeset 2 for exampleparties
- Timestamp:
- 08/28/19 11:35:52 (5 years ago)
- Location:
- exampleparties
- Files:
-
- 57 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
exampleparties/pom.xml
r1 r2 18 18 <module>randomparty</module> 19 19 <module>randompartypy</module> 20 <module>timedependentparty</module> 21 <module>conceder</module> 22 <module>hardliner</module> 23 <module>boulware</module> 24 <module>linear</module> 20 25 </modules> 21 26 </project> -
exampleparties/randomparty/pom.xml
r1 r2 54 54 <groupId>tudelft.utilities</groupId> 55 55 <artifactId>immutablelist</artifactId> 56 <version>1.0. 0</version>56 <version>1.0.1</version> 57 57 </dependency> 58 58 -
exampleparties/randomparty/src/main/java/geniusweb/exampleparties/randomparty/RandomParty.java
r1 r2 23 23 import geniusweb.party.inform.Settings; 24 24 import geniusweb.party.inform.YourTurn; 25 import geniusweb.profile.PartialOrdering; 26 import geniusweb.profile.Profile; 25 27 import geniusweb.profile.utilityspace.LinearAdditiveUtilitySpace; 26 28 import geniusweb.profileconnection.ProfileConnectionFactory; … … 55 57 if (info instanceof Settings) { 56 58 Settings settings = (Settings) info; 57 this.profileint = ProfileConnectionFactory 58 .create(settings.getProfile().getURI(), getReporter()); 59 this.profileint = ProfileConnectionFactory.create(settings.getProfile().getURI(), getReporter()); 59 60 this.me = settings.getID(); 60 61 this.progress = settings.getProgress(); … … 80 81 public Capabilities getCapabilities() { 81 82 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"))))); 84 84 } 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); 87 86 return null; 88 87 } … … 100 99 } else { 101 100 // 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()); 104 102 Bid bid = null; 105 103 for (int attempt = 0; attempt < 20 && !isGood(bid); attempt++) { … … 114 112 115 113 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()); 119 124 } 120 125 -
exampleparties/randompartypy/pom.xml
r1 r2 47 47 <groupId>tudelft.utilities</groupId> 48 48 <artifactId>immutablelist</artifactId> 49 <version>1.0. 0</version>49 <version>1.0.1</version> 50 50 </dependency> 51 51 -
exampleparties/randompartypy/src/main/resources/RandomParty.py
r1 r2 23 23 import geniusweb.party.DefaultParty as DefaultParty 24 24 import geniusweb.profile.Profile as Profile 25 import geniusweb.profile.PartialOrdering as PartialOrdering 25 26 import geniusweb.profile.utilityspace.LinearAdditiveUtilitySpace as LinearAdditiveUtilitySpace 26 27 import geniusweb.references.ProfileRef as ProfileRef … … 29 30 import geniusweb.profileconnection.ProfileInterface as ProfileInterface 30 31 import geniusweb.progress.ProgressRounds as ProgressRounds 32 31 33 32 34 import com.fasterxml.jackson.databind.ObjectMapper as ObjectMapper … … 92 94 93 95 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.