- Timestamp:
- 06/11/20 16:34:40 (4 years ago)
- Location:
- protocol
- Files:
-
- 1 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
protocol/pom.xml
r14 r18 6 6 <groupId>geniusweb</groupId> 7 7 <artifactId>protocol</artifactId> 8 <version>1.4. 0</version>8 <version>1.4.1</version> <!-- must equal ${geniusweb.version} --> 9 9 <packaging>jar</packaging> 10 10 … … 17 17 <passwd>${env.ARTIFACTORY_PASS}</passwd> 18 18 <jackson-2-version>2.9.10</jackson-2-version> 19 <geniusweb.version>1.4.1</geniusweb.version> 19 20 </properties> 20 21 … … 31 32 <groupId>geniusweb</groupId> 32 33 <artifactId>profile</artifactId> 33 <version> 1.4.0</version>34 <version>${geniusweb.version}</version> 34 35 </dependency> 35 36 <dependency> 36 37 <groupId>geniusweb</groupId> 37 38 <artifactId>party</artifactId> 38 <version> 1.4.0</version>39 <version>${geniusweb.version}</version> 39 40 </dependency> 40 41 <dependency> 41 42 <groupId>geniusweb</groupId> 42 43 <artifactId>references</artifactId> 43 <version> 1.4.0</version>44 <version>${geniusweb.version}</version> 44 45 </dependency> 45 46 <dependency> 46 47 <groupId>geniusweb</groupId> 47 48 <artifactId>events</artifactId> 48 <version> 1.4.0</version>49 <version>${geniusweb.version}</version> 49 50 </dependency> 50 51 <dependency> 51 52 <groupId>tudelft.utilities</groupId> 52 53 <artifactId>immutablelist</artifactId> 53 <version>1. 0.1</version>54 <version>1.1.0</version> 54 55 </dependency> 55 56 <dependency> -
protocol/src/main/java/geniusweb/protocol/session/shaop/BareSHAOPState.java
r11 r18 22 22 */ 23 23 public abstract class BareSHAOPState implements SessionState { 24 24 25 protected final List<Action> actions; 25 26 … … 167 168 } 168 169 170 @Override 171 public int hashCode() { 172 final int prime = 31; 173 int result = 1; 174 result = prime * result + ((actions == null) ? 0 : actions.hashCode()); 175 result = prime * result + ((error == null) ? 0 : error.hashCode()); 176 result = prime * result 177 + ((partyNumbers == null) ? 0 : partyNumbers.hashCode()); 178 result = prime * result 179 + ((progress == null) ? 0 : progress.hashCode()); 180 result = prime * result 181 + ((settings == null) ? 0 : settings.hashCode()); 182 result = prime * result + teamNr; 183 result = prime * result 184 + ((totalSpent == null) ? 0 : totalSpent.hashCode()); 185 return result; 186 } 187 188 @Override 189 public boolean equals(Object obj) { 190 if (this == obj) 191 return true; 192 if (obj == null) 193 return false; 194 if (getClass() != obj.getClass()) 195 return false; 196 BareSHAOPState other = (BareSHAOPState) obj; 197 if (actions == null) { 198 if (other.actions != null) 199 return false; 200 } else if (!actions.equals(other.actions)) 201 return false; 202 if (error == null) { 203 if (other.error != null) 204 return false; 205 } else if (!error.equals(other.error)) 206 return false; 207 if (partyNumbers == null) { 208 if (other.partyNumbers != null) 209 return false; 210 } else if (!partyNumbers.equals(other.partyNumbers)) 211 return false; 212 if (progress == null) { 213 if (other.progress != null) 214 return false; 215 } else if (!progress.equals(other.progress)) 216 return false; 217 if (settings == null) { 218 if (other.settings != null) 219 return false; 220 } else if (!settings.equals(other.settings)) 221 return false; 222 if (teamNr != other.teamNr) 223 return false; 224 if (totalSpent == null) { 225 if (other.totalSpent != null) 226 return false; 227 } else if (!totalSpent.equals(other.totalSpent)) 228 return false; 229 return true; 230 } 231 169 232 } -
protocol/src/main/java/geniusweb/protocol/session/shaop/SHAOP.java
r11 r18 50 50 * party of this type can execute a RequestComparison(userid) action, which 51 51 * increases the total bother with the elicitationcost. The call results in the 52 * associated COB party to execute a Comparison action. 52 * associated COB party to execute a Comparison action. If this parameter is not 53 * set, the {@link SHAOPState#DEFAULT_ELICITATATION_COST} is used. 53 54 * <p> 54 55 * A SHAOP party keeps the turn until it does an action that is not a … … 58 59 * <p> 59 60 * The Comparison/ComparisonTest actions are private between the 60 * {@link ShaopTeam}. A SHAOP party can do a {@link ElicitComparison} action 61 * a t any time. These actions are completely transparent to the other parties62 * a nd are not dependent or influencing the normal turn taking.61 * {@link ShaopTeam}. A SHAOP party can do a {@link ElicitComparison} action at 62 * any time. These actions are completely transparent to the other parties and 63 * are not dependent or influencing the normal turn taking. 63 64 */ 64 65 public class SHAOP extends DefaultListenable<ProtocolEvent> … … 162 163 ProtocolToPartyConnFactory connectionfactory) 163 164 throws InterruptedException, IOException { 164 List<PartyWithProfile> participants = state.getSettings() 165 . getTeams().stream().map(team -> team.getAllParties())165 List<PartyWithProfile> participants = state.getSettings().getTeams() 166 .stream().map(team -> team.getAllParties()) 166 167 .flatMap(List::stream).collect(Collectors.toList()); 167 168 List<Reference> parties = participants.stream() -
protocol/src/main/java/geniusweb/protocol/session/shaop/SHAOPState.java
r11 r18 30 30 public class SHAOPState extends BareSHAOPState { 31 31 32 p rivate static final double DEFAULT_ELICITATATION_COST = 0.1d;32 public static final double DEFAULT_ELICITATATION_COST = 0.01d; 33 33 34 34 /** … … 277 277 // shaop party does real action, move to next SHAOP party. 278 278 newTeam = (teamNr + 1) % settings.getTeams().size(); 279 if (newprogress instanceof ProgressRounds) { 279 // check if we completed a round 280 if (newprogress instanceof ProgressRounds && newTeam == 0) { 280 281 newprogress = ((ProgressRounds) newprogress).advance(); 282 System.out.println("Progressed rounds " + newprogress 283 + " after action " + action + ""); 281 284 } 282 285 } -
protocol/src/main/java/geniusweb/protocol/tournament/allpermutations/AllPermutationsSettings.java
r16 r18 1 1 package geniusweb.protocol.tournament.allpermutations; 2 2 3 import java.math.BigInteger; 3 4 import java.util.Collections; 4 5 import java.util.List; 6 import java.util.function.BiFunction; 5 7 6 8 import com.fasterxml.jackson.annotation.JsonCreator; … … 17 19 import geniusweb.references.PartyWithProfile; 18 20 import tudelft.utilities.immutablelist.FixedList; 19 import tudelft.utilities.immutablelist.Function2;20 21 import tudelft.utilities.immutablelist.ImmutableList; 21 22 import tudelft.utilities.immutablelist.MapList; … … 25 26 import tudelft.utilities.immutablelist.PermutationsWithReturn; 26 27 import tudelft.utilities.immutablelist.PermutationsWithoutReturn; 28 import tudelft.utilities.immutablelist.Repeat; 27 29 import tudelft.utilities.immutablelist.Tuple; 28 30 import tudelft.utilities.immutablelist.Tuples; … … 56 58 public class AllPermutationsSettings implements TournamentSettings { 57 59 58 public static final String COB_PARTY = "comparebids-1.2.0";59 60 private final List<Team> teams; 60 61 private final List<ProfileList> profileslists; … … 62 63 private final int teamsPerSession; 63 64 private final SessionSettings sessionsettings; 65 private final int numberTournaments; 64 66 65 67 /** 66 68 * 67 * @param teams a list of {@link Team}s. Must contain at least 68 * {@link #teamsPerSession} elements. The <teamsize> 69 * must match the protocol: (SAOP:1, SHAOP:2) 70 * @param reuseTeams if true, we use PermutationsWithReturn, if false 71 * we use PermutationsWithoutReturn to create the 72 * teams. 73 * @param plists list of available {@link ProfileList}s to be 74 * permutated over the teams. Each 75 * {@link ProfileList} must contain <teamsize> 76 * elements. 77 * @param teamsPerSession number of parties per session, must be at least 2. 78 * @param sesettings The generic {@link SessionSetting}. 79 * {@link SessionSettings#with(PartyWithProfile)} 80 * will be used to add the required 81 * {@link PartyWithProfile}s 69 * @param teams a list of {@link Team}s. Must contain at least 70 * {@link #teamsPerSession} elements. The 71 * <teamsize> must match the protocol: (SAOP:1, 72 * SHAOP:2) 73 * @param reuseTeams if true, we use PermutationsWithReturn, if false 74 * we use PermutationsWithoutReturn to create the 75 * teams. 76 * @param plists list of available {@link ProfileList}s to be 77 * permutated over the teams. Each 78 * {@link ProfileList} must contain <teamsize> 79 * elements. 80 * @param teamsPerSession number of parties per session, must be at least 81 * 2. 82 * @param sesettings The generic {@link SessionSetting}. 83 * {@link SessionSettings#with(PartyWithProfile)} 84 * will be used to add the required 85 * {@link PartyWithProfile}s 86 * @param numberTournaments the number of times the tournament should be 87 * run. 82 88 */ 83 89 @JsonCreator … … 86 92 @JsonProperty("reuseTeams") boolean reuseTeams, 87 93 @JsonProperty("teamsPerSession") int teamsPerSession, 88 @JsonProperty("sessionsettings") SessionSettings sesettings) { 94 @JsonProperty("sessionsettings") SessionSettings sesettings, 95 @JsonProperty("numberTournaments") int nTournaments) { 89 96 if (teamsPerSession < 2) 90 97 throw new IllegalArgumentException("teamsPerSession must be >=2"); … … 96 103 "profileslist must contain at least " + teamsPerSession 97 104 + " ProfileList's"); 105 if (nTournaments <= 0) 106 throw new IllegalArgumentException("nTournaments must be >0"); 98 107 int teamsize; 99 108 if (sesettings instanceof SAOPSettings) … … 117 126 + teamsize + " but found " 118 127 + profile.getProfiles().size()); 119 120 128 } 121 129 } … … 125 133 this.profileslists = plists; 126 134 this.sessionsettings = sesettings; 135 this.numberTournaments = nTournaments; 127 136 } 128 137 … … 159 168 return "AllPermutationsSettings[" + teams + "," + reuseTeams + "," 160 169 + profileslists + "," + teamsPerSession + "," + sessionsettings 161 + " ]";170 + "," + numberTournaments + "]"; 162 171 } 163 172 … … 166 175 final int prime = 31; 167 176 int result = 1; 168 result = prime * result + ((teams == null) ? 0 : teams.hashCode()); 169 result = prime * result + teamsPerSession; 177 result = prime * result + numberTournaments; 170 178 result = prime * result 171 179 + ((profileslists == null) ? 0 : profileslists.hashCode()); … … 173 181 result = prime * result 174 182 + ((sessionsettings == null) ? 0 : sessionsettings.hashCode()); 183 result = prime * result + ((teams == null) ? 0 : teams.hashCode()); 184 result = prime * result + teamsPerSession; 175 185 return result; 176 186 } … … 185 195 return false; 186 196 AllPermutationsSettings other = (AllPermutationsSettings) obj; 197 if (numberTournaments != other.numberTournaments) 198 return false; 199 if (profileslists == null) { 200 if (other.profileslists != null) 201 return false; 202 } else if (!profileslists.equals(other.profileslists)) 203 return false; 204 if (reuseTeams != other.reuseTeams) 205 return false; 206 if (sessionsettings == null) { 207 if (other.sessionsettings != null) 208 return false; 209 } else if (!sessionsettings.equals(other.sessionsettings)) 210 return false; 187 211 if (teams == null) { 188 212 if (other.teams != null) … … 191 215 return false; 192 216 if (teamsPerSession != other.teamsPerSession) 193 return false;194 if (profileslists == null) {195 if (other.profileslists != null)196 return false;197 } else if (!profileslists.equals(other.profileslists))198 return false;199 if (reuseTeams != other.reuseTeams)200 return false;201 if (sessionsettings == null) {202 if (other.sessionsettings != null)203 return false;204 } else if (!sessionsettings.equals(other.sessionsettings))205 217 return false; 206 218 return true; … … 251 263 partiesPermutations, profilesPermutations); 252 264 253 returnnew MapList<Tuple<ImmutableList<Team>, ImmutableList<ProfileList>>, ImmutableList<TeamOfPartiesAndProfiles>>(265 MapList<Tuple<ImmutableList<Team>, ImmutableList<ProfileList>>, ImmutableList<TeamOfPartiesAndProfiles>> tournamentsettings = new MapList<Tuple<ImmutableList<Team>, ImmutableList<ProfileList>>, ImmutableList<TeamOfPartiesAndProfiles>>( 254 266 tuple -> teamlist(tuple), tuples); 267 return new Repeat<ImmutableList<TeamOfPartiesAndProfiles>>( 268 tournamentsettings, BigInteger.valueOf(numberTournaments), 269 true); 255 270 } 256 271 … … 264 279 private ImmutableList<TeamOfPartiesAndProfiles> teamlist( 265 280 Tuple<ImmutableList<Team>, ImmutableList<ProfileList>> tuple) { 266 Function2<Team, ProfileList, TeamOfPartiesAndProfiles> makeparty = new Function2<Team, ProfileList, TeamOfPartiesAndProfiles>() {281 BiFunction<Team, ProfileList, TeamOfPartiesAndProfiles> makeparty = new BiFunction<Team, ProfileList, TeamOfPartiesAndProfiles>() { 267 282 @Override 268 283 public TeamOfPartiesAndProfiles apply(Team team, … … 288 303 } 289 304 290 // /**291 // * Extract the raw URL, without the part after the question mark292 // *293 // * @param party a party reference (for another party)294 // * @param profile a profile that may have a filter like "?partial=XX"295 // * @return profile without the filter and with a cob party on the same296 // * machine. IT IS ASSUMED that there will the default297 // * "comparebids-1.0.0" party on the same machine as where the other298 // * party is299 // */300 // protected static PartyWithProfile makeCob(PartyRef party,301 // ProfileRef profile) {302 // try {303 // URI profileuri = profile.getURI();304 // URI partyuri = party.getURI();305 // ProfileRef cobprof = new ProfileRef(profileuri.getScheme() + "://"306 // + profileuri.getAuthority() + profileuri.getPath());307 // String partypath = partyuri.getPath();308 // partypath = partypath.substring(0, partypath.lastIndexOf('/'));309 // PartyWithParameters cobparty = new PartyWithParameters(new PartyRef(310 // partyuri.getScheme() + "://" + partyuri.getAuthority()311 // + partypath + "/" + COB_PARTY),312 // new Parameters());313 // return new PartyWithProfile(cobparty, cobprof);314 //315 // } catch (URISyntaxException e) {316 // throw new IllegalArgumentException(317 // "Failed making cob party with profile " + profile, e);318 // }319 // }320 321 305 } -
protocol/src/test/java/geniusweb/protocol/tournament/allpermutations/AllPermutationsSettingsTest.java
r14 r18 32 32 private final ObjectMapper jackson = new ObjectMapper(); 33 33 34 private final String serialized = "{\"AllPermutationsSettings\":{\"teams\":[{\"Team\":[{\"partyref\":\"party1\",\"parameters\":{}}]},{\"Team\":[{\"partyref\":\"party2\",\"parameters\":{}}]}],\"profileslists\":[{\"ProfileList\":[\"profile1\"]},{\"ProfileList\":[\"profile2\"]},{\"ProfileList\":[\"profile3\"]}],\"reuseTeams\":false,\"teamsPerSession\":2,\"sessionsettings\":{\"SAOPSettings\":{\"participants\":[],\"deadline\":{\"deadlinetime\":{\"durationms\":10000}}}} }}";34 private final String serialized = "{\"AllPermutationsSettings\":{\"teams\":[{\"Team\":[{\"partyref\":\"party1\",\"parameters\":{}}]},{\"Team\":[{\"partyref\":\"party2\",\"parameters\":{}}]}],\"profileslists\":[{\"ProfileList\":[\"profile1\"]},{\"ProfileList\":[\"profile2\"]},{\"ProfileList\":[\"profile3\"]}],\"reuseTeams\":false,\"teamsPerSession\":2,\"sessionsettings\":{\"SAOPSettings\":{\"participants\":[],\"deadline\":{\"deadlinetime\":{\"durationms\":10000}}}},\"numberTournaments\":1}}"; 35 35 private AllPermutationsSettings settings, settings1a, settings2, settings3, 36 settings4 ;36 settings4, settings5; 37 37 38 38 // use directly because there is some hard coding currently. … … 76 76 77 77 settings = new AllPermutationsSettings(parties, profiles, false, 2, 78 saopsettings );78 saopsettings, 1); 79 79 80 80 settings1a = new AllPermutationsSettings(parties, profiles, false, 2, 81 saopsettings );81 saopsettings, 1); 82 82 83 83 settings2 = new AllPermutationsSettings(Arrays.asList(partywithparams1, 84 84 partywithparams2, partywithparams3), profiles, false, 2, 85 saopsettings );85 saopsettings, 1); 86 86 87 87 settings3 = new AllPermutationsSettings(parties, profiles, true, 2, 88 saopsettings );88 saopsettings, 1); 89 89 90 90 settings4 = new AllPermutationsSettings(parties, 91 91 Arrays.asList(profiles1, profiles2, profiles3, profiles1), 92 false, 2, saopsettings); 92 false, 2, saopsettings, 1); 93 94 settings5 = new AllPermutationsSettings(parties, profiles, false, 2, 95 saopsettings, 2); 93 96 94 97 } … … 98 101 return Arrays.asList(Arrays.asList(settings, settings1a), 99 102 Arrays.asList(settings2), Arrays.asList(settings3), 100 Arrays.asList(settings4) );103 Arrays.asList(settings4), Arrays.asList(settings5)); 101 104 } 102 105 … … 104 107 public List<String> getGeneralTestStrings() { 105 108 return Arrays.asList( 106 "AllPermutationsSettings.*party1.*party2.*,false,.*profile1.*profile2.*profile3.*,2,SAOPSettings.*", 107 "AllPermutationsSettings.*party1.*party2.*party3.*,false,.*profile1.*profile2.*profile3.*,2,SAOPSettings.*", 108 "AllPermutationsSettings.*party1.*party2.*,true,.*profile1.*profile2.*profile3.*,2,SAOPSettings.*", 109 "AllPermutationsSettings.*party1.*party2.*,false,.*profile1.*profile2.*profile3.*profile1.*,2,SAOPSettings.*"); 109 "AllPermutationsSettings.*party1.*party2.*,false,.*profile1.*profile2.*profile3.*,2,SAOPSettings.*1.*", 110 "AllPermutationsSettings.*party1.*party2.*party3.*,false,.*profile1.*profile2.*profile3.*,2,SAOPSettings.*1.*", 111 "AllPermutationsSettings.*party1.*party2.*,true,.*profile1.*profile2.*profile3.*,2,SAOPSettings.*1.*", 112 "AllPermutationsSettings.*party1.*party2.*,false,.*profile1.*profile2.*profile3.*profile1.*,2,SAOPSettings.*1.*", 113 "AllPermutationsSettings.*party1.*party2.*,false,.*profile1.*profile2.*profile3.*,2,SAOPSettings.*2.*"); 110 114 } 111 115 … … 137 141 new AllPermutationsSettings(null, 138 142 Arrays.asList(profiles1, profiles2, profiles3, profiles1), true, 139 2, saopsettings );143 2, saopsettings, 1); 140 144 141 145 } … … 145 149 new AllPermutationsSettings(Collections.emptyList(), 146 150 Arrays.asList(profiles1, profiles2, profiles3, profiles1), true, 147 2, saopsettings );151 2, saopsettings, 1); 148 152 149 153 } … … 151 155 @Test(expected = IllegalArgumentException.class) 152 156 public void testNullProfiles() { 153 new AllPermutationsSettings(parties, null, true, 2, saopsettings );157 new AllPermutationsSettings(parties, null, true, 2, saopsettings, 1); 154 158 155 159 } … … 159 163 new AllPermutationsSettings(parties, 160 164 Arrays.asList(profiles1, profiles2, profiles3, profiles1), true, 161 4, saopsettings );165 4, saopsettings, 1); 162 166 163 167 } … … 167 171 new AllPermutationsSettings(parties, 168 172 Arrays.asList(profiles1, profiles2, profiles3, profiles1), true, 169 4, null );173 4, null, 1); 170 174 171 175 } … … 175 179 new AllPermutationsSettings(parties, 176 180 Arrays.asList(profiles1, profiles2, profiles3, profiles1), true, 177 1, saopsettings );181 1, saopsettings, 1); 178 182 179 183 }
Note:
See TracChangeset
for help on using the changeset viewer.