title: How to solve simple linear programming problem with lpSolve
body: <p>I am trying to maximize the function <span class="math-container">$a_1x_1 + \cdots +a_nx_n$</span> subject to the constraints <span class="math-container">$b_1x_1 + \cdots + b_nx_n \leq c$</span> and <span class="math-container">$x_i \geq 0$</span> for all <span class="math-container">$i$</span>. For the toy example below, I've chosen <span class="math-container">$a_i = b_i$</span>, so the problem is to maximize <span class="math-container">$0x_1 + 25x_2 + 50x_3 + 75x_4 + 100x_5$</span> given <span class="math-container">$0x_1 + 25x_2 + 50x_3 + 75x_4 + 100x_5 \leq 100$</span>. Trivially, the maximum value of the objective function should be 100, but when I run the code below I get a solution of 2.5e+31. What's going on?</p>
  
  <pre><code>library(lpSolve)
  
  a &lt;- seq.int(0, 100, 25)
  b &lt;- seq.int(0, 100, 25)
  c &lt;- 100
  
  
  optimal_val &lt;- lp(direction = "max", 
                    objective.in = a,
                    const.mat = b, 
                    const.dir = "&lt;=", 
                    const.rhs = c, 
                    all.int = TRUE)
  
  optimal_val
  </code></pre>