title: Algorithm to schedule jobs to minimise change
body: <p>I'm writing a program in Python that will hopefully minimise the tool changes to do with a CNC turret punch. </p>
  
  <p>The information is stored in a big dictionary:</p>
  
  <pre><code>Data = {
    'job1' : {
      'tool1' : {'clearance' : X, 'station': Y, 'angle': Z, },
      'tool2' : ...
    },
    'job2' : ...
  }
  </code></pre>
  
  <p>Jobs usually use between 4-8 tools, however there's a lot of tool use overlap between jobs (thus only requiring 1 or 2 changes between jobs). </p>
  
  <p>I want to be able to input that I want to do job1, job3, job5, job7 and job8 and the program to sort the jobs into 'groups' that can all be completed with the same tool set.</p>
  
  <p>These groups have to have no conflicts in the 'tool sets'. I.e. no two tools can occupy the same station. If a tool is used for more than one job it's characteristics (station,clearance,angle) all have to be identical. etc.</p>
  
  <p><strong>I just have no idea how to do that sort of sorting to a dictionary in python</strong>. Any help or pointers would be greatly appreciated.</p>
  
  <p>also: there will be around 4-5 thousand jobs in the dictionary. Though the time it takes to sort isn't particularly crucial.</p>
  
  <p><strong>EDIT:
  Simple example (with only one tool characterstic) as I don't think I'm being clear:</strong></p>
  
  <p>Job1 needs:</p>
  
  <ul>
  <li>Hammer - st: 2</li>
  <li>Screwdriver - st:4</li>
  </ul>
  
  <p>Job2 needs</p>
  
  <ul>
  <li>Hammer - st: 2</li>
  <li>Nail gun - st: 6</li>
  </ul>
  
  <p>Job3 needs:</p>
  
  <ul>
  <li>Hammer - st:2</li>
  <li>wrench - st: 4</li>
  </ul>
  
  <p>Job 4 needs:</p>
  
  <ul>
  <li>wrench - st: 4</li>
  <li>Nail gun - st:6</li>
  </ul>
  
  <p>Job 5 needs:</p>
  
  <ul>
  <li>screwdriver st: 4</li>
  <li>pillow st: 5 </li>
  </ul>
  
  <p><strong>Thus the program would output</strong></p>
  
  <p>Jobs: 2, 3 and 4 can be done with:</p>
  
  <ul>
  <li>Hammer - st: 2</li>
  <li>wrench - st: 4</li>
  <li>Nail gun - st: 6</li>
  </ul>
  
  <p>Job 1 and 5 can be done with:</p>
  
  <ul>
  <li>Hammer - st: 1</li>
  <li>screwdriver - st: 4 </li>
  <li>pillow - st: 5</li>
  </ul>
  
  <p>any help would be greatly appreciated. </p>