Professional Documents
Culture Documents
By
19BCE1148 MUSKAN DHINGRA
19BCE1769 POOJA SARAVANAN
BACHELOR OF TECHNOLOGY
IN
COMPUTER SCIENCE AND ENGINEERING
Submitted to
Dr R. Rajalakshmi
School of Computer Science and Engineering
November 2020
2
ACKNOWLEDGEMENT
We also take this opportunity to thank all the faculty of the School for their
support and their wisdom imparted to us throughout the courses.
We thank our parents, family, and friends for bearing with us throughout
the course of our project and for the opportunity they provided us in
undergoing this course in such a prestigious institution.
4
BONAFIDE CERTIFICATE
Dr. R. Rajalakshmi
School of Computer Science and Engineering (SCOPE)
5
TABLE OF CONTENTS
1 Abstract 6
2 Introduction 7
3 Algorithm 8
5 Literature Survey 10
6 Modules 11
7 Website Snippets 12
8 Code 14
9 Motivation 22
11 Individual contributions 23
12 Conclusion 24
13 Reference 25
6
ABSTRACT
The Stable Marriage Problem states that given N men and N women, where
each person has ranked all members of the opposite sex in order of
preference, marry the men and women together such that there are no two
people of opposite sex who would both rather have each other than their
current partners. If there are no such people, all the marriages are “stable”.
Colleges and sent the entire list of preferences to these Colleges. Colleges
that received the application could see a student’s entire list of preferences
as well as where they ranked on the list. These Colleges would then decide
to accept, reject, or waitlist these students. In this process, some students
would get multiple offers and some would get none. After offers were
extended, and applicants accepted no more than one offer, the process would
be repeated two more times with the same preference lists. The Colleges that
still had room would extend new offers.
7
INTRODUCTION
The “stable marriage” problem is often described as follows. There are n men
and n women; each of the men has an order of preference on the women, and
each of the women has an order of preference on the men. A “matching” of
the people into n man-woman pairs is said to be unstable if there exist some
man and some woman who both prefer each other to their partner in the
matching. If there is no such pair, the matching is stable. At the beginning, all
the men and all the women are unpaired. In each round of the algorithm, take
each man in turn. If he is currently unpaired, he “proposes” to the woman
highest on his preference list that he has not before proposed to. If she is
unpaired, or if she prefers him to the man she is currently paired to, she
“accepts” (provisionally) the proposal, and they are paired together (her
current partner, if any, becomes unpaired). Continue for as many rounds as
necessary until no one is unpaired, then output the resulting matching.
The “college matching problem” is described as follows. First, each
student applies to their most preferred UNIVERSITY, and each university
rejects unranked applicants and retains its highest ranked applicants. The
rejected students then apply to their next highest preference, and the
process repeats until no rejections are issued by the colleges. Because no
student gets multiple offers, it makes room for more students to get offers.
In this specific algorithm, the students are the ones to propose, so they end
up with a better outcome than if the universities proposed. This makes
stating true preferences a dominant strategy for students.
Is it so that some more powerful model may allow for faster
algorithms?
While many “natural” algorithms for stable marriage do fit into these models,
there may be others that do not. Indeed, there exist problems for which
“computationally unnatural” operations, such as various types of hashing,
arithmetic operations, or even “cognitively natural” operations such as
processing through a neural network, do give algorithmic speedups.
The real question is: Can they do better than deterministic ones?
This question is especially fitting for the stable marriage problem as the
expected running time is known to be small when the preferences are chosen
uniformly at random.3 We give a negative answer to both hopes, as well as
several other related problems, thereby showing that answering a wide
variety of basic questions related to stable marriages requires a quadratic
number of queries (that is, requires querying nearly the entire preference
structure)
8
ALGORITHM
{
int s
for s=0 to total student
If sFree[s]==false
break;
for i=0 to total university && sFree[s]==false
select university = Sp[s][i];
if(there are slots available for current university)
decrease slot
add element to linked list [current university]
free the student
break;
if(no slots)
if(current student is more preferred by any other previous
admitted student)
free the student
LITERATURE SURVEY
This book probes the stable marriage problem and its variants as a rich
source of problems and ideas that illustrate both the design and analysis of
efficient algorithms. It covers the most recent structural and algorithmic
work on stable matching problems, simplifies and unifies many earlier
proofs, strengthens several earlier results, and presents new results and
more efficient algorithms.
Challenges faced:
MODULES
WEBSITE-SNIPPETS
13
14
CODES
int main()
{
int ta;
printf("Enter number of test cases:\n");
scanf("%d",&ta);
while(ta--)
{
int n;
printf("\nEnter number of men or women:\n");
scanf("%d",&n);
int man2[n];
int man[n][n];
int women [n][n];
int man_ma[n],wom_ma[n];
int t;
printf("\nEnter table of preferences for women:\n");
for(int i=0;i<n;i++)
{
man2[i]=0;
scanf("%d",&t);
for(int j=0;j<n;j++)
{
scanf("%d",&women[t-1][j]);
women[t-1][j]--;
}
}
while(man1>0)
{
for(int i=0;i<n;i++)
{
if(man_ma[i]==-1)
{
while(1)
{
if(wom_ma[man[i][man2[i]]]==-1)
{
man_ma[i]=man[i][man2[i]];
wom_ma[man[i][man2[i]]]=i;
man1--;
man2[i]++;
break;
}
else
{
int rank1,rank2;
for(int k=0;k<n;k++)
{
if(women[man[i][man2[i]]][k]==wom_ma[man[i][man2[i]]])
rank1=k;
if(women[man[i][man2[i]]][k]==i)
rank2=k;
}
if(rank1>rank2)
{
man_ma[wom_ma[man[i][man2[i]]]]=-1;
wom_ma[man[i][man2[i]]]=i;
man_ma[i]=man[i][man2[i]];
man2[i]++;
break;
}
man2[i]++;
}
}
}
}
printf("The match is:\n");
for(int i=0;i<n;i++)
{
printf("%d %d\n",i+1,man_ma[i]+1);
}
}
return 0;
}
16
OUTPUT:
17
#include <iostream>
#include <stdio.h>
//Student Preferences
int Sp[Total_Student][Total_University]={
{1,0},
{1,0}
};
//University Preferences
int Up[Total_University][Total_Student]={
{1,0,2},
{0,2,1}
};
18
class list
{
private:
node *head, *tail;
public:
list()
{
head=NULL;
tail=NULL;
}
void addElement(int value)
{
node *temp=new node;
temp->data=value;
temp->next=NULL;
if(head==NULL)
{
head=temp;
tail=temp;
temp=NULL;
}
else
{
tail->next=temp;
tail=temp;
}
}
void display()
{
node *temp=new node;
temp=head;
while(temp!=NULL)
{
cout<<"S"<<temp->data<<"\t";
temp=temp->next;
}
}
if(i==index)
return temp->data;
i++;
temp=temp->next;
}
}
int length(){
node *temp=new node;
temp=head;
int i=0;
while(temp!=NULL)
{
i++;
temp=temp->next;
}
return i;
}
};
int freeStudent;
bool sFree[Total_Student];
int u_slot[Total_University];
void initialize(){
for(int i=0;i<Total_Student;i++){
sFree[i]=false;
u_slot[i] = U_Slot[i];
20
freeStudent = Total_Student;
}
return U_to_S.getIndexByValue(maxElement);
}
}
}
int main()
21
initialize();
list U_to_S[Total_University];
if(u_slot[selectedUniversity] == 0){
if(currentPrefersMoreThanPrevious(U_to_S[selectedUniversity],s,selectedUniversity)){
changePreviousToCurrent(U_to_S[selectedUniversity],s,selectedUniversity);
sFree[s]=true;
}
}
}
}
for(int i=0;i < Total_University; i++){
cout<<"University "<<i<<"- ";
U_to_S[i].display();
cout<<"\n";
}
return 0;
}
OUTPUT:
22
MOTIVATION
The motivation behind this project is to solve the situation of men and
women and as well as, the students. Also, to understand the algorithm used
in match-making. We wanted to make use of the most relevant techniques in
this modern world to solve the issue of finding colleges and as well as
someone for marriage within a matter of seconds. We tried our best to solve
the issues of students in finding the suitable universities for them, we tried
to solve this by giving a ladder for the career of students.
Normally, Gale- Shapley algorithm is used to match men and women for
marriage. In this project, we are considering two applications: marriage and
as well as university-student matchmaking. We have developed the code all
by ourselves and we have tried to solve the issue of matchmaking through
this project in seconds. Further, we have developed a front-end for the stable
marriage problem and added an aspect of user input.
23
INDIVIDUAL CONTRIBUTIONS
Muskan Dhingra:
• Developed the code for gale-Shapley
algorithm for stable marriage problem
and university-student matchmaking.
• Wrote code for the situation: If seats are
available for current university:
Decreasing the slot and hence adding the
element in the linked list and analysing
loops.
• Managed the back-end part.
Pooja Saravanan:
CONCLUSION
Gale and Shapley (1962) initiated and advanced what has grown into not
only a substantial academic literature on matching models and mechanisms,
but also an emerging empirical literature on market failure and market
organization, and a growing “economic engineering” practice of market
design.
This algorithm successfully matches the university with the student
and men with women. The result of this test is stable so that the optimal pair
formed. The Gale-Shapley algorithm determines the pair based on the weight
value of each student or men/women. If the position of the couple changes,
this means there is a new person who is more qualified. The algorithm has a
preference table that contains interest between both parties and positions.
Any installation made between candidates and positions in a set can be said
to be the allocation of stable pairs. But not all preference lists are a potential
stable partner. A stable pair will be determined in the last round.
A condition will result in a separate pair because a certain student’s
rank is higher than the one previously occupying that position. Although
engagement occurs, students who do not have a partner will someday
occupy an existing position. The more preference lists, the more
candidates to occupy certain positions.
REFERENCE LINKS
[1]
https://en.wikipedia.org/wiki/Stable_marriage_problem
[2]https://www.researchgate.net/publication/22063984
2_Stable_matching_with_couples_An_empirical_study
[3]https://www.researchgate.net/publication/22073981
5_Genetic_algorithms_for_the_sailor_assignment_problem
[4]https://www.yumpu.com/en/document/read/683880
2/stable-matching-theory-evidence-and-practical-design
[5]https://web.stanford.edu/~alroth/papers/GaleandSha
pley.revised.IJGT.pdf