top trading cycle project report

7

Click here to load reader

Upload: kartikaybansal8825

Post on 01-Jun-2018

215 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Top Trading Cycle Project Report

8/9/2019 Top Trading Cycle Project Report

http://slidepdf.com/reader/full/top-trading-cycle-project-report 1/7

 Top Trading Cycle

Top Trading Cycle

Computer Programming 271 Mini-project report 

Geetanjali Rohilla, Kritika Mittal, Lalit Sethia and Madhu Kiran

Abstract

This project endeavours to provide an efficient solution*  to finite objects allocation where

individual agents have well defined strict preference order (preference order over these objects

and capacit! to absorb the"# This is co""onl! known as $ne%Sided Matching (as the objects in

 pla! do not have preferences over the agents# This solution is based on work done b! Roth,

Shapel! and others# &e have used '!thon progra""ing language to co"e up with a code, which

when provided with set of agents, their corresponding preference order over objects (with

individual hierarch! of ownership and their capacities, returns an efficient solution of allocation

of objects to the agents#

1. Introduction:

llocating indivisible objects or tasks a"ong co"peting agents is a classical econo"ic proble"#

The objects can be houses, jobs, project, positions, transfer locations, etc# )or e*a"ple, project

allocation of + projects to groups, where each group has a capacit! of -, preference order of 

these + projects and a rando"l! generated hierarch! of ownership over these projects..#

Most "ethods for finding efficient solutions are variants of two algorith"s, top trading c!cle

algorith" and deferred acceptance algorith"# &e shall be using the for"er#

/n the following subsection, we present the related literature#

1.1 Relationship to the literature

This report relies on the e*tensive work done in the field of stable allocations and the practice of

"arket design# Shaple! and Gale 0-1234 introduced the idea of allocation of indivisible objects to

agents with preferences over the" and vice versa using college admission and stability of

marriage problems as e*a"ples# )urther, Shaple! and Scarf 0-154 investigated the econo"ic

"odel of trading in si"ilar indivisible co""odities, like houses, fro" a ga"e%theoretic point of

view and concluded that the "arket in 6uestion has a none"pt! core (set of allocations which are

not strongl! do"inated, that is, at least one outco"e that no subset of traders can i"prove upon#Roth and 'ostlewaite 0-124 e*tended Shaple! and Scarf7s result which depends on the core

 being defined in ter"s of strong rather than weak do"ination and pointed out several other

i"plications of the differences between strong and weak do"ination in this t!pe of "arket ga"e#

/n -118 Roth and Soto"a!or presented a unified treat"ent of a class of two%sided "atching

"odels (both discrete and continuous#

Page 2: Top Trading Cycle Project Report

8/9/2019 Top Trading Cycle Project Report

http://slidepdf.com/reader/full/top-trading-cycle-project-report 2/7

 Top Trading Cycle

The rest of the report is organi9ed as follows# &e present the proble" state"ent in section 3, the

"ethodolog! used along with e*planation to ke! aspects of the code in Section : followed b! a

test si"ulation of the code on a si"ple allocation in Section 5 and the entire code has been

 provided as an appendi* to the report#

2. Problem Statement:

There is a finite set of objects M = {a1, a 2, a , ! ! ! ! , a m " and finite set of agents # = {1, ! ! ! ,n" with

corresponding capacities ; < {c1 ,! ! ! ,cm "# The preference ordering of agent i will be denoted as

>i# profile of preference will be denoted as >≡(>- , # # # ,  >n# n alternative is a  feasible

matc$ing, i#e, a "apping fro"  #   to  M, given ;# gents do not have direct preference over 

alternatives# &e e*tract their preferences over alternatives fro" their preferences over objects#

Given M, =, ; and >, we need to find an efficient allocation defined as follows>

Deinition 2.!: n allocation is efficient if ∄ another allocation ? ≠ , such that ?(i >i (i

or ?(i = (i ∀ i ∈N (where A(i) is the allocation to the ith agent in A)

". #ethodology:

&e shall solve the above stated proble" state"ent using the following algorith"#

Step 1: @ach agent Apoints toB the owner of her favorite house (object of interest# Since there

are finite no# of agents, there is at least one c!cle # @ach agent in a c!cle is assigned the house of 

the agent she points to and re"oved fro" the "arket with her assign"ent if the nu"ber of 

houses allocated to her e6uals her capacit!# /f nu"ber of houses allocated to the agent does not

e6ual her capacit! then the house allocated to her is re"oved fro" the "arket while the agent

continues to be a part of the following round. /f there is at least one re"aining agent, proceedwith the ne*t step#

Step t> @ach re"aining agent (after t%- steps points to the owner of her favorite house a"ong

the re"aining houses# @ver! agent in a c!cle is assigned the house of the agent he points to and

re"oved fro" the "arket with his assign"ent# /f nu"ber of houses allocated to the agent does

not e6ual her capacit! then the house allocated to her is re"oved fro" the "arket while the agent

continues to be a part of the following round# /f there is at least one re"aining agent, proceed

with the ne*t step#

The "ethodolog! of the algorith" will be e*plained better in Section 5 using the above

"entioned e*a"ple of project allocation of ;o"puter progra""ing 3- "ini%projects with one

capacity constraint.

Page 3: Top Trading Cycle Project Report

8/9/2019 Top Trading Cycle Project Report

http://slidepdf.com/reader/full/top-trading-cycle-project-report 3/7

 Top Trading Cycle

$. Simulation:

Agents

%roup A %roup & %roup C %roup D %roup ' %roup ( %roup %

Me"# - Geet @ktatiger rpit Manish Sheekha Rajas kanksha

Me"# 3 Krit Raneji Sid 'alu $ja99 Srutiji =ishaMe"# : Lalit Sourav 'raveen Shidantho Cash Srishti nindita

Me"# 5 Mad%hun

Preerence

%roup A %roup & %roup C %roup D %roup ' %roup ( %roup %

Choice 1 Leel AccCorrelated

Leel Acc!e"Crawl

Leel Acc!e"Crawl

Leel Acc

Choice # $hapley $hapley!e"Crawl

$hapley $hapley TTC %ash

Choice & TTC %ashCorrelated

%ash %ash %ash $hapley

Choice '

echanis

echanis

$hapley

echanis

Correlate

d Leel Acc

Correlate

d

Choice * $+do,+ TTC %ash TTCechanis

$hapley $+do,+

Choice -!e"Crawl

$+do,+ TTCCorrelated

 TTC $+do,+ TTC

Choice . %ash Leel Accechanis

$+do,+ $+do,+echanis

!e"Crawl

Choice /Correlated

!e"Crawl

$+do,+ Leel Acc!e"Crawl

Correlated

echanis

)ierarchy o *+nerships o Pro,ects

!e"Cra

wl

%ash $hapleyCorrelat

ed

$+do,+Leel

Acc

echani

s

 TTC

- ) D G ; E G E

3 D G ) ) ) ; @ G

: G ) ; @ D D D ;

5 ; @ D D ) G @

F E ; E E G @ ; D

2 @ G ; E ) )

@ E @ E

The above proble" proceeds as follows>

Step 1: $bserve that Group ?s -st preference is Level cc# which is owned at the current stage

 b! Group G as per ?ierarch! of $wnerships of 'rojects?# Group G?s -st preference is Level cc#

which it owns along with Shapel! (which is irrelevant for the current c!cle# This co"pletes

c!cle - as Group G gets (owns in this case its -st preference as seen in the figure below# Thus

re"oving Group G and Level cc# fro" future stages of the allocation process#

Page 4: Top Trading Cycle Project Report

8/9/2019 Top Trading Cycle Project Report

http://slidepdf.com/reader/full/top-trading-cycle-project-report 4/7

 Top Trading Cycle

Step 2:  $bserve that Group ?s -st preference has been

allocated and so the! "ove to their 3nd preference, i#e Shaple!, which is owned no% b! Group )

as per ?ierarch! of $wnerships of 'rojects?# Group )?s -st preference is &eb;rawl which it

owns along with Shapel!# This co"pletes c!cle 3 as Group ) gets (owns in this case its -st

 preference as seen in the figure below# Thus re"oving Group ) and &eb;rawl fro" future stages

of the allocation process#

(rom the abo-e steps the proceeding steps o the allocation process can be easily deduced

as sho+n (igure $."

Figure

Figure

Step 4

Step 3

Step 2 Step 7

Step 6Step 1

Figure

Step 5

Page 5: Top Trading Cycle Project Report

8/9/2019 Top Trading Cycle Project Report

http://slidepdf.com/reader/full/top-trading-cycle-project-report 5/7

 Top Trading Cycle

&ibliography>

-# Gale, E# and L# S# Shaple! (-123, A;ollege d"issions and the Stabilit! of Marriage,B

"erican Mathe"atical Monthl! 21, 1%-F#

3# Shaple!, L# S# and # @# Scarf (-15,A$n ;ores and /ndivisibilit!,B Hournal of Mathe"atical@cono"ics -, 3:%3+#

:# Roth, #@# and # 'ostlewaite (-1, A&eak versus Strong Eo"ination in a Market for/ndivisible Goods,B Hournal of Mathe"atical @cono"ics 5,-:-%-:#

5# Roth, # @# and M# Soto"a!or (-118, Two%Sided Matching> Stud! in Ga"e%Theoretic

Modeling and nal!sis, ;a"bridge Iniversit! 'ress, ;a"bridge#

Page 6: Top Trading Cycle Project Report

8/9/2019 Top Trading Cycle Project Report

http://slidepdf.com/reader/full/top-trading-cycle-project-report 6/7

 Top Trading Cycle

Appendi/>

fro" pandas i"port Series, Eata)ra"e

 pla!erMap < dict(J->??,3>?D?,:>?;?,5>?E?,F>?@?,2>?)?,>?G?

objectMap < dict(J->?&eb ;rawl?,3>?=ash?,:>?Shaple!?,5>?;orrelated?,F>?Sudoku?,2>?Levelcc?,>?Mechanis"?,+>?TT;?

 preferences < J- > 02,:,+,,F,-,3,54,

  3 > 05,:,3,,+,F,2,-4,

  : > 02,-,5,:,3,+,,F4,

  5 > 0-,:,3,,+,5,F,24,

  F > 02,:,3,5,,+,F,-4,

  2 > 0-,+,3,2,:,F,,54,

  > 02,3,:,5,F,+,-,4

 preferencesE) < Eata)ra"e(preferences,inde*<0-,3,:,5,F,2,,+4

 print preferencesE)

ownershipierarch! < J- > 02,3,,:,5,-,F4,

  3 > 03,,2,F,:,-,54,

  : > 0,2,:,3,5,F,-4,

  5 > 0:,2,F,3,5,,-4,

  F > 05,2,3,-,,:,F4,

  2 > 0,:,3,2,F,5,-4,

  > 05,F,3,,:,2,-4,

  + > 0-,,:,F,3,2,54

ownershipierarch!E) < Eata)ra"e(ownershipierarch!, inde*<0-,3,:,5,F,2,4

 print ownershipierarch!E)

