Changeset 22 for protocol/src/main/java/geniusweb
- Timestamp:
- 09/22/20 16:26:36 (4 years ago)
- Location:
- protocol/src/main/java/geniusweb/protocol/session/mopac
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
protocol/src/main/java/geniusweb/protocol/session/mopac/MOPAC.java
r21 r22 145 145 ProtocolToPartyConnFactory connectionfactory) { 146 146 try { 147 System.out.println("starting MOPAC");147 //System.out.println("starting MOPAC"); 148 148 // we're in Phase.INIT still 149 149 connect(connectionfactory); … … 314 314 final ProtocolToPartyConn partyconn, final Action action, 315 315 long now) { 316 System.out.println("received " + action);316 //System.out.println("received " + action); 317 317 state = state.with(partyconn.getParty(), action, now); 318 318 checkEndPhase(System.currentTimeMillis()); … … 341 341 342 342 state = state.nextPhase(now); 343 343 344 startPhase(now); 344 345 } … … 351 352 */ 352 353 private void broadcastNegotiators(Inform info) { 353 System.out.println("broadcasting " + info);354 //System.out.println("broadcasting " + info); 354 355 for (PartyId party : state.getPhase().getPartyStates() 355 356 .getNegotiatingParties()) { -
protocol/src/main/java/geniusweb/protocol/session/mopac/MOPACState.java
r21 r22 14 14 import geniusweb.actions.PartyId; 15 15 import geniusweb.inform.Agreements; 16 import geniusweb.inform.OptIn; 16 17 import geniusweb.progress.Progress; 17 18 import geniusweb.progress.ProgressRounds; … … 22 23 import geniusweb.protocol.session.SessionState; 23 24 import geniusweb.protocol.session.mopac.phase.OfferPhase; 25 import geniusweb.protocol.session.mopac.phase.OptInPhase; 24 26 import geniusweb.protocol.session.mopac.phase.Phase; 25 27 import geniusweb.protocol.session.saop.SAOPSettings; … … 127 129 /** 128 130 * @param now current time ms since 1970 129 * @return the max possible duration in ms of th is phase. Maybe negative if130 * ew are past deadline131 * @return the max possible duration in ms of the NEXT phase. Maybe 0 or 132 * negative if past deadline. 131 133 */ 132 134 private Long getAvailablePhaseTime(long now) { 135 // explicit check, to check also the round counts. 136 if (incrementProgress().isPastDeadline(now + Phase.PHASE_MINTIME)) 137 return 0l; 133 138 return Math.min(progress.getTerminationTime().getTime() - now, 134 139 Phase.PHASE_MAXTIME); … … 196 201 Phase newphase = phase.next(now, 197 202 Math.min(remainingNegoTime, Phase.PHASE_MAXTIME)); 198 Progress newprogress = progress; 199 if (newphase instanceof OfferPhase 200 && progress instanceof ProgressRounds) 201 newprogress = ((ProgressRounds) progress).advance(); 202 203 return new MOPACState(newphase, actions, connections, newprogress, 204 getSettings(), partyprofiles); 203 204 return new MOPACState(newphase, actions, connections, 205 incrementProgress(), getSettings(), partyprofiles); 206 } 207 208 /** 209 * 210 * @return the next progress. Progress round advances if phase is 211 * {@link OptIn}. 212 */ 213 private Progress incrementProgress() { 214 if (progress instanceof ProgressRounds && phase instanceof OptInPhase) 215 return ((ProgressRounds) progress).advance(); 216 return progress; 205 217 } 206 218 … … 217 229 */ 218 230 public boolean isNewPhasePossible(long now) { 219 return phase.getPartyStates().getNegotiatingParties().size() >= 2 231 // System.out.println("phase=" + phase); 232 boolean a = phase.getPartyStates().getNegotiatingParties().size() >= 2 220 233 && getAvailablePhaseTime(now) > Phase.PHASE_MINTIME; 234 // System.out.println("newstate possible:" + a); 235 return a; 221 236 } 222 237
Note:
See TracChangeset
for help on using the changeset viewer.