app/managers/PlayerAgentManager.js
//reassign probability mass for each player based on WTP
reassign probability mass for each player based on WTP
reassign probability mass for each player based on WTP
updateWeights(
    fadingFactor,
    names
  ) {
    const cards = this.cards
    let WTPOffset = 0
    if (!fadingFactor) {
      fadingFactor = 0.5
    }
    let agent_list
    if (names && !names.includes('all')) {
      agent_list = []
      for (const name of names) {
        agent_list.push(this.agents.get(name))
      }
    } else {
      agent_list = Array.from(this.agents.values())
    }
    for (const agent of agent_list) {
      const dailyDraw = agent.estimatedDailyDraw
      agent.calculateWTP(dailyDraw, fadingFactor)
    }
    const totalDailyDraw = this.totalDailyDraw
    this.updateTotalWTP()
    this.updateWTP_reverse()
    const WTP_reverse_sum = this.WTP_reverse_sum
    const sorted_agents = agent_list
    sorted_agents.sort((a, b) => {
      return b.WTP_reverse - a.WTP_reverse
    })
    const avg_wtp = this.totalWTP / this.agents.size
    let remainingTotalDailyDraw = totalDailyDraw
    for (const agent of sorted_agents) {
      WTPOffset = agent.getUpdatedWeight(
        totalDailyDraw,
        remainingTotalDailyDraw,
        WTP_reverse_sum,
        avg_wtp,
        this.correctionFactor1,
        this.correctionFactor2,
        cards,
        WTPOffset
      )
      remainingTotalDailyDraw -= agent.estimatedDailyDraw
    }
  }
updateWeights ( fadingFactor , names ) { const cards = this . cards let WTPOffset = 0 if ( ! fadingFactor ) { fadingFactor = 0.5 } let agent_list if ( names && ! names . includes ( 'all' ) ) { agent_list = [ ] for ( const name of names ) { agent_list . push ( this . agents . get ( name ) ) } } else { agent_list = Array . from ( this . agents . values ( ) ) } for ( const agent of agent_list ) { const dailyDraw = agent . estimatedDailyDraw agent . calculateWTP ( dailyDraw , fadingFactor ) } const totalDailyDraw = this . totalDailyDraw this . updateTotalWTP ( ) this . updateWTP_reverse ( ) const WTP_reverse_sum = this . WTP_reverse_sum const sorted_agents = agent_list sorted_agents . sort ( ( a , b ) => { return b . WTP_reverse - a . WTP_reverse } ) const avg_wtp = this . totalWTP / this . agents . size let remainingTotalDailyDraw = totalDailyDraw for ( const agent of sorted_agents ) { WTPOffset = agent . getUpdatedWeight ( totalDailyDraw , remainingTotalDailyDraw , WTP_reverse_sum , avg_wtp , this . correctionFactor1 , this . correctionFactor2 , cards , WTPOffset ) remainingTotalDailyDraw -= agent . estimatedDailyDraw } }
reassign probability mass for each player based on WTP
reassign probability mass for each player based on WTP