Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It is not that simple, you need to create a utility function that lets you know which is better matching. For example, which will be better: <br>(1) one pair with excellent match, the other is terribly poor. <br>(2) two pairs, with an average match.</p> <p>I suggest using some well proven <a href="http://en.wikipedia.org/wiki/Artificial_intelligence" rel="nofollow">artificial intelligence</a> tools for this problem. <br>first, some definitions: </p> <ul> <li><code>P={all persons}</code> </li> <li><code>S={all possibilities to match all people}</code></li> <li>let <code>u:PxP-&gt;R</code> be a scoring function for a pair: <code>u(p1,p2)=their score as a match</code> [depends on your data of course]</li> <li>let <code>U:S-&gt;R</code> be a scoring function for the whole matching: <code>U(aMatch) = Sigma(u(p1,p2)) for each paired couple</code>.</li> <li>let <code>next:S-&gt;2^S</code> be: <code>next(S)={all possible matchings which are different from S by swapping two people only}</code></li> </ul> <p>Now, with the above definition you can use <a href="http://en.wikipedia.org/wiki/Hill_climbing#Variants" rel="nofollow">steepest ascent hill climbing</a> or a <a href="http://en.wikipedia.org/wiki/Genetic_algorithm" rel="nofollow">genethic algorithm</a>, which are proven Artificial Intelligence tools for getting a good result.</p> <p><strong>Steepest Ascent Hill Climbing</strong> [SAHC] is simple, start with as random matching, and make a small change, until you reach a point where you cannot make a local improvement. This point is a local maximum, and a candidate to be the best solution. restart the process with a different initial state. <br>pseudo code:</p> <pre><code>1. best&lt;- -INFINITY 2. while there is more time 3. choose a random matching 4. NEXT &lt;- next(s) 5. if max{ U(v) | for each v in NEXT} &lt; U(s): //s is a local maximum 5.1. if u(s) &gt; best: best &lt;- u(s) //if s is better then the previous result - store it. 5.2. go to 2. //restart the hill climbing from a different random point. 6. else: 6.1. s &lt;- max { NEXT } 6.2. goto 4. 7. return best //when out of time, return the best solution found so far. </code></pre> <p><strong>Note1:</strong> that this algorithm is <a href="http://en.wikipedia.org/wiki/Anytime_algorithm" rel="nofollow">anytime</a>, which means it will get better results as you give it more time. and if your time->infinity, the algorithm will eventually find the optimal solution. <br><strong>Note2:</strong> the utility function <code>U</code> is just a suggestion, you could also use <code>max{u(p1,p2) | for each pair in the match}</code>, or any other utility function you find fits.</p> <p><strong>EDIT:</strong> <br>Even the simpler problem, which is: two people can simply "match" or "not match" [<code>u(p1,p2)=0</code> or <code>u(p1,p2)=1</code>] is actually the <a href="http://en.wikipedia.org/wiki/Matching_%28graph_theory%29#Maximal_matchings" rel="nofollow">maximal matching problem</a>, which is <a href="http://en.wikipedia.org/wiki/NP-hard" rel="nofollow">NP-Hard</a>, thus there is no known polynomial solution for this problem, and a heuristical solution, such as suggested above should probably be used. <Br>Note that if your graph is <a href="http://en.wikipedia.org/wiki/Bipartite_graph" rel="nofollow">bipartite</a> [i.e. you cannot match male with male/female with female], this problem is solveable in polynomial time. More info: <a href="http://en.wikipedia.org/wiki/Matching_%28graph_theory%29#Maximum_matchings_in_bipartite_graphs" rel="nofollow">matching in bipartite graphs</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload