Java Programming Assignment - I have attached code below in a download link - Th
ID: 3888304 • Letter: J
Question
Java Programming Assignment - I have attached code below in a download link - Thanks
Please do part 1 and/or part 2
Files download : https://files.fm/u/sk5ccu6j
Problem Description In this problem we will consider a version of the problem for professors and students and their fully ordered list of preferences. Please read through this document and the documentation in the starter code thoroughly before beginning The Stable Matching Problem, as discussed in the text, assumes that all men and women have a fully ordered list of preferences. In this problem we will consider a version of the problem for professors and students and their fully ordered list of preferences. Note that ties in preference lists are not allowed. As before we have a set P of n professors and a set S of n students. Assume each professor and each student ranks the members of the opposite group. Part 1: Implement a Brute Force Solution [30 points A brute force solution to this problem involves generating all possible permutations of men and women, and checking whether each one is a stable matching, until a stable matching is found. For this assignment, you are provided with Preferences.java class which includes the necessarry input structures for the problem. Please see the comments in Preferences.java file for details. You are also given Assignment1.java file where you will put your implementation for this part under stableMatchBruteForce) function which returns ArrayList. This ArrayList should contain information for matching information representing the index of student matched with a professor, -1 is not matched. For example, if ith element of the returned ArrayList is j, than professor i is matched with student j. There might be a stable matching which is neither professor nor student optimal. This is because in a brute force, you are trying to find all possible stable matches. Part 2: Implement Gale-Shapley Algorithm [40 points In order to solve this matching problem more efficiently, you need to implement Gale-Shapley Al gorithm and give a solution for Professors Optimal Matching. For implementation, we provide you with again with Preferences.java and you will put your implementation to Assignment1.java file under stableMatchGaleShapley). This algorithm is discussed in the class, so you can useExplanation / Answer
/**
* Class to implement Stable Matching algorithms
*/
import java.util.ArrayList;
public class Assignment1 {
// Part1: Implement a Brute Force Solution
public static ArrayList<Integer> stableMatchBruteForce(Preferences preferences) {
}
// Part2: Implement Gale-Shapley Algorithm
public static ArrayList<Integer> stableMatchGaleShapley(Preferences preferences) {
}
// Part3: Matching with Costs
public static ArrayList<Cost> stableMatchCosts(Preferences preferences) {
}
}
/**
* Cost object for Assignment 1 - Part 3
* This object helps you to return 4 fields at once.
* The meaning of cost is described in the assignment.
*/
public class Cost {
private int indexOfProfessor;
private int indexOfStudent;
private int costToProfessor;
private int costToStuent;
public Cost(int indexOfProfessor, int indexOfStudent, int costToProfessor, int costToStuent) {
this.indexOfProfessor = indexOfProfessor;
this.indexOfStudent = indexOfStudent;
this.costToProfessor = costToProfessor;
this.costToStuent = costToStuent;
}
public int getIndexOfProfessor() {
return indexOfProfessor;
}
public void setIndexOfProfessor(int indexOfProfessor) {
this.indexOfProfessor = indexOfProfessor;
}
public int getIndexOfStudent() {
return indexOfStudent;
}
public void setIndexOfStudent(int indexOfStudent) {
this.indexOfStudent = indexOfStudent;
}
public int getCostToProfessor() {
return costToProfessor;
}
public void setCostToProfessor(int costToProfessor) {
this.costToProfessor = costToProfessor;
}
public int getCostToStuent() {
return costToStuent;
}
public void setCostToStuent(int costToStuent) {
this.costToStuent = costToStuent;
}
}
import java.util.ArrayList;
/**
* Class to provide input to Stable Matching algorithms
*/
public class Preferences {
/** Number of professors. */
private int numberOfProfessors;
/** Number of students. */
private int numberOfStudents;
/** A list containing each professor's preference list. */
private ArrayList<ArrayList<Integer>> professors_preference;
/** A list containing each student's preference list. */
private ArrayList<ArrayList<Integer>> students_preference;
public Preferences(int numberOfProfessors, int numberOfStudents,
ArrayList<ArrayList<Integer>> professors_preference,
ArrayList<ArrayList<Integer>> students_preference) {
this.numberOfProfessors = numberOfProfessors;
this.numberOfStudents = numberOfStudents;
this.professors_preference = professors_preference;
this.students_preference = students_preference;
}
public int getNumberOfProfessors() {
return numberOfProfessors;
}
public void setNumberOfProfessors(int numberOfProfessors) {
this.numberOfProfessors = numberOfProfessors;
}
public int getNumberOfStudents() {
return numberOfStudents;
}
public void setNumberOfStudents(int numberOfStudents) {
this.numberOfStudents = numberOfStudents;
}
public ArrayList<ArrayList<Integer>> getProfessors_preference() {
return professors_preference;
}
public void setProfessors_preference(ArrayList<ArrayList<Integer>> professors_preference) {
this.professors_preference = professors_preference;
}
public ArrayList<ArrayList<Integer>> getStudents_preference() {
return students_preference;
}
public void setStudents_preference(ArrayList<ArrayList<Integer>> students_preference) {
this.students_preference = students_preference;
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.