Changeset 19 for src/main/webapp/plotlog.xhtml
- Timestamp:
- 09/28/20 09:29:02 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/main/webapp/plotlog.xhtml
r18 r19 87 87 */ 88 88 function processLogFile(json) { 89 89 90 if (json['SAOPState']!=undefined) { 90 processS AOP(json['SAOPState']);91 processStandard(json['SAOPState'], 'SAOP'); 91 92 } else if (json['SHAOPState']!=undefined) { 92 93 processSHAOP(json['SHAOPState']); … … 94 95 // just use the SAOP processor, which shows the 95 96 // utilities of all Offers in sequence. 96 processS AOP(json['MOPACState']);97 processStandard(json['MOPACState'], 'MOPAC'); 97 98 } else{ 98 99 setStatus("Unknown log file contents "+Object.keys(json)); … … 101 102 102 103 /** 103 Handle SAOP protocol result. 104 */ 105 function processSAOP(json) { 104 Handle standard protocol result. 105 @param protocol either SAOP or MOPAC or another SAOP-like protocol 106 */ 107 function processStandard(json, protocol) { 106 108 var partyprofiles={} 107 109 var profs=json['partyprofiles']; … … 110 112 } 111 113 112 getProfiles(json, partyprofiles );114 getProfiles(json, partyprofiles, protocol); 113 115 } 114 116 … … 129 131 130 132 131 getProfiles(json, partyprofiles );133 getProfiles(json, partyprofiles, "SHAOP"); 132 134 } 133 135 … … 148 150 /** 149 151 Get the partyprofiles. 150 @json the json protocol result 151 @partyprofileURIs dict with the websocket addresses for each party'as profile 152 @partyprofiles dict with each party's profile. Initially should be {} 153 */ 154 function getProfiles(json, partyprofileURIs, partyprofiles={}) { 152 @param json the json protocol result 153 @param partyprofileURIs dict with the websocket addresses for each party'as profile 154 @param partyprofiles dict with each party's profile. Initially should be {} 155 @param protocol protocolname, eg "SAOP" 156 */ 157 function getProfiles(json, partyprofileURIs, protocol, partyprofiles={} ) { 155 158 var keys = Object.keys(partyprofileURIs); 156 159 if (keys.length==0) { 157 plotResults(computeUtils(json, partyprofiles), isAgreement(json ));160 plotResults(computeUtils(json, partyprofiles), isAgreement(json, protocol)); 158 161 return; 159 162 } … … 178 181 } 179 182 partyprofiles[party]=profile['LinearAdditiveUtilitySpace']; 180 getProfiles(json, partyprofileURIs, p artyprofiles);183 getProfiles(json, partyprofileURIs, protocol, partyprofiles); 181 184 }; 182 185 ws.onerror=function(event) { … … 186 189 187 190 /** 188 @return true if there is agreement 189 */ 190 function isAgreement(logfile) { 191 var actions=logfile['actions']; 192 var lastact = actions[actions.length -1]; 193 return 'accept' in lastact; 191 @param logfile the logfile content, but below the protocol header 192 @param protocol the protocol name, eg SAOP, SHAOP, MOPAC 193 @return 'Yes' if there is agreement, 'No' if there is no agreement at all, 194 or 'Partial' if part of the parties agreed and part did not. 195 or '?' if unsupported protocol 196 */ 197 function isAgreement(logfile, protocol) { 198 switch (protocol) { 199 case "SAOP": 200 case "SHAOP": 201 var actions=logfile['actions']; 202 var lastact = actions[actions.length -1]; 203 return 'accept' in lastact ? 'Yes':'No'; 204 case "MOPAC": 205 var finalstate=logfile['phase']['partyStates']; 206 var nagrees=Object.keys(finalstate['agreements']).length; 207 var nparties=Object.keys(finalstate['powers']).length; 208 if (nagrees==nparties) return "Yes"; 209 if (nagrees==0) return "No" 210 return "Partial"; 211 default: 212 return "?"; 213 } 194 214 } 195 215 /** … … 235 255 /** 236 256 @param utilities the dict with key=party id of the utilities of all steps for each party ) 237 @param isAgreement true iff there is agreement reached257 @param isAgreement either Yes, No, Partial or ? 238 258 */ 239 259 … … 241 261 setStatus("Plotting" ) 242 262 243 document.getElementById('agreement').innerHTML=isAgreement ?"Yes":"No";263 document.getElementById('agreement').innerHTML=isAgreement; 244 264 245 265 var parties=Object.keys(utilities); … … 287 307 scaleLabel: { 288 308 display: true, 289 labelString: ' Turn'309 labelString: 'Offer' 290 310 } 291 311 }],
Note:
See TracChangeset
for help on using the changeset viewer.