Changeset 14 for src/main/webapp/utilstable.xhtml
- Timestamp:
- 06/11/20 16:34:50 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/main/webapp/utilstable.xhtml
r13 r14 257 257 */ 258 258 function addUtilityCell(cell, agreedbid, partyname, profileurl) { 259 if (Object.keys(agreedbid).lengt==0) {260 cell.innerHTML = "0 :"+partyname;261 return;262 }263 259 var util = utility(profiles[profileurl],agreedbid); 264 260 cell.innerHTML = Math.round(util*1000000)/1000000 +" :"+partyname; … … 267 263 268 264 269 270 271 /**272 @json the log file contents273 @param partyprofiles a dict with key=party id and value a the (linear additive) profile274 */275 function computeUtils(json, partyprofiles) {276 277 setStatus("Computing utilities.")278 var utilities={};279 for (var party in partyprofiles) {280 utilities[party]=[];281 }282 var actions = json['actions'];283 for (var action in actions) {284 var offer = actions[action];285 if (offer['offer']==undefined)286 continue;287 var issueutilities = offer['offer']['bid']['issuevalues']288 for (var party in partyprofiles) {289 utilities[party].push(utility(partyprofiles[party],issueutilities));290 }291 }292 return utilities;293 294 295 }296 265 297 266 … … 324 293 /** 325 294 Compute utilityes 326 @param linadditive the linear additive utility space295 @param profile the linear additive utility space 327 296 @param issueValues the bid containing dict with values for the issues 328 @return utility of issueValues 297 @param isResBidAlternative true if the reservation bid is usable as alternative bid 298 . If true, and the issueValues list is empty/null, this returns the utility 299 of the reservation bid instead. 300 @return utility of issueValues. Returns 0 if profile =null or no bid available 301 329 302 */ 330 function utility(profile, issueValues) { 303 function utility(profile, issueValues, isResBidAlternative) { 304 if (profile==null) return 0; 305 306 // check if we need the reservationbid. 307 if (issueValues==null || Object.keys(issueValues).length==0) { 308 var resBid = profile['reservationBid']; 309 if (resBid==null) return 0; 310 issueValues = resBid['issuevalues']; 311 } 312 313 if (issueValues==null) return 0; 314 331 315 var util=0; 332 316 var weights = profile['issueWeights']; … … 359 343 if (utilfunc['discreteutils']!=undefined) { 360 344 // it's discrete issue. Compute 361 return utilfunc['discreteutils']['valueUtilities'][value]; 345 if (value in utilfunc['discreteutils']['valueUtilities']) 346 return utilfunc['discreteutils']['valueUtilities'][value]; 347 return 0; 362 348 } 363 349 setStatus("Unknown utility function type "+Object.keys(utilfunc));
Note:
See TracChangeset
for help on using the changeset viewer.