Changeset 9 for exampleparties/randomparty
- Timestamp:
- 11/28/19 14:40:48 (5 years ago)
- Location:
- exampleparties/randomparty
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
exampleparties/randomparty/pom.xml
r6 r9 6 6 <groupId>geniusweb.exampleparties</groupId> 7 7 <artifactId>randomparty</artifactId> 8 <version>1. 0.0</version>8 <version>1.1.0</version> 9 9 <packaging>jar</packaging> 10 10 … … 33 33 <groupId>geniusweb</groupId> 34 34 <artifactId>party</artifactId> 35 <version>1. 0.0</version>35 <version>1.1.0</version> 36 36 </dependency> 37 37 … … 39 39 <groupId>geniusweb</groupId> 40 40 <artifactId>bidspace</artifactId> 41 <version>1.0.0</version> 41 <version>1.1.0</version> 42 </dependency> 43 <dependency> 44 <groupId>geniusweb</groupId> 45 <artifactId>profileconnection</artifactId> 46 <version>1.1.0</version> 42 47 </dependency> 43 48 <dependency> 44 49 <groupId>tudelft.utilities</groupId> 45 50 <artifactId>logging</artifactId> 46 <version>1.0.0</version>47 </dependency>48 <dependency>49 <groupId>geniusweb</groupId>50 <artifactId>profileconnection</artifactId>51 51 <version>1.0.0</version> 52 52 </dependency> -
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 -
exampleparties/randomparty/src/test/java/geniusweb/exampleparties/randomparty/RandomPartyTest.java
r8 r9 33 33 import geniusweb.actions.PartyId; 34 34 import geniusweb.bidspace.AllBidsList; 35 import geniusweb.connection.Connection ;35 import geniusweb.connection.ConnectionEnd; 36 36 import geniusweb.issuevalue.Bid; 37 37 import geniusweb.party.Capabilities; … … 107 107 public void testInformSettings() { 108 108 party.connect(connection); 109 connection.notify Change(settings);109 connection.notifyListeners(settings); 110 110 assertEquals(0, connection.getActions().size()); 111 111 } … … 199 199 */ 200 200 class TestConnection extends DefaultListenable<Inform> 201 implements Connection <Inform, Action> {201 implements ConnectionEnd<Inform, Action> { 202 202 private List<Action> actions = new LinkedList<>(); 203 203
Note:
See TracChangeset
for help on using the changeset viewer.