Changeset 10 for exampleparties


Ignore:
Timestamp:
01/28/20 10:19:54 (5 years ago)
Author:
bart
Message:

Update 28 jan 2020

Location:
exampleparties
Files:
36 added
11 edited

Legend:

Unmodified
Added
Removed
  • exampleparties/humangui/src/main/java/geniusweb/exampleparties/humangui/HumanGui.java

    r9 r10  
    22
    33import java.awt.BorderLayout;
    4 import java.net.URI;
    5 import java.net.URISyntaxException;
    64import java.util.Arrays;
    75import java.util.HashSet;
     
    2321import geniusweb.profileconnection.ProfileConnectionFactory;
    2422import geniusweb.profileconnection.ProfileInterface;
    25 import geniusweb.references.ProtocolRef;
    2623import tudelft.utilities.logging.Reporter;
    2724
     
    8582        @Override
    8683        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")));
    9585        }
    9686
  • exampleparties/humangui/src/test/java/geniusweb/exampleparties/humangui/BiddingInfoTest.java

    r9 r10  
    3232import geniusweb.party.inform.Settings;
    3333import geniusweb.profile.Profile;
    34 import geniusweb.profile.utilityspace.LinearAdditiveUtilitySpace;
     34import geniusweb.profile.utilityspace.LinearAdditive;
    3535import geniusweb.profileconnection.ProfileConnectionFactory;
    3636import geniusweb.profileconnection.ProfileInterface;
     
    6161        private final ProgressRounds progress = mock(ProgressRounds.class);
    6262        private Settings settings;
    63         private LinearAdditiveUtilitySpace profile, profile2;
     63        private LinearAdditive profile, profile2;
    6464        private final Parameters parameters = new Parameters();
    6565        private Reporter reporter = mock(Reporter.class);
     
    7676                String serialized = new String(Files.readAllBytes(Paths.get(PROFILE)),
    7777                                StandardCharsets.UTF_8);
    78                 profile = (LinearAdditiveUtilitySpace) jackson.readValue(serialized,
    79                                 Profile.class);
     78                profile = (LinearAdditive) jackson.readValue(serialized, Profile.class);
    8079                String serialized2 = new String(Files.readAllBytes(Paths.get(PROFILE2)),
    8180                                StandardCharsets.UTF_8);
    82                 profile2 = (LinearAdditiveUtilitySpace) jackson.readValue(serialized2,
     81                profile2 = (LinearAdditive) jackson.readValue(serialized2,
    8382                                Profile.class);
    8483
  • exampleparties/humangui/src/test/java/geniusweb/exampleparties/humangui/HumanGuiTest.java

    r9 r10  
    3434import geniusweb.party.inform.YourTurn;
    3535import geniusweb.profile.Profile;
    36 import geniusweb.profile.utilityspace.LinearAdditiveUtilitySpace;
     36import geniusweb.profile.utilityspace.LinearAdditive;
    3737import geniusweb.progress.ProgressRounds;
    3838import geniusweb.references.Parameters;
     
    5757        private final ProgressRounds progress = mock(ProgressRounds.class);
    5858        private Settings settings;
    59         private LinearAdditiveUtilitySpace profile;
     59        private LinearAdditive profile;
    6060        private final Parameters parameters = new Parameters();
    6161
     
    7070                String serialized = new String(Files.readAllBytes(Paths.get(PROFILE)),
    7171                                StandardCharsets.UTF_8);
    72                 profile = (LinearAdditiveUtilitySpace) jackson.readValue(serialized,
    73                                 Profile.class);
     72                profile = (LinearAdditive) jackson.readValue(serialized, Profile.class);
    7473
    7574        }
     
    9392                Capabilities capabilities = party.getCapabilities();
    9493                assertFalse("party does not define protocols",
    95                                 capabilities.getProtocols().isEmpty());
     94                                capabilities.getBehaviours().isEmpty());
    9695        }
    9796
    9897        @Test
    9998        public void testGetCapabilities() {
    100                 assertTrue(party.getCapabilities().getProtocols().contains(SAOP));
     99                assertTrue(party.getCapabilities().getBehaviours().contains(SAOP));
    101100        }
    102101
  • exampleparties/pom.xml

    r2 r10  
    2323                <module>boulware</module>
    2424                <module>linear</module>
     25                <module>simpleshaop</module>
     26                <module>comparebids</module>
    2527        </modules>
    2628</project>
  • exampleparties/randomparty/src/main/java/geniusweb/exampleparties/randomparty/RandomParty.java

    r9 r10  
    33import java.io.IOException;
    44import java.math.BigInteger;
    5 import java.net.URI;
    6 import java.net.URISyntaxException;
    75import java.util.Arrays;
    86import java.util.HashSet;
     
    3028import geniusweb.progress.Progress;
    3129import geniusweb.progress.ProgressRounds;
    32 import geniusweb.references.ProtocolRef;
    3330import tudelft.utilities.logging.Reporter;
    3431
     
    8178        @Override
    8279        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")));
    9181        }
    9282
     
    115105        }
    116106
    117         private boolean isGood(Bid bid) {
     107        private boolean isGood(Bid bid) throws IOException {
    118108                if (bid == null)
    119109                        return false;
  • exampleparties/randomparty/src/test/java/geniusweb/exampleparties/randomparty/RandomPartyTest.java

    r9 r10  
    4242import geniusweb.party.inform.YourTurn;
    4343import geniusweb.profile.Profile;
    44 import geniusweb.profile.utilityspace.LinearAdditiveUtilitySpace;
     44import geniusweb.profile.utilityspace.LinearAdditive;
    4545import geniusweb.progress.ProgressRounds;
    4646import geniusweb.references.Parameters;
     
    5353public class RandomPartyTest {
    5454
    55         private static final ProtocolRef SAOP = new ProtocolRef("SAOP");
     55        private static final String SAOP = "SAOP";
    5656        private static final PartyId otherparty = new PartyId("other");
    5757        private static final String PROFILE = "src/test/resources/testprofile.json";
     
    6363        private final ProgressRounds progress = mock(ProgressRounds.class);
    6464        private Settings settings;
    65         private LinearAdditiveUtilitySpace profile;
     65        private LinearAdditive profile;
    6666        private final Parameters parameters = new Parameters();
    6767
     
    7676                String serialized = new String(Files.readAllBytes(Paths.get(PROFILE)),
    7777                                StandardCharsets.UTF_8);
    78                 profile = (LinearAdditiveUtilitySpace) jackson.readValue(serialized,
    79                                 Profile.class);
     78                profile = (LinearAdditive) jackson.readValue(serialized, Profile.class);
    8079
    8180        }
     
    9493                Capabilities capabilities = party.getCapabilities();
    9594                assertFalse("party does not define protocols",
    96                                 capabilities.getProtocols().isEmpty());
     95                                capabilities.getBehaviours().isEmpty());
    9796        }
    9897
     
    176175        @Test
    177176        public void testGetCapabilities() {
    178                 assertTrue(party.getCapabilities().getProtocols().contains(SAOP));
     177                assertTrue(party.getCapabilities().getBehaviours().contains(SAOP));
    179178        }
    180179
  • exampleparties/randompartypy/src/main/resources/RandomParty.py

    r9 r10  
    6565        # Override
    6666        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"]))
    7268
    7369        # Override
  • exampleparties/randompartypy/src/test/java/geniusweb/exampleparties/randompartypy/RandomPartyTest.java

    r9 r10  
    3939import geniusweb.party.inform.YourTurn;
    4040import geniusweb.profile.Profile;
    41 import geniusweb.profile.utilityspace.LinearAdditiveUtilitySpace;
     41import geniusweb.profile.utilityspace.LinearAdditive;
    4242import geniusweb.progress.ProgressRounds;
    4343import geniusweb.pythonadapter.PythonPartyAdapter;
     
    5151
    5252        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";
    5454        private static final PartyId otherparty = new PartyId("other");
    5555        private final static ObjectMapper jackson = new ObjectMapper();
     
    6262        private final Parameters parameters = new Parameters();
    6363
    64         private LinearAdditiveUtilitySpace profile; // the real profile
     64        private LinearAdditive profile; // the real profile
    6565
    6666        @Before
     
    8080                String serialized = new String(Files.readAllBytes(Paths.get(PROFILE)),
    8181                                StandardCharsets.UTF_8);
    82                 profile = (LinearAdditiveUtilitySpace) jackson.readValue(serialized,
    83                                 Profile.class);
     82                profile = (LinearAdditive) jackson.readValue(serialized, Profile.class);
    8483
    8584        }
     
    9897                Capabilities capabilities = party.getCapabilities();
    9998                assertFalse("party does not define protocols",
    100                                 capabilities.getProtocols().isEmpty());
     99                                capabilities.getBehaviours().isEmpty());
    101100        }
    102101
     
    167166        @Test
    168167        public void testGetCapabilities() {
    169                 assertTrue(party.getCapabilities().getProtocols().contains(SAOP));
     168                assertTrue(party.getCapabilities().getBehaviours().contains(SAOP));
    170169        }
    171170
  • exampleparties/timedependentparty/src/main/java/geniusweb/exampleparties/timedependentparty/ExtendedUtilSpace.java

    r4 r10  
    1111import geniusweb.issuevalue.Bid;
    1212import geniusweb.issuevalue.Value;
    13 import geniusweb.profile.utilityspace.LinearAdditiveUtilitySpace;
     13import geniusweb.profile.utilityspace.LinearAdditive;
    1414import tudelft.utilities.immutablelist.ImmutableList;
    1515
     
    2020 */
    2121public class ExtendedUtilSpace {
    22         private LinearAdditiveUtilitySpace utilspace;
     22        private LinearAdditive utilspace;
    2323        private BigDecimal tolerance; // utility tolerance for a bid.
    2424        private BidsWithUtility bidutils;
     
    2727        private BigDecimal maxUtil;
    2828
    29         public ExtendedUtilSpace(LinearAdditiveUtilitySpace space) {
     29        public ExtendedUtilSpace(LinearAdditive space) {
    3030                this.utilspace = space;
    3131                bidutils = new BidsWithUtility(utilspace);
  • exampleparties/timedependentparty/src/main/java/geniusweb/exampleparties/timedependentparty/TimeDependentParty.java

    r8 r10  
    44import java.math.BigDecimal;
    55import java.math.BigInteger;
    6 import java.net.URI;
    7 import java.net.URISyntaxException;
    86import java.util.Arrays;
    97import java.util.HashSet;
     
    2422import geniusweb.party.inform.YourTurn;
    2523import geniusweb.profile.Profile;
    26 import geniusweb.profile.utilityspace.LinearAdditiveUtilitySpace;
     24import geniusweb.profile.utilityspace.LinearAdditive;
    2725import geniusweb.profileconnection.ProfileConnectionFactory;
    2826import geniusweb.profileconnection.ProfileInterface;
    2927import geniusweb.progress.Progress;
    3028import geniusweb.progress.ProgressRounds;
    31 import geniusweb.references.ProtocolRef;
    3229import tudelft.utilities.immutablelist.ImmutableList;
    3330import tudelft.utilities.logging.Reporter;
     
    4441        private static final BigDecimal DEC100 = new BigDecimal("100");
    4542        private ProfileInterface profileint;
    46         private LinearAdditiveUtilitySpace utilspace = null; // last received space
     43        private LinearAdditive utilspace = null; // last received space
    4744        private PartyId me;
    4845        private Progress progress;
     
    6158        @Override
    6259        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")));
    7161        }
    7262
     
    148138        }
    149139
    150         private LinearAdditiveUtilitySpace updateUtilSpace() {
     140        private LinearAdditive updateUtilSpace() throws IOException {
    151141                Profile newutilspace = profileint.getProfile();
    152142                if (!newutilspace.equals(utilspace)) {
    153                         utilspace = (LinearAdditiveUtilitySpace) newutilspace;
     143                        utilspace = (LinearAdditive) newutilspace;
    154144                        extendedspace = new ExtendedUtilSpace(utilspace);
    155145                }
  • exampleparties/timedependentparty/src/test/java/geniusweb/exampleparties/timedependentparty/TimeDependentPartyTest.java

    r9 r10  
    5353public class TimeDependentPartyTest {
    5454
    55         private static final ProtocolRef SAOP = new ProtocolRef("SAOP");
     55        private static final String SAOP = "SAOP";
    5656        private static final PartyId otherparty = new PartyId("other");
    5757        private static final String PROFILE = "src/test/resources/testprofile.json";
     
    105105                Capabilities capabilities = party.getCapabilities();
    106106                assertFalse("party does not define protocols",
    107                                 capabilities.getProtocols().isEmpty());
     107                                capabilities.getBehaviours().isEmpty());
    108108        }
    109109
     
    198198        @Test
    199199        public void testGetCapabilities() {
    200                 assertTrue(party.getCapabilities().getProtocols().contains(SAOP));
     200                assertTrue(party.getCapabilities().getBehaviours().contains(SAOP));
    201201        }
    202202
Note: See TracChangeset for help on using the changeset viewer.