示例#1
0
empty = [""]
singletons = list(items)
pairs = preferences.pairs(items)
triplets = preferences.triplets(items)
quartets = preferences.quartets(items)

prefs_of_Alice = quartets + triplets + [
    "wx", "wy", "wz", "xy", "w", "xz", "yz", "x", "y", "z"
] + empty
prefs_of_Bob = quartets + triplets + pairs + ["w", "z", "x", "y"] + empty
prefs_of_Carl = quartets + triplets + pairs + ["x", "y", "w", "z"] + empty
prefs_of_Dana = quartets + triplets + pairs + singletons + empty
prefs = [prefs_of_Alice, prefs_of_Bob, prefs_of_Carl, prefs_of_Dana]
budgets = [160, 130, 90, 66]

print(
    "\nWith the preferences in the paper, there are no competitive equilibria:"
)
ce.display(ce.find_equilibrium(items, prefs, budgets))

print(
    "\nAs a control, with only the three highest-income agents, a competitive equilibrium exists:"
)
ce.display(ce.find_equilibrium(items, prefs[0:3], budgets[0:3]))

print(
    "\nWith the preferences in the paper, even a *personalized* equilibrium does not exist:"
)
ce.display(ce.find_personalized_equilibrium(items, prefs, budgets))
import competitive_equilibrium as ce
import sys, logging
if len(sys.argv) < 2 or sys.argv[1] != "quiet":
    ce.logger.setLevel(logging.INFO)

items = "xyz"

prefs_of_any_agent = ["", "x", "y", "xy", "z", "zx", "zy", "zxy"]
prefs = [prefs_of_any_agent, prefs_of_any_agent, prefs_of_any_agent]
budgets = [-7, -8, -9]

print("\nWith budgets as in the paper, there are no competitive equilibria:")
ce.display(ce.find_equilibrium(items, prefs, budgets, negative_prices=True))

print(
    "\nAs a control, if we change the budgets, there is a competitive equilibrium:"
)
alternative_budgets = [-3, -7, -15]
ce.display(
    ce.find_equilibrium(items,
                        prefs,
                        alternative_budgets,
                        negative_prices=True))

print("\nEven a *personalized* competitive equilibrium does not exist:")
ce.display(
    ce.find_personalized_equilibrium(items,
                                     prefs,
                                     budgets,
                                     negative_prices=True))
示例#3
0
by exhaustively checking all allocations.

See Appendix D, Example 4

AUTHOR: Erel Segal-Halevi
SINCE:  2019-08
"""

import preferences
import competitive_equilibrium as ce
import sys, logging
if len(sys.argv)<2 or sys.argv[1]!="quiet":
    ce.logger.setLevel(logging.INFO)


items = "xyz"
prefs_of_Alice = ["xyz", "xy","yz","xz", "x","y","z", ""]
prefs_of_Bob   = ["xyz", "xy","xz","yz", "y","x","z", ""]
prefs_of_Carl  = preferences.triplets(items) + preferences.pairs(items) + list(items) + [""]
budget_of_Alice = budget_of_Bob = 4;  budget_of_Carl = 2   # or any other a,b,c such that a=b > c

print("\nWith only Alice and Bob, no competitive equilibria exists:")
ce.display(ce.find_equilibrium(items, [prefs_of_Alice, prefs_of_Bob], [budget_of_Alice, budget_of_Bob]))

print("\nWith all three agents, a competitive equilibrium exists:")
ce.display(ce.find_equilibrium(items, [prefs_of_Alice, prefs_of_Bob, prefs_of_Carl],
                               [budget_of_Alice, budget_of_Bob, budget_of_Carl]))

print("\nWith only Alice and Bob, even a *personalized* competitive equilibrium does not exist:")
ce.display(ce.find_personalized_equilibrium(items, [prefs_of_Alice, prefs_of_Bob], [budget_of_Alice, budget_of_Bob]))
示例#4
0
    ce.logger.setLevel(logging.INFO)

items = "vwxyz"

empty = [""]
singletons = list(items)
pairs = preferences.pairs(items)
triplets = preferences.triplets(items)
quartets = preferences.quartets(items)
quintuplets = [items]

triplets_except_xyz = preferences.list_difference(triplets, ["xyz"])
triplets_except_vwx_vwy_vwz_xyz = preferences.list_difference(triplets, ["vwx","vwy","vwz","xyz"])
pairs_except_vw = preferences.list_difference(pairs, ["vw"])

prefs_of_Alice = preferences.goods_to_chores(items, quintuplets + quartets + ["vwx","vwy","vwz","vw","xyz"] + triplets_except_vwx_vwy_vwz_xyz + pairs_except_vw + singletons + empty)
prefs_of_Bob   = preferences.goods_to_chores(items, quintuplets + quartets + triplets_except_xyz + ["vx","vy","vz","wx","wy","wz","xyz","vw","w","v","xy","xz","yz","x","y","z"] + empty)
budgets = [-10,-12]

print("\nWith the preferences in the paper, there are no competitive equilibria:")
ce.display(ce.find_equilibrium(items, [prefs_of_Alice, prefs_of_Bob], budgets, negative_prices=True))

print("\nAs a control, if we slightly change the preferences of Alice, there is a competitive equilibrium:")
alternative_prefs_of_Alice = preferences.goods_to_chores(items, quintuplets + quartets + ["vwx","vwy","vwz","xyz"] + triplets_except_vwx_vwy_vwz_xyz + pairs + singletons + [""])
alternative_prefs_of_Bob   = prefs_of_Bob
ce.display(
    ce.find_equilibrium(items, [alternative_prefs_of_Alice, alternative_prefs_of_Bob], budgets, negative_prices=True))

print("\nWith the original preferences, even a *personalized* competitive equilibrium does not exist.")
ce.display(ce.find_personalized_equilibrium(items, [prefs_of_Alice, prefs_of_Bob], budgets, negative_prices=True))