Friday, April 24, 2009

Data for Manners 2009

Greetings:

OK, here it is.  As you can see, we have to possibility of adding some complexity regarding the teachers and socialites.  BUT, we'll do that only if the times are extremely low.
==============================
Num,Profession,SubProf,Gender,Hobby1,Hobby2,Hobby3
-------------------------------------------
1,Politician,Democrat,F,4,1,2
2,Politician,Democrat,F,1,2,4
3,Politician,Democrat,F,5,1,3
4,Politician,Democrat,F,3,4,2
5,Politician,Democrat,F,2,5,3
6,Politician,Democrat,F,4,3,5
7,Politician,Democrat,M,4,1,2
8,Politician,Democrat,M,4,1,3
9,Politician,Democrat,M,2,3,4
10,Politician,Democrat,M,1,2,4
11,Politician,Democrat,M,5,3,1
12,Politician,Democrat,M,4,3,5
13,Politician,Republican,F,3,4,2
14,Politician,Republican,F,3,5,4
15,Politician,Republican,F,3,1,4
16,Politician,Republican,F,1,3,4
17,Politician,Republican,F,2,4,3
18,Politician,Republican,F,4,1,5
19,Politician,Republican,M,1,3,2
20,Politician,Republican,M,5,3,4
21,Politician,Republican,M,5,4,2
22,Politician,Republican,M,2,3,1
23,Politician,Republican,M,2,4,1
24,Politician,Republican,M,4,5,1
25,Doctor,Pediatrician,F,3,4,1
26,Doctor,Pediatrician,F,2,5,3
27,Doctor,Pediatrician,F,2,5,3
28,Doctor,Pediatrician,F,1,3,5
29,Doctor,Pediatrician,F,1,2,3
30,Doctor,Pediatrician,F,1,1,5
31,Doctor,Pediatrician,M,4,5,3
32,Doctor,Pediatrician,M,3,1,5
33,Doctor,Surgeon,F,2,3,1
34,Doctor,Surgeon,F,3,5,1
35,Doctor,Surgeon,F,5,4,1
36,Doctor,Surgeon,F,5,3,4
37,Doctor,Surgeon,M,2,4,1
38,Doctor,Surgeon,M,2,5,3
39,Doctor,Surgeon,M,4,3,2
40,Doctor,Surgeon,M,1,3,5
41,Doctor,Osteopath,F,4,3,2
42,Doctor,Osteopath,F,4,1,3
43,Doctor,Osteopath,M,5,4,1
44,Doctor,Osteopath,M,2,1,3
45,Doctor,Osteopath,M,2,5,3
46,Doctor,Osteopath,M,3,2,5
47,Doctor,Osteopath,M,5,4,3
48,Doctor,Osteopath,M,5,4,1
49,Sports,Basketball,F,1,3,5
50,Sports,Basketball,F,3,5,1
51,Sports,Basketball,F,5,1,3
52,Sports,Basketball,F,4,2,1
53,Sports,Basketball,M,2,1,4
54,Sports,Basketball,M,5,1,4
55,Sports,Basketball,M,4,5,1
56,Sports,Basketball,M,3,5,2
57,Sports,Football,M,4,3,2
58,Sports,Football,M,3,2,4
59,Sports,Football,M,5,3,2
60,Sports,Football,M,2,3,4
61,Sports,Football,M,4,1,2
62,Sports,Football,M,1,5,2
63,Sports,Football,M,3,5,1
64,Sports,Football,M,2,3,1
65,Sports,Football,M,3,4,5
66,Sports,Football,M,5,3,4
67,Sports,Football,M,2,1,3
68,Sports,Football,M,2,4,3
69,Sports,Baseball,M,2,5,4
70,Sports,Baseball,M,2,3,1
71,Sports,Baseball,M,4,2,3
72,Sports,Baseball,M,3,1,4
73,Teacher,Math,F,4,5,2
74,Teacher,Math,F,3,4,2
75,Teacher,Math,M,4,4,3
76,Teacher,Math,M,2,1,3
77,Teacher,Math,M,3,5,2
78,Teacher,Math,M,5,2,3
79,Teacher,Math,M,4,2,3
80,Teacher,Math,M,1,4,3
81,Teacher,English,F,3,5,4
82,Teacher,English,F,4,3,1
83,Teacher,English,M,4,3,5
84,Teacher,English,M,1,2,3
85,Teacher,Science,F,4,2,1
86,Teacher,Science,F,3,2,1
87,Teacher,Science,M,1,3,5
88,Teacher,Science,M,1,5,3
89,Teacher,Sports,F,5,3,2
90,Teacher,Sports,F,2,5,3
91,Teacher,Sports,M,1,4,2
92,Teacher,Sports,M,1,4,5
93,Teacher,History,F,1,5,3
94,Teacher,History,F,1,3,5
95,Teacher,History,M,4,1,2
96,Teacher,History,M,4,3,2
97,Programmer,MacIntosh,F,2,4,3
98,Programmer,MacIntosh,F,4,5,1
99,Programmer,MacIntosh,F,5,3,1
100,Programmer,MacIntosh,M,2,5,3
101,Programmer,MacIntosh,M,4,1,3
102,Programmer,MacIntosh,M,5,4,3
103,Programmer,MacIntosh,M,4,3,1
104,Programmer,MacIntosh,M,1,5,4
105,Programmer,Windows,F,5,4,3
106,Programmer,Windows,F,2,4,3
107,Programmer,Windows,F,1,5,4
108,Programmer,Windows,F,2,4,5
109,Programmer,Windows,F,4,2,3
110,Programmer,Windows,F,1,3,2
111,Programmer,Windows,M,4,3,2
112,Programmer,Windows,M,3,4,1
113,Programmer,COBOL,F,4,1,3
114,Programmer,COBOL,F,5,2,1
115,Programmer,COBOL,M,2,3,4
116,Programmer,COBOL,M,2,3,5
117,Programmer,COBOL,M,4,5,1
118,Programmer,COBOL,M,3,2,5
119,Programmer,COBOL,M,2,4,5
120,Programmer,COBOL,M,4,2,1
121,Socialite,Republican,F,4,5,3
122,Socialite,Republican,F,1,3,5
123,Socialite,Republican,F,2,2,3
124,Socialite,Republican,F,1,3,5
125,Socialite,Republican,F,3,2,4
126,Socialite,Republican,F,3,2,1
127,Socialite,Democrat,F,5,2,3
128,Socialite,Democrat,F,5,4,3
129,Socialite,Democrat,F,1,5,2
130,Socialite,Democrat,F,1,4,5
131,Socialite,Democrat,F,5,4,1
132,Socialite,Democrat,F,4,1,2
133,Socialite,Democrat,F,1,3,5
134,Socialite,Democrat,F,1,4,5
135,Socialite,Democrat,F,2,5,1
136,Socialite,Democrat,F,1,4,5
137,Socialite,Democrat,F,3,4,1
138,Socialite,Democrat,F,2,5,3
139,Socialite,Republican,M,3,1,5
140,Socialite,Republican,M,1,2,3
141,Socialite,Republican,M,1,5,3
142,Socialite,Republican,M,4,2,3
143,Socialite,Democrat,M,4,1,2
144,Socialite,Democrat,M,1,5,3
----------------------------------

