title: Algorithm for Table / Seat assignment
body: <p>I am currently developing a Booking system, and are in need of an algorithm to assign Company participants to Seats, based on some conditions and predefined values.</p>
  
  <p>The conditions are:</p>
  
  <ul>
  <li>From each distinct company, at least two participants must be placed at the same table. (Given that the company has 2 at least participants)</li>
  <li>Companies have competitors defined. A Company cannot be seated at the same table as a competitor.</li>
  </ul>
  
  <p>The predefined values are:</p>
  
  <ul>
  <li>Tables and seats are predefined.</li>
  <li>Companies participants and Competitors relations are predefined.</li>
  </ul>
  
  <p>Definition of entities:</p>
  
  <p><strong>Table:</strong>
  ID (Int, PK),
  Description (String),
  Number (Int),</p>
  
  <p><strong>TableSeat:</strong>
  ID (Int, PK),
  Number (Int),
  TableID (FK),
  CustomerID (Nullable Int, FK)</p>
  
  <p><strong>Company:</strong>
  ID (PK)
  Name (String)
  DefaultNumberOfParticipants (Int)
  CompetitorID (FK)</p>
  
  <p><strong>Competior:</strong>
  ID (PK)
  CompanyID (FK)
  CompanyID2 (FK)</p>
  
  <p>So, if i, for example, have the following preset defined:</p>
  
  <p>Tables:</p>
  
  <ul>
  <li>Table 1 has 6 Seats </li>
  <li>Table 2 has 4 Seats</li>
  <li>Table 3 has 6 Seats</li>
  <li>Table 4 has 3 Seats</li>
  </ul>
  
  <p>Company/Participants:</p>
  
  <ul>
  <li>Company1 has 3 participants and no competitors</li>
  <li>Company2 has 2 participants and Company3 as Competitor</li>
  <li>Company3 has 4 participants and Company2 as Competitor</li>
  </ul>
  
  <p>I need to auto assign the total of 9 participants, from the 3 companies on the total of 19 seats on 4 tables. According to the conditions, participants from Company2 and Company3 cannot be seated at the same table. Futhermore, when a participant is seated at a table he should be accompanied (if possible) by a fellow company participant.</p>
  
  <p>Any ideas or pointers towards a suitable algorithm would be greatly appreciated. Thanks.</p>