Search code examples
pythonmathmathematical-optimizationdata-sciencediscrete-mathematics

How to do discrete optimization with python


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


Solution

  • 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.