简体   繁体   中英

Php&MySQL Matchmaking Algorithm With Score

i'm thinking how can i matchmaking with PHP and MySQL but I can not find.

For example we have a mysql users table and users set some setting their profiles and we macth profiles with percentage.

Our simple mysql table:

CREATE TABLE IF NOT EXISTS `users` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `username` varchar(255) NOT NULL DEFAULT '',
  `password` varchar(255) NOT NULL DEFAULT '',
  `email` varchar(255) NOT NULL DEFAULT '',
  `gender` enum('M','F') NOT NULL DEFAULT 'M',
  `answer1` enum('Y','N') NOT NULL DEFAULT 'Y',
  `answer2` enum('Y','N') NOT NULL DEFAULT 'Y',
  `answer3` enum('Y','N') NOT NULL DEFAULT 'Y',
  `answer4` enum('Y','N') NOT NULL DEFAULT 'Y',
  `answer5` enum('Y','N') NOT NULL DEFAULT 'Y',
  `answer6` enum('Y','N') NOT NULL DEFAULT 'Y',
  `answer7` enum('Y','N') NOT NULL DEFAULT 'Y',
  `answer8` enum('Y','N') NOT NULL DEFAULT 'Y',
  `answer9` enum('Y','N') NOT NULL DEFAULT 'Y',
  `answer10` enum('Y','N') NOT NULL DEFAULT 'Y',
  PRIMARY KEY (`id`),
  UNIQUE KEY `username` (`username`),
  UNIQUE KEY `email` (`email`),
  KEY `gender` (`gender`)
) ENGINE=MyISAM DEFAULT CHARSET=latin5 AUTO_INCREMENT=1 ;

And our rows:

INSERT INTO `users` (`id`, `username`, `password`, `email`, `gender`, `answer1`, `answer2`, `answer3`, `answer4`, `answer5`, `answer6`, `answer7`, `answer8`, `answer9`, `answer10`) VALUES
(1, 'maleuser1', '123456', 'male1@male1.com', 'M', 'Y', 'N', 'Y', 'Y', 'N', 'N', 'N', 'Y', 'N', 'Y'),
(2, 'maleuser2', '123456', 'male2@male2.com', 'M', 'Y', 'Y', 'N', 'N', 'N', 'Y', 'Y', 'Y', 'N', 'Y'),
(3, 'femaleuser1', '123456', 'female1@female1.com', 'F', 'Y', 'Y', 'N', 'Y', 'Y', 'N', 'N', 'Y', 'N', 'Y'),
(4, 'femaleuser2', '123456', 'female2@female2.com', 'F', 'Y', 'Y', 'Y', 'N', 'Y', 'N', 'Y', 'N', 'N', 'Y');

You can see we have 2 male and 2 female users (normally they will be thousands) and I want to search best matching female profiles for male profiles with percentage.

For example we will query:

select username, blabla as percentage 
from users where gender = 'F' 
and ("here best matchmaking codes") 
and we show users; femaleuser1 and you matching %85.

And we will only showing matcing bigger than percentage %70.

So i'm talking for that but I can not solve.

Basically you cannot compare apples with orange. You can look for assignment and maximize workers and jobs. In your problem description it would be maximize female and male pairs. Look for hungarian algorithm or edmonds v blossom algorithm.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM