Changeset 46 for src/main/webapp/plotlog.xhtml
- Timestamp:
- 12/18/24 13:54:06 (3 weeks ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/main/webapp/plotlog.xhtml
r45 r46 56 56 57 57 var ws = null; 58 59 function arrayequals(array1, array2) { 60 return array1.length === array2.length && array1.every(function(value, index) { return value === array2[index]}) 61 } 58 62 59 63 <!-- Most functions are reactive programming written out--> … … 179 183 ws.onmessage = function (event) { 180 184 var profile = JSON.parse(event.data); 181 if (profile['LinearAdditiveUtilitySpace']==undefined ) {182 setStatus('Fatal: profile '+uri+" does not contain a LinearAdditive UtilitySpace.");185 if (profile['LinearAdditiveUtilitySpace']==undefined && profile['SumOfGroupsUtilitySpace']==undefined) { 186 setStatus('Fatal: profile '+uri+" does not contain a LinearAdditive- or SumOfGroups UtilitySpace."); 183 187 return; 184 188 } 185 partyprofiles[party]=profile ['LinearAdditiveUtilitySpace'];189 partyprofiles[party]=profile; 186 190 getProfiles(json, partyprofileURIs, protocol, partyprofiles); 187 191 }; … … 381 385 382 386 387 function utility(profile, issueValues) { 388 if (profile['LinearAdditiveUtilitySpace']!=undefined) 389 return linearUtility(profile['LinearAdditiveUtilitySpace'], issueValues); 390 391 if (profile['SumOfGroupsUtilitySpace']!=undefined) 392 return groupUtility(profile['SumOfGroupsUtilitySpace'], issueValues); 393 394 } 395 396 /** 397 Compute utilityes for a linear-additive profile 398 @param linadditive the linear additive utility space 399 @param issueValues the bid containing dict with values for the issues 400 @return utility of issueValues 401 */ 402 function groupUtility(profile, issueValues) { 403 var util=0; 404 405 for (var part in profile['partUtilities']) { 406 util = util + grouputil(profile['partUtilities'][part]['PartsUtilities'], issueValues ); 407 } 408 return util; 409 } 410 411 function grouputil(partutils, issueValues) { 412 413 // extract the exact value list of this group 414 var value = [] 415 for (const iss of partutils['issues']) { 416 value.push( issueValues[iss] ) 417 } 418 419 // find the utility in the utilslist 420 for (const item of partutils['utilslist']) { 421 if ( arrayequals( item['values'], value)) 422 return item['util'] 423 } 424 return 0; // fallback, not found. Maybe error? 425 426 } 427 428 383 429 384 385 430 /** 386 Compute utilityes 431 Compute utilityes for a linear-additive profile 387 432 @param linadditive the linear additive utility space 388 433 @param issueValues the bid containing dict with values for the issues 389 434 @return utility of issueValues 390 435 */ 391 function utility(profile, issueValues) {436 function linearUtility(profile, issueValues) { 392 437 var util=0; 393 438 var weights = profile['issueWeights']; … … 399 444 } 400 445 401 /** 446 447 /** 402 448 Bit hacky, javascript version of evaluator of utility space. 403 449 Would be much nicer if we could use java here … … 437 483 438 484 485 439 486 </script> 440 487
Note:
See TracChangeset
for help on using the changeset viewer.