Changeset 2 for exampleparties/randomparty/src
- Timestamp:
- 08/28/19 11:35:52 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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
Note:
See TracChangeset
for help on using the changeset viewer.