Reference 〉 Function


Calculates the agent’s utility on the basis of the quantities entered. Subclasses are required to implement this method and should call the parent function super().calculate() at the beginning. The agent.stocks dict can be passed directly to this function.

Utility.calculate() only returns the values, and is thus useful for counterfactual calculations. To actually realize utility from consumption, use Utility.consume() instead.


  • quantities dict{str:num}, required

    The quantities of the goods to be consumed. If the utility function was registered with the same set of goods as the model (see Goods.add()), agent.stocks can be passed straight into this function.

Return Value num

The utility gained from consuming the quantities in question.

Notes and Examples

  1. Contribute a Note

    Your email address will not be published. Required fields are marked *

    You may use limited HTML for formatting. Please embed blocks of code in <pre><code> </code></pre> tags.