10 comments:

Geoffrey De Smet said...

There is this constraint:
The objective is to put at each table
1 democrat
1 republican

Does this mean:
1 democrat politician
1 republican politician
Or does it mean
1 democrat politician or socialite
1 republican politician or socialite
?

James Owen said...

At each table:

One Politician that is a DEMOCRAT
One Politician that is a REPUBLICAN

I left the opportunity to further extend the problem by assigning a political party to the Socialites. Also, I put a sub-profession type on the Teachers but they don't have to be of any certain type for the problem.

SDG
jco

Geoffrey De Smet said...

Can I propose to add this to the start of the file?

Tables: 12
SeatsPerTable: 12

I see no reason to hard code that?

Geoffrey De Smet said...

If every guest has 3 hobbies, out of a pool of 5 hobbies, then every guest has at least 1 hobby in common with every other guest.

Doesn't that make this constraint obsolete?
Each person MUST have someone (left or right) who has the same hobby.

By the way, as I interpret that constraint, the guest doesn't even have a hobby in common with the person sitting left of him, as long as he got a hobby in common with the person sitting right of him. Is that the correct interpretation?

James Owen said...

Number of tables is 12
Number of guests at each table is 12
(144 guests)

Every guest has three hobbies max (doesn't mean that it has to be three. Could be three, two or one. Selected from a group of five hobbies.
It's just important that the guest on each side have one hobby in common of the guest in question.

Initially, if no one is sitting on the left or right side, as may happen while running the rules, then that non-existent person does not have a hobby to be in question.

Does this clear up your questions? At least someone is working on the problem - did you lose a bet or something? :-)

SDG
jco

Geoffrey De Smet said...

My implementation is almost finished :) I worked a full day on it yesterday and it's pretty straightforward.

There are some issues with the testdata though:

1) 67 females and 77 males makes it impossible to put them into boy-girl-boy-girl seating arrangements. The last 5 male guests (guest 140 till 144) have had a sex change operation in my implementation. Now there are 72 males are 72 females.

2) The testdata assign every guest 3 hobbies out of 5. So every guest has a hobby in common with every other guest. That means the testdata doesn't test the hobby constraint at all. I'll create a variation on james1.txt and drop 2 hobbies every 3 rows and 1 hobby every other 3 rows.
So this:
1,Politician,Democrat,F,4,1,2
2,Politician,Democrat,F,1,2,4
3,Politician,Democrat,F,5,1,3
4,Politician,Democrat,F,3,4,2
5,Politician,Democrat,F,2,5,3
6,Politician,Democrat,F,4,3,5
becomes this:
1,Politician,Democrat,F,4
2,Politician,Democrat,F,1,2
3,Politician,Democrat,F,5,1,3
4,Politician,Democrat,F,3
5,Politician,Democrat,F,2,5
6,Politician,Democrat,F,4,3,5

Geoffrey De Smet said...

BTW, I've already got a perfect solution (no constraints broken) to your testdata with the gender change for the last 5 males. It's in the drools subversion.

Geoffrey De Smet said...

I've blogged about Manners 2009:
http://blog.athico.com/2009/05/miss-manners-2009-yet-another-drools.html

James Owen said...

Geoffrey:

Thanks for the work done while I was tooding around Louisiana Bayou country. :-)

I'll make the changes to my data here as well.

SDG
jco

Geoffrey De Smet said...

Here's the txt file with the changes I mentioned:

http://fisheye.jboss.org/browse/JBossRules/trunk/drools-solver/drools-solver-examples/data/manners2009/input/geoffrey1.txt?r=trunk

My solution is in a verbose xml format here:
http://fisheye.jboss.org/browse/JBossRules/trunk/drools-solver/drools-solver-examples/data/manners2009/solved/geoffrey1-score0.xml?r=trunk

If you define an output format too, I'll write an OutputConverter which turns that into a readable txt file.

For now, you 'll have to pull drools-solver from subversion and run Manners2009App (in the working directory of drools-solver-examples) and you can load the solution file.