@@ -0,0 +1,1695 @@
+package stableMatching;%0Aimport java.util.Map;%0A/** Creates a stable matching by running the deferred acceptance algorithm (Gale-Shapely).%0A *  Assumes m-proposing, but has the option to make w-proposing.%0A * @author Alan Ponte%0A */%0Apublic class StableMatching %7B%0A%09%0A%09/** Creates a new matching with the preferences of the men, MPREFS,%0A%09 * and the preferences of the woman, WPREFS.*/%0A%09public StableMatching(Map%3CAgent, Integer%3E mPrefs, Map%3CAgent, Integer%3E wPrefs) %7B%0A%09%09_mPrefs = mPrefs;%0A%09%09_wPrefs = wPrefs;%0A%09%7D%0A%09%0A%09/** Creates a new matching with the preferernces of the men, MPREFS,%0A%09 *  and the preferences of the women, WPREFS.  If M_PROPOSING is ON, %0A%09 *  then the algorithm is m_proposing.  %0A%09 */%0A%09public StableMatching(Map%3CAgent, Integer%3E mPrefs, Map%3CAgent, Integer%3E wPrefs, boolean m_proposing) %7B%0A%09%09_mPrefs = mPrefs;%0A%09%09_wPrefs = wPrefs;%0A%09%09_mProposing = m_proposing;%0A%09%7D%0A%09%0A%09/** Returns True iff the algorithm is M-Proposing.*/%0A%09public boolean m_proposing() %7B%0A%09%09return _mProposing;%0A%09%7D%0A%09%0A%09/** Performs the deferred acceptance algorithm.  Outputs the result.%0A%09 * The algorithm runs as follows:%0A%09 * Step 1:  Each man points to his most preferred woman from his%0A%09 * set of preferences.  Each woman accepts or rejects the man.%0A%09 * %0A%09 * Step k %3E= 2:  Repeat this process until a matching is found.*/%0A%09public static void runAlgorithm() %7B%0A%09%09%0A%09%09%0A%09%7D%0A%09/** If M_PROPOSING is ON, the algorithm is M-Proposing .*/%0A%09public void setMproposing(boolean m_proposing) %7B%0A%09%09%0A%09%7D%0A%09/** True iff the algorithm is m-proposing.*/%0A%09private boolean _mProposing = true;%0A%09%0A%09/** The preference list of the men.*/%0A%09private Map%3CAgent, Integer%3E _mPrefs;%0A%09%0A%09%0A%09/** The preference list of the women*/%0A%09private Map%3CAgent, Integer%3E _wPrefs;%0A%7D%0A

Create StableMatching.java