Professional Documents
Culture Documents
TP2: Recherche Opérationnelle: 1. Bar and Pie Charts
TP2: Recherche Opérationnelle: 1. Bar and Pie Charts
Source:
R. 1. https://matplotlib.org/3.5.0/gallery/lines_bars_and_markers/barchart.html
R. 2. https://www.geeksforgeeks.org/plot-a-pie-chart-in-python-using-matplotlib/
This example shows a how to create a grouped bar chart and how to annotate bars with labels.
import matplotlib.pyplot as plt
import numpy as np
fig, ax = plt.subplots()
rects1 = ax.bar(x - width/2, men_means, width, label='Men')
rects2 = ax.bar(x + width/2, women_means, width, label='Women')
# Add some text for labels, title and custom x-axis tick labels, etc.
ax.set_ylabel('Scores')
ax.set_title('Scores by group and gender')
ax.set_xticks(x, labels)
ax.legend()
ax.bar_label(rects1, padding=3)
ax.bar_label(rects2, padding=3)
fig.tight_layout()
plt.show()
Result:
Année universitaire: 2021-2022
Filières : 4éme G.Indus /GPMC
Module : Recherche opérationnelle
Source:
R. 3. https://fr.acervolima.com/python-programmation-lineaire-dans-la-pate-2/
R. 4. https://www.analyticsvidhya.com/blog/2022/03/linear-programming-discrete-
optimization-with-pulp/
# Objective Function
Lp_prob += 3 * x + 5 * y
# Constraints:
Lp_prob += 2 * x + 3 * y >= 12 , "C_1" # The constraint , constraint name
Lp_prob += -x + y <= 3 , "C_2" # The constraint , constraint name
Lp_prob += x >= 4 , "C_3" # The constraint , constraint name
Lp_prob += y <= 3 , "C_4" # The constraint , constraint name
Output:
x= 6.0 y= 0.0 z= 18.0
C_1 0.0 -12
C_2 -9.0 -3
C_3 2.0 -4
C_4 -3.0 -3
Année universitaire: 2021-2022
Filières : 4éme G.Indus /GPMC
Module : Recherche opérationnelle
Travail A faire:
En utilisant les références et les bibliothèques précédentes, créer deux programmes sous
Python pour résoudre les programmes linéaires: gestion des équipes (Exercice 6) et programme
de production (Exercice 7) comme indiqué sur les figures suivantes: