title: Minimization problem with linking constraints in R
body: <p>How should I incorporate the linking constraints into the optimization problem formulation in equations 1 - 4 where Y_i's are binary variables?</p>
  
  <pre><code>minimize
      22X11 + 20.5X12 + 21X13 + 19X14 + 21X21 + 21X22 + 18X23 + 17X24 +
      22X31 + 24X32 + 22X33 + 23X34 + 22X41 + 16X42 + 17X43 + 17.5X44 + 
      1500 Y1 + 1700 Y2 + 1500 Y3 + 1400 Y4
  
  subject to constraints
  
      2.00 X11 + 1.80 X21 + 2.30 X31 + 2.10 X41 &gt;= 750
      2.80 X12 + 2.30 X22 + 2.20 X32 + 2.60 X42 &gt;= 800
      1.70 X13 + 1.75 X23 + 1.60 X33 + 1.90 X43 &gt;= 1000
      2.40 X14 + 1.90 X24 + 2.60 X34 + 2.40 X44 &gt;= 300
  
      X11 - 1500 Y1 &lt;= 0
      X21 - 2000 Y2 &lt;= 0
      X31 - 1500 Y3 &lt;= 0
      X41 - 1800 Y4 &lt;= 0
      X12 - 500 Y1 &gt;= 0
      X22 - 500 Y2 &gt;= 0
      X32 - 500 Y3 &gt;= 0
      X42 - 500 Y4 &gt;= 0
  
      Y1 = 1 if X11&gt;0 and 0 otherwise 
      Y1 = 1 if X12&gt;0 and 0 otherwise 
      Y2 = 1 if X21&gt;0 and 0 otherwise 
      Y2 = 1 if X22&gt;0 and 0 otherwise 
      Y3 = 1 if X31&gt;0 and 0 otherwise 
      Y3 = 1 if X32&gt;0 and 0 otherwise 
      Y4 = 1 if X41&gt;0 and 0 otherwise 
      Y4 = 1 if X42&gt;0 and 0 otherwise 
  </code></pre>
  
  <p>R code to find optimal solutions without those linking variables:</p>
  
  <pre><code>library(lpSolve)
  f.obj &lt;-  c(22,20.5,21,19,21,21,18,17,22,24,22,23,22,16,17,17.5,1500,1700,1500,1400) 
  
  const1 = c(2.00,1.80,2.30,2.10)
  const2 = c(2.80,2.30,2.20,2.60)
  const3 = c(1.70,1.75,1.60,1.90)
  const4 = c(2.40,1.90,2.60,2.40)
  
  f.con &lt;- rbind(const1,const2,const3,const4)
  f.dir &lt;- c(rep("&gt;=",2), "&gt;=", "&gt;=")
  f.rhs &lt;- c(750,800,1000,300)
  res &lt;- lp("min", f.obj, f.con,f.dir,f.rhs, binary.vec=c(1,2))
  
  res$solution
  res$objective
  res$objval 
  </code></pre>