0

Please help, maybe I am stupid, but what do I miss? lpSolve is not converging.

Firstly, I try to solve this and it is working

f.obj [1] 0.02708294 0.02677628 0.05480254 0.09362836 -0.13018085 0.01081241 0.02723422 0.10048414 0.04800000 0.00750000 0.01400000

 > f.con
          [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11]
     [1,]    2    3    4    5    6    2    3    5    1     1     1
     [2,]    1    1    1    1    1    1    1    1    1     1     1
     [3,]    1    0    0    0    0    0    0    0    0     0     0
     [4,]    0    1    0    0    0    0    0    0    0     0     0
     [5,]    0    0    1    0    0    0    0    0    0     0     0
     [6,]    0    0    0    1    0    0    0    0    0     0     0
     [7,]    0    0    0    0    1    0    0    0    0     0     0
     [8,]    0    0    0    0    0    1    0    0    0     0     0
     [9,]    0    0    0    0    0    0    1    0    0     0     0
    [10,]    0    0    0    0    0    0    0    1    0     0     0
    [11,]    0    0    0    0    0    0    0    0    1     0     0
    [12,]    0    0    0    0    0    0    0    0    0     1     0
    [13,]    0    0    0    0    0    0    0    0    0     0     1
    > f.dir
     [1] "<=" "="  "<=" "<=" "<=" "<=" "<=" "<=" "<=" "<=" "<=" "<=" "<="
    > f.rhs
     [1] 2.00000000 1.00000000 0.11194472 0.06814353 0.30487805 0.10031507 0.30487805 0.50000000 0.30487805 0.30487805 0.50000000 0.50000000
    [13] 0.50000000
    > lp ("max", f.obj, f.con, f.dir, f.rhs)$solution # solution
     [1] 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.25 0.50 0.00 0.25

However I want to add condition to the variables to be > 0.3 if appeared in the solution So I add:

> f.obj
 [1]  0.02708294  0.02677628  0.05480254  0.09362836 -0.13018085  0.01081241  0.02723422  0.10048414  0.04800000  0.00750000  0.01400000
> f.con
      [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11]
 [1,]    2    3    4    5    6    2    3    5    1     1     1
 [2,]    1    1    1    1    1    1    1    1    1     1     1
 [3,]    1    0    0    0    0    0    0    0    0     0     0
 [4,]    0    1    0    0    0    0    0    0    0     0     0
 [5,]    0    0    1    0    0    0    0    0    0     0     0
 [6,]    0    0    0    1    0    0    0    0    0     0     0
 [7,]    0    0    0    0    1    0    0    0    0     0     0
 [8,]    0    0    0    0    0    1    0    0    0     0     0
 [9,]    0    0    0    0    0    0    1    0    0     0     0
[10,]    0    0    0    0    0    0    0    1    0     0     0
[11,]    0    0    0    0    0    0    0    0    1     0     0
[12,]    0    0    0    0    0    0    0    0    0     1     0
[13,]    0    0    0    0    0    0    0    0    0     0     1
[14,]    1    0    0    0    0    0    0    0    0     0     0
[15,]    0    1    0    0    0    0    0    0    0     0     0
[16,]    0    0    1    0    0    0    0    0    0     0     0
[17,]    0    0    0    1    0    0    0    0    0     0     0
[18,]    0    0    0    0    1    0    0    0    0     0     0
[19,]    0    0    0    0    0    1    0    0    0     0     0
[20,]    0    0    0    0    0    0    1    0    0     0     0
[21,]    0    0    0    0    0    0    0    1    0     0     0
[22,]    0    0    0    0    0    0    0    0    1     0     0
[23,]    0    0    0    0    0    0    0    0    0     1     0
[24,]    0    0    0    0    0    0    0    0    0     0     1
> f.dir
 [1] "<=" "="  "<=" "<=" "<=" "<=" "<=" "<=" "<=" "<=" "<=" "<=" "<=" ">=" ">=" ">=" ">=" ">=" ">=" ">=" ">=" ">=" ">=" ">="
> f.rhs
 [1] 2.00000000 1.00000000 0.11194472 0.06814353 0.30487805 0.10031507 0.30487805 0.50000000 0.30487805 0.30487805 0.50000000 0.50000000
[13] 0.50000000 0.30000000 0.30000000 0.30000000 0.30000000 0.30000000 0.30000000 0.30000000 0.30000000 0.30000000 0.30000000 0.30000000
> lp ("max", f.obj, f.con, f.dir, f.rhs)   # linear programming
Error: no feasible solution found

Why?

  • You can maximize the objective function without bounds. The only constraint you have on the variables is that they must be greater than 0.3. But, (with the exception of the fifth variable, whose coefficient in the objective is negative) as any variable increases the objective increases without bounds. – nicola Sep 18 '17 at 19:24
  • Thx nicola, but I have the same problem with the second example which finds no feasible solution (sorry for so much code). I editited the question :) – Jakub Štěch Sep 18 '17 at 20:29
  • You don't have the same problem; you have to opposite one. See that the first constraint is not compatible with each variable being greater than 0.3 (just assign to each variable 0.3 or any greater value and you'll see that the first constraint is not satisfied). – nicola Sep 18 '17 at 20:41
  • Of course, omg I am dumb :( Thx!!! – Jakub Štěch Sep 18 '17 at 20:46
  • This issue is solved :) – Jakub Štěch Sep 18 '17 at 20:48
  • @nicola I propose that you copy/paste your comments as an answer (to get this out of the unanswered queue). – scottkosty Jan 11 '21 at 00:09

0 Answers0