def find;!cle(preferencesE),ownershipierarch!E)>

  c!cle;heckList < 04

  current'erson < preferencesE)#colu"ns#values084  allocationMap < J

  while current'erson not in c!cle;heckList>

  )inding preference of current person

  current'erson'reference < 8

  for preference in preferencesE)0current'erson4>

  if preference N< %->

  current'erson'reference < preference

  break 

 

)inding owner of current person?s preference

  owner$f;urrent'erson'reference < 8

  for owner in ownershipierarch!E)0current'erson'reference4>

  if owner N< %->  owner$f;urrent'erson'reference < owner 

  break 

 

allocationMap0current'erson4 < current'erson'reference

Page 7: Top Trading Cycle Project Report

8/9/2019 Top Trading Cycle Project Report

http://slidepdf.com/reader/full/top-trading-cycle-project-report 7/7

 Top Trading Cycle

  c!cle;heckList#append(current'erson

  current'erson < owner$f;urrent'erson'reference 

c!cle;heckList#append(current'erson

  return c!cle;heckList0c!cle;heckList#inde*(current'erson>%-4

def getllocationMap)or'ersons(c!cle>  personTollocationMap < J

  for person in c!cle>

  for preference in preferencesE)0person4>

  if preference N< %->

  personTollocationMap0person4 < preference

  break 

  return personTollocationMap

def "odif!Eata)ra"es(preferencesE),ownershipierarch!E),personTollocationMap>

  for person in personTollocationMap#ke!s(>

  del preferencesE)0person4  for i in range(-,len(ownershipierarch!E)#colu"nsO->

  for j in range(-,len(ownershipierarch!E)#inde*O->

  if ownershipierarch!E)0i40j4 << person>

  ownershipierarch!E)0i40j4 < %-

 

for allocation in personTollocationMap#values(>

  for i in preferencesE)#colu"ns#values>

  for j in range(-,len(preferencesE)#inde*O->  if preferencesE)0i40j4 << allocation >

  preferencesE)0i40j4 < %-

finalllocationMap < Jno$f'ersons <

while len(finalllocationMap#ke!s( P no$f'ersons>

  c!cle < find;!cle(preferencesE),ownershipierarch!E)

  allocation < getllocationMap)or'ersons(c!cle

  finalllocationMap#update(allocation

  "odif!Eata)ra"es(preferencesE),ownershipierarch!E),allocation

 

finalllocationMap&ith=a"es < J

for i in finalllocationMap#ke!s(>  finalllocationMap&ith=a"es0pla!erMap0i44 < objectMap0finalllocationMap0i44

 print Series(finalllocationMap&ith=a"es