Changeset 18 for protocol/src/main/java
- Timestamp:
- 06/11/20 16:34:40 (4 years ago)
- Location:
- protocol/src/main/java/geniusweb/protocol
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
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 }
Note:
See TracChangeset
for help on using the changeset viewer.