Changeset 10 for exampleparties
- Timestamp:
- 01/28/20 10:19:54 (5 years ago)
- Location:
- exampleparties
- Files:
-
- 36 added
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
exampleparties/humangui/src/main/java/geniusweb/exampleparties/humangui/HumanGui.java
r9 r10 2 2 3 3 import java.awt.BorderLayout; 4 import java.net.URI;5 import java.net.URISyntaxException;6 4 import java.util.Arrays; 7 5 import java.util.HashSet; … … 23 21 import geniusweb.profileconnection.ProfileConnectionFactory; 24 22 import geniusweb.profileconnection.ProfileInterface; 25 import geniusweb.references.ProtocolRef;26 23 import tudelft.utilities.logging.Reporter; 27 24 … … 85 82 @Override 86 83 public Capabilities getCapabilities() { 87 try { 88 return new Capabilities(new HashSet<>( 89 Arrays.asList(new ProtocolRef(new URI("SAOP"))))); 90 } catch (URISyntaxException e) { 91 getReporter().log(Level.SEVERE, "Failed to create capabilities URI", 92 e); 93 return null; 94 } 84 return new Capabilities(new HashSet<>(Arrays.asList("SAOP"))); 95 85 } 96 86 -
exampleparties/humangui/src/test/java/geniusweb/exampleparties/humangui/BiddingInfoTest.java
r9 r10 32 32 import geniusweb.party.inform.Settings; 33 33 import geniusweb.profile.Profile; 34 import geniusweb.profile.utilityspace.LinearAdditive UtilitySpace;34 import geniusweb.profile.utilityspace.LinearAdditive; 35 35 import geniusweb.profileconnection.ProfileConnectionFactory; 36 36 import geniusweb.profileconnection.ProfileInterface; … … 61 61 private final ProgressRounds progress = mock(ProgressRounds.class); 62 62 private Settings settings; 63 private LinearAdditive UtilitySpaceprofile, profile2;63 private LinearAdditive profile, profile2; 64 64 private final Parameters parameters = new Parameters(); 65 65 private Reporter reporter = mock(Reporter.class); … … 76 76 String serialized = new String(Files.readAllBytes(Paths.get(PROFILE)), 77 77 StandardCharsets.UTF_8); 78 profile = (LinearAdditiveUtilitySpace) jackson.readValue(serialized, 79 Profile.class); 78 profile = (LinearAdditive) jackson.readValue(serialized, Profile.class); 80 79 String serialized2 = new String(Files.readAllBytes(Paths.get(PROFILE2)), 81 80 StandardCharsets.UTF_8); 82 profile2 = (LinearAdditive UtilitySpace) jackson.readValue(serialized2,81 profile2 = (LinearAdditive) jackson.readValue(serialized2, 83 82 Profile.class); 84 83 -
exampleparties/humangui/src/test/java/geniusweb/exampleparties/humangui/HumanGuiTest.java
r9 r10 34 34 import geniusweb.party.inform.YourTurn; 35 35 import geniusweb.profile.Profile; 36 import geniusweb.profile.utilityspace.LinearAdditive UtilitySpace;36 import geniusweb.profile.utilityspace.LinearAdditive; 37 37 import geniusweb.progress.ProgressRounds; 38 38 import geniusweb.references.Parameters; … … 57 57 private final ProgressRounds progress = mock(ProgressRounds.class); 58 58 private Settings settings; 59 private LinearAdditive UtilitySpaceprofile;59 private LinearAdditive profile; 60 60 private final Parameters parameters = new Parameters(); 61 61 … … 70 70 String serialized = new String(Files.readAllBytes(Paths.get(PROFILE)), 71 71 StandardCharsets.UTF_8); 72 profile = (LinearAdditiveUtilitySpace) jackson.readValue(serialized, 73 Profile.class); 72 profile = (LinearAdditive) jackson.readValue(serialized, Profile.class); 74 73 75 74 } … … 93 92 Capabilities capabilities = party.getCapabilities(); 94 93 assertFalse("party does not define protocols", 95 capabilities.get Protocols().isEmpty());94 capabilities.getBehaviours().isEmpty()); 96 95 } 97 96 98 97 @Test 99 98 public void testGetCapabilities() { 100 assertTrue(party.getCapabilities().get Protocols().contains(SAOP));99 assertTrue(party.getCapabilities().getBehaviours().contains(SAOP)); 101 100 } 102 101 -
exampleparties/pom.xml
r2 r10 23 23 <module>boulware</module> 24 24 <module>linear</module> 25 <module>simpleshaop</module> 26 <module>comparebids</module> 25 27 </modules> 26 28 </project> -
exampleparties/randomparty/src/main/java/geniusweb/exampleparties/randomparty/RandomParty.java
r9 r10 3 3 import java.io.IOException; 4 4 import java.math.BigInteger; 5 import java.net.URI;6 import java.net.URISyntaxException;7 5 import java.util.Arrays; 8 6 import java.util.HashSet; … … 30 28 import geniusweb.progress.Progress; 31 29 import geniusweb.progress.ProgressRounds; 32 import geniusweb.references.ProtocolRef;33 30 import tudelft.utilities.logging.Reporter; 34 31 … … 81 78 @Override 82 79 public Capabilities getCapabilities() { 83 try { 84 return new Capabilities(new HashSet<>( 85 Arrays.asList(new ProtocolRef(new URI("SAOP"))))); 86 } catch (URISyntaxException e) { 87 getReporter().log(Level.SEVERE, "Failed to create capabilities URI", 88 e); 89 return null; 90 } 80 return new Capabilities(new HashSet<>(Arrays.asList("SAOP"))); 91 81 } 92 82 … … 115 105 } 116 106 117 private boolean isGood(Bid bid) {107 private boolean isGood(Bid bid) throws IOException { 118 108 if (bid == null) 119 109 return false; -
exampleparties/randomparty/src/test/java/geniusweb/exampleparties/randomparty/RandomPartyTest.java
r9 r10 42 42 import geniusweb.party.inform.YourTurn; 43 43 import geniusweb.profile.Profile; 44 import geniusweb.profile.utilityspace.LinearAdditive UtilitySpace;44 import geniusweb.profile.utilityspace.LinearAdditive; 45 45 import geniusweb.progress.ProgressRounds; 46 46 import geniusweb.references.Parameters; … … 53 53 public class RandomPartyTest { 54 54 55 private static final ProtocolRef SAOP = new ProtocolRef("SAOP");55 private static final String SAOP = "SAOP"; 56 56 private static final PartyId otherparty = new PartyId("other"); 57 57 private static final String PROFILE = "src/test/resources/testprofile.json"; … … 63 63 private final ProgressRounds progress = mock(ProgressRounds.class); 64 64 private Settings settings; 65 private LinearAdditive UtilitySpaceprofile;65 private LinearAdditive profile; 66 66 private final Parameters parameters = new Parameters(); 67 67 … … 76 76 String serialized = new String(Files.readAllBytes(Paths.get(PROFILE)), 77 77 StandardCharsets.UTF_8); 78 profile = (LinearAdditiveUtilitySpace) jackson.readValue(serialized, 79 Profile.class); 78 profile = (LinearAdditive) jackson.readValue(serialized, Profile.class); 80 79 81 80 } … … 94 93 Capabilities capabilities = party.getCapabilities(); 95 94 assertFalse("party does not define protocols", 96 capabilities.get Protocols().isEmpty());95 capabilities.getBehaviours().isEmpty()); 97 96 } 98 97 … … 176 175 @Test 177 176 public void testGetCapabilities() { 178 assertTrue(party.getCapabilities().get Protocols().contains(SAOP));177 assertTrue(party.getCapabilities().getBehaviours().contains(SAOP)); 179 178 } 180 179 -
exampleparties/randompartypy/src/main/resources/RandomParty.py
r9 r10 65 65 # Override 66 66 def getCapabilities(self): # -> Capabilities 67 try: 68 return Capabilities(HashSet([ ProtocolRef(URI("SAOP"))])) 69 except: 70 getReporter().log(Level.SEVERE, "Failed to create capabilities URI",e); 71 return None 67 return Capabilities(HashSet([ "SAOP"])) 72 68 73 69 # Override -
exampleparties/randompartypy/src/test/java/geniusweb/exampleparties/randompartypy/RandomPartyTest.java
r9 r10 39 39 import geniusweb.party.inform.YourTurn; 40 40 import geniusweb.profile.Profile; 41 import geniusweb.profile.utilityspace.LinearAdditive UtilitySpace;41 import geniusweb.profile.utilityspace.LinearAdditive; 42 42 import geniusweb.progress.ProgressRounds; 43 43 import geniusweb.pythonadapter.PythonPartyAdapter; … … 51 51 52 52 private static final String PROFILE = "src/test/resources/testprofile.json"; 53 private static final ProtocolRef SAOP = new ProtocolRef("SAOP");53 private static final String SAOP = "SAOP"; 54 54 private static final PartyId otherparty = new PartyId("other"); 55 55 private final static ObjectMapper jackson = new ObjectMapper(); … … 62 62 private final Parameters parameters = new Parameters(); 63 63 64 private LinearAdditive UtilitySpaceprofile; // the real profile64 private LinearAdditive profile; // the real profile 65 65 66 66 @Before … … 80 80 String serialized = new String(Files.readAllBytes(Paths.get(PROFILE)), 81 81 StandardCharsets.UTF_8); 82 profile = (LinearAdditiveUtilitySpace) jackson.readValue(serialized, 83 Profile.class); 82 profile = (LinearAdditive) jackson.readValue(serialized, Profile.class); 84 83 85 84 } … … 98 97 Capabilities capabilities = party.getCapabilities(); 99 98 assertFalse("party does not define protocols", 100 capabilities.get Protocols().isEmpty());99 capabilities.getBehaviours().isEmpty()); 101 100 } 102 101 … … 167 166 @Test 168 167 public void testGetCapabilities() { 169 assertTrue(party.getCapabilities().get Protocols().contains(SAOP));168 assertTrue(party.getCapabilities().getBehaviours().contains(SAOP)); 170 169 } 171 170 -
exampleparties/timedependentparty/src/main/java/geniusweb/exampleparties/timedependentparty/ExtendedUtilSpace.java
r4 r10 11 11 import geniusweb.issuevalue.Bid; 12 12 import geniusweb.issuevalue.Value; 13 import geniusweb.profile.utilityspace.LinearAdditive UtilitySpace;13 import geniusweb.profile.utilityspace.LinearAdditive; 14 14 import tudelft.utilities.immutablelist.ImmutableList; 15 15 … … 20 20 */ 21 21 public class ExtendedUtilSpace { 22 private LinearAdditive UtilitySpaceutilspace;22 private LinearAdditive utilspace; 23 23 private BigDecimal tolerance; // utility tolerance for a bid. 24 24 private BidsWithUtility bidutils; … … 27 27 private BigDecimal maxUtil; 28 28 29 public ExtendedUtilSpace(LinearAdditive UtilitySpacespace) {29 public ExtendedUtilSpace(LinearAdditive space) { 30 30 this.utilspace = space; 31 31 bidutils = new BidsWithUtility(utilspace); -
exampleparties/timedependentparty/src/main/java/geniusweb/exampleparties/timedependentparty/TimeDependentParty.java
r8 r10 4 4 import java.math.BigDecimal; 5 5 import java.math.BigInteger; 6 import java.net.URI;7 import java.net.URISyntaxException;8 6 import java.util.Arrays; 9 7 import java.util.HashSet; … … 24 22 import geniusweb.party.inform.YourTurn; 25 23 import geniusweb.profile.Profile; 26 import geniusweb.profile.utilityspace.LinearAdditive UtilitySpace;24 import geniusweb.profile.utilityspace.LinearAdditive; 27 25 import geniusweb.profileconnection.ProfileConnectionFactory; 28 26 import geniusweb.profileconnection.ProfileInterface; 29 27 import geniusweb.progress.Progress; 30 28 import geniusweb.progress.ProgressRounds; 31 import geniusweb.references.ProtocolRef;32 29 import tudelft.utilities.immutablelist.ImmutableList; 33 30 import tudelft.utilities.logging.Reporter; … … 44 41 private static final BigDecimal DEC100 = new BigDecimal("100"); 45 42 private ProfileInterface profileint; 46 private LinearAdditive UtilitySpaceutilspace = null; // last received space43 private LinearAdditive utilspace = null; // last received space 47 44 private PartyId me; 48 45 private Progress progress; … … 61 58 @Override 62 59 public Capabilities getCapabilities() { 63 try { 64 return new Capabilities(new HashSet<>( 65 Arrays.asList(new ProtocolRef(new URI("SAOP"))))); 66 } catch (URISyntaxException e) { 67 getReporter().log(Level.SEVERE, "Failed to create capabilities URI", 68 e); 69 return null; 70 } 60 return new Capabilities(new HashSet<>(Arrays.asList("SAOP"))); 71 61 } 72 62 … … 148 138 } 149 139 150 private LinearAdditive UtilitySpace updateUtilSpace(){140 private LinearAdditive updateUtilSpace() throws IOException { 151 141 Profile newutilspace = profileint.getProfile(); 152 142 if (!newutilspace.equals(utilspace)) { 153 utilspace = (LinearAdditive UtilitySpace) newutilspace;143 utilspace = (LinearAdditive) newutilspace; 154 144 extendedspace = new ExtendedUtilSpace(utilspace); 155 145 } -
exampleparties/timedependentparty/src/test/java/geniusweb/exampleparties/timedependentparty/TimeDependentPartyTest.java
r9 r10 53 53 public class TimeDependentPartyTest { 54 54 55 private static final ProtocolRef SAOP = new ProtocolRef("SAOP");55 private static final String SAOP = "SAOP"; 56 56 private static final PartyId otherparty = new PartyId("other"); 57 57 private static final String PROFILE = "src/test/resources/testprofile.json"; … … 105 105 Capabilities capabilities = party.getCapabilities(); 106 106 assertFalse("party does not define protocols", 107 capabilities.get Protocols().isEmpty());107 capabilities.getBehaviours().isEmpty()); 108 108 } 109 109 … … 198 198 @Test 199 199 public void testGetCapabilities() { 200 assertTrue(party.getCapabilities().get Protocols().contains(SAOP));200 assertTrue(party.getCapabilities().getBehaviours().contains(SAOP)); 201 201 } 202 202
Note:
See TracChangeset
for help on using the changeset viewer.