1

I am pretty new to the subject of linear programming and would appreciate any pointers.

I have a slightly complicated equation but here is a simpler version of the problem:

x1 + x2 = 10 
#subject to the following constraints: 
0 <= x1 <= 5 and 
3x1 <= x2 <= 20 

Basically x2 has to have a value that is greater than 3 times that of x1. So in this case the solutions are, x1 = [0,1,2] and correspondingly x2 = [10, 9, 8]

There is a lot of material out there for minimizing or maximizing an objective function but this is not one of them. What do you call solving such type of problems and also what is the recommended way to solve this preferably using some libraries from python that finds one single or multiple feasible solutions?

Javiar Sandra
  • 827
  • 1
  • 10
  • 25
  • At a glance is this a case of Quadratic Programming? There are at least two Python libraries which I am aware of which can help with this. – FChm Apr 09 '19 at 19:59
  • It's just plain linear programming, and a nice library to define and solve linear programs in python is cvxpy. – Valentin Lorentz Apr 09 '19 at 20:01
  • you could solve this problem using linear programming if you set an objective function that has zero coefficients. In that setting, `x1+x2=10` is also a constraint, and `3x1<=x2<=20` translates to `3x1-x2<=0` and `x2<=20`. – Karsten W. Apr 09 '19 at 20:48
  • @KarstenW. Can you explain what you mean by having an objective function with zero coefficients? – Javiar Sandra Apr 10 '19 at 00:03

1 Answers1

0

Your problem could be stated as

min 0*x1+0*x2 ("zero coefficients")

subject to

x1+x2=10
3x1-x2<=0
x2<=20 (note that this constraint follows from x1,x2>=0 and their sum being 10)

This can easily fed into a linear programming package such as pulp. I am more of a R user than a python user hence I can not provide details. You could solve it also online without any programming.

EDIT: rereading your question, I see that your desired solutions are not continuous (e.g. it seems you are not looking for [2.5, 7.5] as solution), but are restricted to integer values. The problem would then called a "mixed integer problem" instead of "linear problem". Pulp, however, should be able to solve it if you can declare the variables x1, x2 as integers.

Another point is, if you are after ALL integer solutions given the constraints. There has been some discussions about that here on stackoverflow, however I am unsure if pulp can do that out of the box.

Karsten W.
  • 17,826
  • 11
  • 69
  • 103
  • Thanks @Karsten for the explanation .. I managed to solve this problem by reading on constraint programming - specially useful when there is no objective function. – Javiar Sandra Apr 15 '19 at 01:46