Class Continuous.Traits2Payoff

Object
Traits2Payoff
Enclosing class:
Continuous

public class Continuous.Traits2Payoff extends Object
Translate continuous traits into payoffs based on configurable cost and benefit functions.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    (package private) Continuous.Benefits[]
    The array of benefit functions, one for each trait.
    (package private) double[][]
    The 2D array of cost function parameters.
    (package private) double[][]
    The 2D array of cost function parameters.
    (package private) Continuous.Costs[]
    The array of cost functions, one for each trait.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs a new map for converting traits into oayoffs.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected double
    benefits(double[] me, double[] you)
    Calculate the benefits to the focal individual with traits me when interacting with an opponent with traits you.
    protected double
    benefits(double me, double you, int trait)
    Calculate the benefits to the focal individual with trait value me in trait with index trait when interacting with an opponent with trait value you.
    protected double
    costs(double[] me, double[] you)
    Calculate the costs to the focal individual with traits me when interacting with an opponent with traits you.
    protected double
    costs(double me, double you, int trait)
    Calculate the costs to the focal individual with trait value me in trait with index trait when interacting with an opponent with trait value you.
    formatBenefits(int idx)
    Return formatted string of the benefit function of trait index idx.
    formatCosts(int idx)
    Return formatted string of the cost function of trait index idx.
    getBenefitFunction(int index)
    Get the benefit function for trait index.
    Get the array of benefit functions for each trait.
    double[][]
    Get the 2D array of benefit function parameters.
    double[]
    Get the array of benefit function parameters for trait with index idx.
    getCostFunction(int index)
    Get the cost function for trait index.
    Get the array of cost functions, one for each trait.
    double[][]
    Get the 2D array of cost function parameters.
    double[]
    getCostParameters(int index)
    Get the array of cost function parameters for trait with index idx.
    double
    payoff(double[] me, double[] you)
    Calculate the payoff to the focal individual with traits me when interacting with an opponent with traits you.
    double
    payoff(double me, double you)
    Calculate the payoff to the focal individual with trait me when interacting with an opponent with trait you.
    void
    setBenefitFunction(Continuous.Benefits benefitfcn, double[] bparams, int index)
    Set the benefit function of the trait index to benefitfcn.
    void
    setBenefitParameters(double[] bparams, int index)
    Set the array of benefit function parameters for trait with index idx to array params.
    void
    setCostFunction(Continuous.Costs costfcn, double[] cparams, int index)
    Set the cost function of the trait index to costfcn with parameters in the array cparams.
    void
    setCostParameters(double[] cparams, int index)
    Set the array of cost function parameters for trait with index idx to array params.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • costs

      The array of cost functions, one for each trait.
    • ci

      double[][] ci
      The 2D array of cost function parameters. The rows refer to the different traits and the columns to their cost parameters. ci is not necessarily a square array because the each trait may have different numbers of parameters.
      See Also:
    • benefits

      The array of benefit functions, one for each trait.
    • bi

      double[][] bi
      The 2D array of cost function parameters. The rows refer to the different traits and the columns to their cost parameters. bi is not necessarily a square array because the each trait may have different numbers of parameters.
      See Also:
  • Constructor Details

    • Traits2Payoff

      public Traits2Payoff()
      Constructs a new map for converting traits into oayoffs.
  • Method Details

    • getCostFunctions

      public Continuous.Costs[] getCostFunctions()
      Get the array of cost functions, one for each trait.
      Returns:
      the array of cost functions
    • getCostFunction

      public Continuous.Costs getCostFunction(int index)
      Get the cost function for trait index.
      Parameters:
      index - the index of the trait
      Returns:
      the cost function
    • setCostFunction

      public void setCostFunction(Continuous.Costs costfcn, double[] cparams, int index)
      Set the cost function of the trait index to costfcn with parameters in the array cparams.
      Parameters:
      costfcn - the cost function
      cparams - the array of parameters for costfcn
      index - the index of the trait
    • setCostParameters

      public void setCostParameters(double[] cparams, int index)
      Set the array of cost function parameters for trait with index idx to array params.
      Parameters:
      cparams - the array of cost function parameters
      index - the index of the trait
      See Also:
    • getCostParameters

      public double[] getCostParameters(int index)
      Get the array of cost function parameters for trait with index idx.
      Parameters:
      index - the index of the trait
      Returns:
      the array of cost function parameters
      See Also:
    • getCostParameters

      public double[][] getCostParameters()
      Get the 2D array of cost function parameters.
      Returns:
      the 2D array of cost function parameters
      See Also:
    • formatCosts

      public String formatCosts(int idx)
      Return formatted string of the cost function of trait index idx.
      Parameters:
      idx - the index of the trait
      Returns:
      the formatted string
    • getBenefitFunctions

      public Continuous.Benefits[] getBenefitFunctions()
      Get the array of benefit functions for each trait.
      Returns:
      the array of benefit functions
    • getBenefitFunction

      public Continuous.Benefits getBenefitFunction(int index)
      Get the benefit function for trait index.
      Parameters:
      index - the index of the trait
      Returns:
      the benefit function
    • setBenefitFunction

      public void setBenefitFunction(Continuous.Benefits benefitfcn, double[] bparams, int index)
      Set the benefit function of the trait index to benefitfcn.
      Parameters:
      benefitfcn - the benefit function
      bparams - the array of benefit function parameters
      index - the index of the trait
    • setBenefitParameters

      public void setBenefitParameters(double[] bparams, int index)
      Set the array of benefit function parameters for trait with index idx to array params.
      Parameters:
      bparams - the array of benefit function parameters
      index - the index of the trait
      See Also:
    • getBenefitParameters

      public double[] getBenefitParameters(int index)
      Get the array of benefit function parameters for trait with index idx.
      Parameters:
      index - the index of the trait
      Returns:
      the array of benefit function parameters
      See Also:
    • getBenefitParameters

      public double[][] getBenefitParameters()
      Get the 2D array of benefit function parameters.
      Returns:
      the 2D array of benefit function parameters
      See Also:
    • formatBenefits

      public String formatBenefits(int idx)
      Return formatted string of the benefit function of trait index idx.
      Parameters:
      idx - the index of the trait
      Returns:
      the formatted string
    • payoff

      public double payoff(double[] me, double[] you)
      Calculate the payoff to the focal individual with traits me when interacting with an opponent with traits you.
      Parameters:
      me - the array of traits of the focal individual
      you - the array of traits of the opponent individual
      Returns:
      the payoff to me
    • payoff

      public double payoff(double me, double you)
      Calculate the payoff to the focal individual with trait me when interacting with an opponent with trait you.
      Parameters:
      me - the trait of the focal individual
      you - the trait of the opponent individual
      Returns:
      the payoff to me
    • costs

      protected double costs(double[] me, double[] you)
      Calculate the costs to the focal individual with traits me when interacting with an opponent with traits you.
      Parameters:
      me - the array of traits of the focal individual
      you - the array of traits of the opponent individual
      Returns:
      the costs to me
    • costs

      protected double costs(double me, double you, int trait)
      Calculate the costs to the focal individual with trait value me in trait with index trait when interacting with an opponent with trait value you.
      Parameters:
      me - the trait value of the focal individual
      you - the trait value of the opponent individual
      trait - the index of the trait
      Returns:
      the costs to me
    • benefits

      protected double benefits(double[] me, double[] you)
      Calculate the benefits to the focal individual with traits me when interacting with an opponent with traits you.
      Parameters:
      me - the array of traits of the focal individual
      you - the array of traits of the opponent individual
      Returns:
      the benefits to me
    • benefits

      protected double benefits(double me, double you, int trait)
      Calculate the benefits to the focal individual with trait value me in trait with index trait when interacting with an opponent with trait value you.
      Parameters:
      me - the trait value of the focal individual
      you - the trait value of the opponent individual
      trait - the index of the trait
      Returns:
      the benefits to me