Optimal Marriage Using ORTools

While an analytical mind might employ optimization algorithms to find the perfect match, true love often dances to its own tune, defying any mathematical explanation.

Optimization team
Operations Research Bit
4 min readJun 25, 2024

--

After all, romance isn’t just about equations and logic; sometimes, it’s about those inexplicable butterflies and spontaneous, heart-fluttering moments that no formula can capture!

Let’s skip to the fun part !

Suppose we have 5 people in group A (assume they are men) and 5 people (assume they are women) in group B.

Each Group has a preference matrix over the other group as follows:

Preferences of each group other the other group

So you can see if Bob likes Alice ( out of 5) Alice likes him (1 out of 5) (sad story)!

Now, you as an OR specialist want to properly match group A to B. Let’s see how we can do it to make all or some people happy.

General Constraints:

  • Each man marries to only one Woman
  • Each woman marries to only one man

1- Pay the whole attention to group A:

case A) In this case we try to maximize the satisfaction group A.

OF of Men = 22

OF of Women = 18

case B) What if we minimize their satisfaction ?

OF of Men = 6

OF of Women = 11

It shows that if we go in this direction we not only make the group A unhappy but also group B gets less than the case A.

Pytjon code:

2- Pay the whole attention to group B:

Maximize Group B satisfaction

OF of Men = 17

OF of Women = 22

Minimize Group B satisfaction

OF of Men = 10

OF of Women = 6

Maximize Group A+ Group B satisfaction

OF of Men = 21

OF of Women = 21

Stable Marriage

This interesting approach is trying to make sure the matching procedure is done in a way that there are no two people of group A,B who would both rather have each other than their current partners.

The formulation is as follows:

For each gentelman:

For each lay:

Python Code:

OF of Men = 22

OF of Women = 18

This would make sure no one is interested to break the deal !

The folks in groups A and B chose to follow the latest solution and lived happily ever after. However, they decided to dive into the world of Operations Research (OR) and keep up with the newsletter before their wedding ceremony.

If you look for real life Application and you find these puzzles useful then this post is not for you .

Some applications:

  • Task assignemnt
  • Coalition formation
  • Project management

برای اگاهی بیشتر از آموزش ها می توانید به کانال
PyomoChannel
مراجعه کنید

#ortools #optimization

--

--