Message Boards Message Boards

Solve for best teams?

GROUPS:

Hello

I have an algorithmus which I like to undestand and solve with Mathematica. It is about cooking. You need at least 18 people for it. Each group (2 people) are cooking either appetizer, main dish or dessert at their place. 2 other groups are visiting them. For the other two courses the group is the invited to another hosts' homes. Each location you meet new people (2 new groups). That means at the end you met 6 groups (12 people). Its a lot of fun. I want to organize this for my birthday party.

Goal is it, to maximise the happinies factor. Only this way you can make sure, that in each different location you will see new people that you will not meet in the 2 other locations.

![enter image description here][2]

There are some constrains which we have to consider:

I like to know how to handle this problem with Mathematica. Where do I start? Which equation do I have to solve here? I don't see what I realy need to do...

As I sad, you need minimum 18 people. That means we have 9 teams and 3 major groups. Ok, but I don't know what to do next and how I implement this in Mathematica. I guess it should not be so difficult but I need some help from you!

POSTED BY: Peter Parker
Answer
1 year ago

You can generate symbolically the constraints of equations (2)-(8) and give (1) to Maximize. It might be a very good idea to make a linear programming formulation (and use LinearProgramming). See this answer at MSE that uses the outlined approach.

POSTED BY: Anton Antonov
Answer
1 year ago

It would be helpful if you give Mathematica code for the various inputs shown above.

POSTED BY: Daniel Lichtblau
Answer
1 year ago

Thank you very much for your answers!

@Daniel: Yes, I will try to give you all the Mathematica code for the various inputs. But here is the first problem. Lets take equation 2 as an overall example. How can I write this in Mathematica? What do I need to define first? For example, is "Ass(c,t,g)" a list? I would be grateful if you can show me how to write equation 2 in Mathematica, so that I can try it for the remaining ones.

@Anton: Sounds interesting. I will first try to finish what Daniel said, then continuing with what you suggested.

Thanks a lot,

Peter

POSTED BY: Peter Parker
Answer
1 year ago

It seems that the uses of "team" and "group" are inconsistent in your description. A team has two people in it or that is the definition of a group?

POSTED BY: Anton Antonov
Answer
1 year ago

Oh yes, maybe you are right and my description in post 1 is not consistend with the mathematical definitions below. Here is a detailed explanation for each equation and what it means:

enter image description here

Anyway, as I said in my previous post, I struggle to write down the Mathematica-code even for equation (2). Would be great if somebody can give me an example, so that I can code the remaining equations.

Cheers,

Peter

POSTED BY: Peter Parker
Answer
1 year ago

For each team/group/course there should correspond a (triply indexed) variable that takes values of 0 or 1. If 1, that means the team is assigned to that group in that course. The sum over all groups, for fixed team and course, must be 1. So that gives the constraints corresponding to stipulation 2.

POSTED BY: Daniel Lichtblau
Answer
1 year ago

Thank you very much. Since I don't have Mathematica on my private PC I will be able to test my idea not until Monday. I guess the best for me would be, it I write the constrains in Mathematica-Code first, and then try to maximize them using the suggestions of Anton in the first reply. Anyway, I think it would be helpful to see the code for equation 2. Then I can apply this to the remaining equations.

Cheers and have a nice weekend,

Peter

POSTED BY: Peter Parker
Answer
1 year ago

This type of problem is best solved with a program called GAMS (see gams.com). The only downside of GAMS is that it does not have the power of Mathematica to create and manipulate the equations and constraints. I have written a GAMS package in Mathematica to enable problems to be formulated in Mathematica and solved in GAMS, however, it is not quite yet ready for external distribution. Fortunately your problem equations are easy to write in GAMS and can be solved with the free version of the program.

Regards

Neil

POSTED BY: Neil Singer
Answer
1 year ago

Here is the solution I outlined in a previous post: http://community.wolfram.com/groups/-/m/t/975898

POSTED BY: Anton Antonov
Answer
1 year ago

@Anton Antonov suggested a great solution. We split it up in a separate discussion. To keep future edits of this solution in a single place please always refer to the new solution's URL: http://community.wolfram.com/groups/-/m/t/975898

POSTED BY: Moderation Team
Answer
1 year ago

Thank all of you for your contributions to my question. You are all very helpful and I am glad that this forum exist. Special thanks to Anton, who took the effort to write a complete algorithm to my problem. Thank you very much. I am also supriesed that my little questions turns out in such a big algorithm. I completely underestimated it.

I am still trying to understand the algorithm but there is one question that I already have:

Did you forget to define eachTeamHadFullMeal ? I think so. This is why I can not evaluate the Matrix plot.

I will have following questions, but I will keep this for the beginning. I don't want to confuse you :-)

Regards,

Peter

POSTED BY: Peter Parker
Answer
1 year ago

Did you forget to define eachTeamHadFullMeal ? I think so. This is why I can not evaluate the Matrix plot.

Yes, I removed it somehow after pasting the Markdown code into the browser. It is fixed now.

POSTED BY: Anton Antonov
Answer
1 year ago

Hi,

I am still in the process of understanding the code step by step. So far I doing well but I have a problem after plotting the matrix (which, by the way, looks exactly like in the example). The problem appears with importing the Mathematica file. Please have a look at the screenshot attached to this message.

Screenshoot in my Dropbox

It is almost the last step. If I evaluate the file again, the first error message disappears ("Cannot open....") but I can still not plot the table. Am I doing sth. wrong when importing the Mathematica file? I don't think so....

Hope you can help me. As I sad, my Matrix plot looks like the one from the example, therefore I think this is not the problem.

Best regards,

Peter

PS: I posted a similar message in the separated discussion of this topic: Discussion But I think it actually belongs to here, which is why I reposted it. I am really interested in understanding the code and I hope you will have the patience to help me with my problem :-) As I sad, I have the matrix plot already and I think I understand it more or less. But the rest doesn't seem to work for some reasons...

POSTED BY: Peter Parker
Answer
1 year ago

@Peter Parker did you edit your post and made images disappear? Could you please bring it back to a readable state?

POSTED BY: Moderation Team
Answer
19 days ago

Group Abstract Group Abstract