# 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!
1 year ago
14 Replies
 Anton Antonov 2 Votes 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.
1 year ago
 Daniel Lichtblau 1 Vote It would be helpful if you give Mathematica code for the various inputs shown above.
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
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?
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: 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
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.
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
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.RegardsNeil
1 year ago
 Anton Antonov 5 Votes Here is the solution I outlined in a previous post: http://community.wolfram.com/groups/-/m/t/975898
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
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