/Linear-Programming-and-MILP-Optimization-With-Python

This notebook expand the Linear Programming with Python by tstran155 by using MILP technique to solve Problem #8.

Primary LanguageJupyter Notebook

Linear Programming and Mixed-Integer Linear Programming Optimization with Python

Mixed Integer Linear Programming extends LP to include cases where some or all of the decision variables are required to be integers. This is particularly useful in scenarios where decisions involve discrete units (like numbers of plants, machines, or hectares in this case). MILP is ideal for scenarios requiring discrete decisions. For this rice planting problem, this would mean specifying the exact number of hectares for each type of rice in each field type, which cannot realistically be fractional. It can model a wide range of practical problems more accurately than LP when integer constraints are involved.

On the flip side, solving MILP problems is generally more computationally intensive than LP. This is because the integer constraints make the problem more complex, leading to potentially longer solve times and higher computational resource usage. As the size of the problem (number of variables and constraints) grows, MILPs can become significantly harder to solve optimally.

  1. Problem formulation
  • Let's define the variables: 𝑥𝑖𝑗 = hectares of rice type

Where 𝑖 ranges over field types (I, II, III) and j ranges over rice types (IR8, CBC, IR132).

  • The constraints based on the total hectares available for each rice type are:

rice type

  • And the constraints based on the total hectares available for each field type are:

field type

  • The objective function to maximize the total yield (in tons) is:

objective function

​ 2. MILP formulation This problem is linear as the objective and constraints are linear relations. MILP is suitable in case integer constraints on the 𝑥𝑖𝑗 variables (assuming that only whole hectares can be allocated). If the variables can be fractional, a simple linear programming approach would suffice.