Homework 3, A Sable Match.

Short Description:

Write and test a program that will perform stable matching.

This assignment is worth 80 points.

Goals

When you finish this homework, you should have:

Formal Description

Implement the Gale Shapley algorithm to find a stable match in a dataset. Your program should be implemented with women proposing to men.

Input

Your input should come from a file. The file name will be specified as argv[1] and will contain The file data1 is an valid example input file corresponding to one of the examples from class.

You do not need to be overly concerned about the file name, the following code should be sufficient to open the file:

int main(int argc, char * argv[]) {
     ifstream inFile;
     if (argc !=2 ) {
         cout << argv[0] << " datafile" << endl;
         return 1;
     } else {
         inFile.open(argv[1]);
     } 
You may rearrange this code to meet your style preferences.

Your program should find a stable match and print that to standard out in the following format:

An example output file is MatchData1 but this was produced by the men proposing from data1 above, so you might not get this result. In fact, I am pretty sure the last two matches should be different.

I have written a program that checks to see that a match is stable. The executable is located at ~dbennett/385/hw3/checker on cslab103. This executable is compiled to run on this platform and will probably not run elsewhere. The command line arguments are the match file and the datafile, where the match file is the output of the stable match program and the data file is the input to the stable match program.

 
./checker MatchData1  data1

If all is well, checker exits silently. If there is a problem it reports the first unstable match it finds. This program may not be completely correct, and will probably break under extreme test conditions.

This directory also contains code for a data set generator called maker.cpp. This program takes a single command line argument, the size of the input, and produces a random test case.

Timing your code

I used the following additions to my program to produce the time taken by the GS function
#include <chrono>
     auto start = chrono::high_resolution_clock::now();
     GS(men, women);
     auto end = chrono::high_resolution_clock::now();
     chrono::duration<double> diff = end - start;
     cerr << diff.count() << " " ; 

I printed to cerr so the output does not get written to the output file on redirection.

To perform the timing tests, I used a script called runner.sh this is a bash script and it will run your program over a set of input values. Be cautioned this will take a while. I run the script with:

bash runner.sh > time.txt
This will produce a file time.txt. Each line begins with the size of the input file and then has the time results for 40 runs at each size. You may need to add ./ before program names, remember I have that automated in my shell. Runner.sh assumes that your program is called stable. You can call the program whatever you wish, but you need to edit runner.sh and change the name.

Using runner will produce a set of files called data.nnnIN and data.nnnOUT, the results of the maker and stable program.

If you have problems with the previous section, please see me. This will take some time so please do not let this for 11:00pm on the due date.

Analysis of your run should be performed in a spreadsheet. You should

Create a word document and

Discussion

Required Files A single tar or zip file containing the source code, Makefile, spreadsheet, and word document for this program.

Submission

Submit the assignment to the D2L folder homework 3 by the due date.