根据偏好的相似性将两个元素(人)匹配在一起

发布于 2024-12-16 14:55:26 字数 197 浏览 3 评论 0原文

我正在规划一个网站,该网站将定期将两个用户匹配在一起。

池中的每个人都会有几个在匹配过程中使用的偏好,例如他们喜欢什么类型的音乐以及一周中的哪几天可以听。出于本项目的目的,如果偏好特定,我想分配更高的权重/匹配优先级;也就是说,两个只喜欢“科幻小说”的人比简单地将两个勾选“以上所有”的人放在一起更好。我认为标准的贪婪匹配算法可能会起作用,但是有没有更有效的算法?

I'm in the planning stages of a website that will match two users together periodically.

Each person in the pool will have several preferences that are used in the matching process, e.g. what genres of music they like and which days of the week they are available. For the purposes of this project, I'd like to assign higher weight/match priority if the preferences are specific; i.e. two people who ONLY like 'science fiction' are a better match than simply putting together two people who checked off 'all of the above'. I'm thinking that a standard greedy matching algorithm would probably work, but is there any algorithm out there that is more efficient?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

丶视觉 2024-12-23 14:55:26

事情没那么简单,您需要创建一个实用函数,让您知道哪个更匹配。例如,哪个会更好:

(1) 一对非常匹配,另一对则非常差。

(2) 两对,平均匹配。

我建议使用一些经过充分验证的人工智能工具来解决这个问题。

首先,一些定义:

  • P={所有人}
  • S={匹配所有人的所有可能性}
  • u:PxP->R< /code> 是一对的评分函数:u(p1,p2)=their
    匹配得分
    [当然取决于您的数据]
  • U:S->R 为整个匹配的评分函数:U(aMatch)
    = Sigma(u(p1,p2)) 对于每对配对
  • next:S->2^S 为: next(S)={所有可能的匹配
    与 S 不同,仅交换两个人}

现在,根据上述定义,您可以使用 最陡爬山遗传算法,它们是经过验证的人工智能工具,用于获取一个好的结果。

最速爬坡[SAHC]很简单,从随机匹配开始,做一些小的改变,直到达到无法进行局部改进的程度。该点是局部最大值,并且是最佳解决方案的候选点。使用不同的初始状态重新启动该进程。

伪代码:

1. best<- -INFINITY
2. while there is more time
3. choose a random matching
4. NEXT <- next(s)
5. if max{ U(v) | for each v in NEXT} < U(s): //s is a local maximum
   5.1. if u(s) > best: best <- 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 <- max { NEXT }
   6.2. goto 4.
7. return best //when out of time, return the best solution found so far.

注1:该算法是任何时间,这意味着你给它更多的时间,它会得到更好的结果。如果你的时间->无穷大,算法最终会找到最优解。

注2:效用函数U只是一个建议,您也可以使用max{u(p1,p2) |对于匹配中的每一对},或您认为合适的任何其他实用函数。

编辑:

即使是更简单的问题,即:两个人可以简单地“匹配”或“不匹配”[u(p1,p2)=0u(p1,p2)= 1]实际上是最大匹配问题,是NP-Hard,因此这个问题没有已知的多项式解决方案,并且有一个启发式的解决方案可能应该使用上面建议的解决方案。

请注意,如果您的图表是二分 [即您无法将男性与男性/女性与女],这个问题可以在多项式时间内解决。详细信息:二分图中的匹配

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:

(1) one pair with excellent match, the other is terribly poor.

(2) two pairs, with an average match.

I suggest using some well proven artificial intelligence tools for this problem.

first, some definitions:

  • P={all persons}
  • S={all possibilities to match all people}
  • let u:PxP->R be a scoring function for a pair: u(p1,p2)=their
    score as a match
    [depends on your data of course]
  • let U:S->R be a scoring function for the whole matching: U(aMatch)
    = Sigma(u(p1,p2)) for each paired couple
    .
  • let next:S->2^S be: next(S)={all possible matchings which are
    different from S by swapping two people only}

Now, with the above definition you can use steepest ascent hill climbing or a genethic algorithm, which are proven Artificial Intelligence tools for getting a good result.

Steepest Ascent Hill Climbing [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.

pseudo code:

1. best<- -INFINITY
2. while there is more time
3. choose a random matching
4. NEXT <- next(s)
5. if max{ U(v) | for each v in NEXT} < U(s): //s is a local maximum
   5.1. if u(s) > best: best <- 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 <- max { NEXT }
   6.2. goto 4.
7. return best //when out of time, return the best solution found so far.

Note1: that this algorithm is anytime, 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.

Note2: the utility function U is just a suggestion, you could also use max{u(p1,p2) | for each pair in the match}, or any other utility function you find fits.

EDIT:

Even the simpler problem, which is: two people can simply "match" or "not match" [u(p1,p2)=0 or u(p1,p2)=1] is actually the maximal matching problem, which is NP-Hard, thus there is no known polynomial solution for this problem, and a heuristical solution, such as suggested above should probably be used.

Note that if your graph is bipartite [i.e. you cannot match male with male/female with female], this problem is solveable in polynomial time. More info: matching in bipartite graphs

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文