Path: blob/main/notebooks/03/04-simple-production-model-gdp.ipynb
663 views
3.4 Production model using disjunctions
Preamble: Install Pyomo and a solver
The following cell sets and verifies a global SOLVER for the notebook. If run on Google Colab, the cell installs Pyomo and the HiGHS solver, while, if run elsewhere, it assumes Pyomo and HiGHS have been previously installed. It then sets to use HiGHS as solver via the appsi module and a test is performed to verify that it is available. The solver interface is stored in a global object SOLVER for later use.
Disjunctions
Disjunctions appear in applications where there is choice among discrete alternatives. Given two logical propositions and , the "or" disjunction is denoted by and defined by the truth table
| False | False | False |
| True | False | True |
| False | True | True |
| True | True | True |
The "exclusive or" is denoted by and defined by the truth table
| False | False | False |
| True | False | True |
| False | True | True |
| True | True | False |
This notebook shows how to express disjunctions in Pyomo models using the Generalized Disjunctive Programming (GDP) extension for a simple production model.
Multi-product factory optimization
A small production facility produces two products, and . With current technology , the facility is subject to the following conditions and constraints:
Product requires 1 hour of labor A, 2 hours of labor B, and 100$ of raw material. Product sells for 270$ per unit. The daily demand is limited to 40 units.
Product requires 1 hour of labor A, 1 hour of labor B, and 90$ of raw material. Product sells for 210$ per unit with unlimited demand.
There are 80 hours per day of labor A available at a cost of 50$/hour.
There are 100 hours per day of labor B available at a cost of 40$/hour.
Using the given data we see that the net profit for each unit of and is 40$ and 30$, respectively. The optimal product strategy is the solution to a linear optimization
Labor B is a relatively high cost for the production of product . Suppose a new technology has been developed with the potential to cut costs by reducing the time required to finish product to hours, but requires more highly skilled labor with a unit cost of per hour.
The net profit for unit of product with technology is equal to , while with technology is equal to .
We need to assess whether the new technology is beneficial, that is, whether adopting it would lead to higher profits. The decision here is whether to use technology or .
In this situation we have an `either-or' structure for both the objective and for Labor B constraint:
$$ \underbrace{p = 40x + 30y, \ 2 x + y \leq 100}_{\text{$\alphaParseError: KaTeX parse error: Expected 'EOF', got '}' at position 12: technology}̲} \quad \text{ …\betaParseError: KaTeX parse error: Expected 'EOF', got '}' at position 12: technology}̲}. $
There are several commonly used techniques for embedding disjunctions into mixed-integer linear optimization problems, which we will explore in this notebook.
MILO implementation
The first approach is using the "big-M" technique introduces a single binary decision variable associated with choosing technology () or technology (). Using MILO, we can formulate this problem as follows:
$$ \begin{align*} \max \quad & \text{profit}\\ \text{s.t.} \quad & x \leq 40 & \text{(demand)}\\ & x + y \leq 80 & \text{(labor A)} \\ & \text{profit} \leq 40x + 30y + M z & \text{(profit with technology $\alphaParseError: KaTeX parse error: Expected 'EOF', got '}' at position 2: )}̲ \\ & \text…\betaParseError: KaTeX parse error: Expected 'EOF', got '}' at position 2: )}̲\\ & 2 x + …\alphaParseError: KaTeX parse error: Expected 'EOF', got '}' at position 2: )}̲ \\ & 1.5 x…\betaParseError: KaTeX parse error: Expected 'EOF', got '}' at position 2: )}̲ \\ & z \in…$
where the variable "activates" the constraints related to the old or new technology, respectively, and is a large enough constant. It can be implemented in Pyomo as follows.
Disjunctive programming implementation
Alternatively, we can formulate our problem using a disjunction, preserving the logical structure, as follows:
This formulation, should the software be capable of handling it, has the benefit that the solver can intelligently partition the problem's solution into various sub-cases, based on the given disjunction. Pyomo natively supports disjunctions, as illustrated in the following implementation.