Changeset 9 for exampleparties/randomparty/src/main
- Timestamp:
- 11/28/19 14:40:48 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
exampleparties/randomparty/src/main/java/geniusweb/exampleparties/randomparty/RandomParty.java
r2 r9 25 25 import geniusweb.profile.PartialOrdering; 26 26 import geniusweb.profile.Profile; 27 import geniusweb.profile.utilityspace. LinearAdditiveUtilitySpace;27 import geniusweb.profile.utilityspace.UtilitySpace; 28 28 import geniusweb.profileconnection.ProfileConnectionFactory; 29 29 import geniusweb.profileconnection.ProfileInterface; … … 57 57 if (info instanceof Settings) { 58 58 Settings settings = (Settings) info; 59 this.profileint = ProfileConnectionFactory.create(settings.getProfile().getURI(), getReporter()); 59 this.profileint = ProfileConnectionFactory 60 .create(settings.getProfile().getURI(), getReporter()); 60 61 this.me = settings.getID(); 61 62 this.progress = settings.getProgress(); … … 74 75 } 75 76 } catch (Exception e) { 76 getReporter().log(Level.SEVERE,"Failed to handle info", e);77 throw new RuntimeException("Failed to handle info", e); 77 78 } 78 79 } … … 81 82 public Capabilities getCapabilities() { 82 83 try { 83 return new Capabilities(new HashSet<>(Arrays.asList(new ProtocolRef(new URI("SAOP"))))); 84 return new Capabilities(new HashSet<>( 85 Arrays.asList(new ProtocolRef(new URI("SAOP"))))); 84 86 } catch (URISyntaxException e) { 85 getReporter().log(Level.SEVERE, "Failed to create capabilities URI", e); 87 getReporter().log(Level.SEVERE, "Failed to create capabilities URI", 88 e); 86 89 return null; 87 90 } … … 99 102 } else { 100 103 // for demo. Obviously full bids have higher util in general 101 AllPartialBidsList bidspace = new AllPartialBidsList(profileint.getProfile().getDomain()); 104 AllPartialBidsList bidspace = new AllPartialBidsList( 105 profileint.getProfile().getDomain()); 102 106 Bid bid = null; 103 107 for (int attempt = 0; attempt < 20 && !isGood(bid); attempt++) { … … 115 119 return false; 116 120 Profile profile = profileint.getProfile(); 117 if (profile instanceof LinearAdditiveUtilitySpace) {118 return (( LinearAdditiveUtilitySpace) profile).getUtility(bid).doubleValue() > 0.6;121 if (profile instanceof UtilitySpace) { 122 return ((UtilitySpace) profile).getUtility(bid).doubleValue() > 0.6; 119 123 } 120 124 if (profile instanceof PartialOrdering) { 121 return ((PartialOrdering) profile).isPreferredOrEqual(bid, profile.getReservationBid()); 125 return ((PartialOrdering) profile).isPreferredOrEqual(bid, 126 profile.getReservationBid()); 122 127 } 123 throw new IllegalArgumentException("Can not handle profile type " + profile.getClass()); 128 throw new IllegalArgumentException( 129 "Can not handle profile type " + profile.getClass()); 124 130 } 125 131
Note:
See TracChangeset
for help on using the changeset viewer.