title: how to solve a simple problem with lpsolve
body: <p>I have a problem to solve, and i have discovered linear programming could help me in doing this with decent performance.</p>
  <p>I would like to know how to solved it using lpsolve.</p>
  <p>I have two tables. The first table list some items with links to the second table. I need to find the combinations of A with the lowest count that matches all the elements of B.</p>
  <p>Example:</p>
  <pre><code>A1: B1, B2
  A2: B2, B3
  A3: B3, B4
  A4: B4
  </code></pre>
  <p>POSSIBLE COMBINATIONS:</p>
  <pre><code>A1/A2/A4
  A1/A3 &lt;--- BEST ONE
  </code></pre>
  <p>Would someone know how to solve this with lpsolve? ^_^</p>
  <p>[EDIT]</p>
  <p>As i've understood, A1/A2/A3/A4 are my variables. Each variables should define a value of 1 for each element of B, and apply an attribute &quot;cost&quot; of 1 (integer).</p>
  <p>Then i have to put a constraint for every element of B, with a min value of 1.</p>
  <p>Then i have to solve the problem with a optimization &quot;minimum&quot; on the &quot;cost&quot; attribute.</p>
  <p>Something like this:</p>
  <pre><code>&quot;model&quot; : {
      &quot;optimize&quot; : &quot;cost&quot;,
      &quot;opType&quot;: &quot;min&quot;,
      
      &quot;variables&quot; : {
          &quot;A1&quot; : {
              &quot;cost&quot; : 1,
              &quot;B1&quot; : 1,
              &quot;B2&quot; : 1,
              &quot;B3&quot; : 0,
              &quot;B4&quot; : 0
          },
          &quot;A2&quot; : {
              &quot;cost&quot; : 1,
              &quot;B1&quot; : 0,
              &quot;B2&quot; : 1,
              &quot;B3&quot; : 1,
              &quot;B4&quot; : 0
          },
          &quot;A3&quot; : {
              &quot;cost&quot; : 1,
              &quot;B1&quot; : 0,
              &quot;B2&quot; : 0,
              &quot;B3&quot; : 1,
              &quot;B4&quot; : 1
          },
          &quot;A4&quot; : {
              &quot;cost&quot; : 1,
              &quot;B1&quot; : 0,
              &quot;B2&quot; : 0,
              &quot;B3&quot; : 0,
              &quot;B4&quot; : 1
          },
      },
  
      &quot;constraints&quot; : {
          &quot;B1&quot; : {&quot;min&quot; : 1},
          &quot;B2&quot; : {&quot;min&quot; : 1},
          &quot;B3&quot; : {&quot;min&quot; : 1},
          &quot;B4&quot; : {&quot;min&quot; : 1}
      },
      
      &quot;ints&quot; : {
          &quot;A1&quot; : 1, &quot;A2&quot; : 1, &quot;A3&quot; : 1, &quot;A4&quot; : 1
      }
      
  }
  </code></pre>
  <p>This is how i wrote it to solve the problem with a JS library, but how to &quot;translate&quot; it for lpsolve... it's out of my reach atm.</p>
  <p>Any suggestion?</p>