-3

I have a discrete optimization problem similar to

Y=3X1+2X2 (a sample one)

Minimize Y such that there are some constraints for X1 and X2 like X1 +X2 >20

X1 can take values from {5,10,15,25,85} X2 can take values from {20,25,5,40,10} etc

How can do this problem with python

U13-Forward
  • 69,221
  • 14
  • 89
  • 114
Sreeja P
  • 13
  • 2
  • 4
  • What's your question? – U13-Forward Aug 13 '18 at 04:03
  • I want to find the values of X1 and X2 such that it should give the minimum value of Y and also X1 and X2 should satisfy the constraints(X1+X2>20) . How can i do this with branch and bound algorithm(or any algorithm) in python. I think it is a discrete optimization problem since X1 belongs to a set {5,10,15,25,85} and X2 belongs to {20,25,5,40,10} – Sreeja P Aug 13 '18 at 04:35
  • https://docs.scipy.org/doc/scipy/reference/optimize.html, https://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.fmin.html#scipy.optimize.fmin – Joe Aug 13 '18 at 04:56
  • @SreejaP Basically you want to get the two values that doon't add up to twenty in the zipped (x1,x2) – U13-Forward Aug 13 '18 at 05:25
  • Thank you for your reply. I go through this before. It is for continuous input. Here the problem is my inputs are discrete. – Sreeja P Aug 13 '18 at 05:33

1 Answers1

0

This is easily modeled with binary variables:

enter image description here

Similar for X2. Most textbooks about integer programming will mention this. Your teacher can probably recommend a few books.

Sometimes SOS1 variables (Special Ordered Sets of Type 1) are suggested for this construct. Some solvers support this. I typically use binary variables for this type of table lookup.

Erwin Kalvelagen
  • 15,677
  • 2
  • 14
  • 39
  • Thank you for your reply. This solution is working. Now i am facing another issue. – Sreeja P Aug 22 '18 at 04:51
  • My intputs are X1 and X2. (representing products). Each product has two parameters its price and rating . I have to choose from product list X1 and from product list X2 such that the total cost should be minimum and should satisfy the rating constraints. – Sreeja P Aug 22 '18 at 05:06