Created
August 22, 2019 01:49
-
-
Save ELC/a54149a25d3f2071d9a5da32a31a1c60 to your computer and use it in GitHub Desktop.
FRRo Operativa Demo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
channels: | |
- defaults | |
- conda-forge | |
dependencies: | |
- ipython | |
- ipywidgets | |
- matplotlib | |
- numpy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Extracted from https://github.com/binder-examples/jupyter-extension/blob/master/postBuild | |
jupyter contrib nbextension install --user | |
jupyter nbextension enable init_cell/main | |
# Notebooks w/ extensions that auto-run code must be "trusted" to work the first time | |
jupyter trust PLC1.ipynb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import matplotlib.pyplot as plt | |
import numpy as np | |
def plot_two_variables(a11, a21, a12, a22, a13, a23, b1, b2, b3, c1, c2): | |
fig = plt.figure(figsize=(12, 6)) | |
x_1 = np.linspace(0, 45, 100) | |
# Mano de Obra | |
x_2 = b1/a21 - a11/a21 * x_1 | |
plt.plot(x_1, x_2, label="Mano de Obra") | |
x_4 = x_2 | |
# Materia Prima | |
x_2 = b2/a22 - a12/a22 * x_1 | |
plt.plot(x_1, x_2, label="Materia Prima") | |
x_4 = np.minimum(x_4, x_2) | |
# Demanda | |
x_2 = b3/a23 + a13/a23 * x_1 | |
plt.plot(x_1, x_2, label="Demanda") | |
x_4 = np.minimum(x_4, x_2) | |
# Sombrear area de interés | |
plt.fill_between(x_1, 0, x_4, color='grey', alpha=0.5) | |
# Optimo | |
z = c1 * x_1 + c2 * x_4 | |
z_x_2 = np.max(z) | |
z_x_1 = np.argmax(z) | |
plt.scatter(x_1[z_x_1], x_4[z_x_1], label="Óptimo", s=100, color="black") | |
# Fijar ticks | |
plt.xticks(np.arange(0, 46, 5)) | |
plt.yticks(np.arange(0, 51, 5)) | |
# Fijar Límites de X e Y | |
plt.ylim(0, 50) | |
plt.xlim(0, 45) | |
plt.legend() | |
plt.tight_layout() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment