0% found this document useful (0 votes)
8 views6 pages

Project Modelisation LES DOMAINES AGRICOLES

This document analyzes the optimization of red fruit production in greenhouses, focusing on maximizing yield and quality while minimizing costs and environmental impact. It details various fruit types, production scenarios, constraints, and a mathematical model for profit maximization using linear programming. The optimal strategy identified yields a total profit of $11,509,792.5.

Uploaded by

mehdi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views6 pages

Project Modelisation LES DOMAINES AGRICOLES

This document analyzes the optimization of red fruit production in greenhouses, focusing on maximizing yield and quality while minimizing costs and environmental impact. It details various fruit types, production scenarios, constraints, and a mathematical model for profit maximization using linear programming. The optimal strategy identified yields a total profit of $11,509,792.5.

Uploaded by

mehdi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Optimization of Red Fruit Production in Greenhouses

May 2024

1 Context
The optimization of red fruit production in greenhouses is crucial for maximizing yield and fruit quality while minimizing
costs and environmental impact. This document presents an in-depth analysis of the various fruit types, planting methods,
production scenarios, and specific constraints associated.

2 Types of Fruits
The red fruits analyzed in this study include:
• Raspberry

• Blackberry
The specific varieties included are:
• Variety 1
• Variety 2

• Variety 3
• Variety 4
The types of plantations and planting periods are essential for optimized production. The plantations are classified
as follows:

• Plantation 1
• Plantation 2
• Plantation 3

• Plantation 4
Months (planting and harvesting periods):
• April
• May

• June
• July
• August

• October
• November

3 Production Scenarios
Fifteen distinct scenarios have been developed to model different production strategies (Fruit, Fruit Variety, Fruit Planting
Type, and Planting Month).

1
4 Constraints and Sector-Specific Requirements
Certain constraints must be considered for effective optimization:
• Scenarios 4 and 5: Can only be executed in sector 6.
• Scenarios 12, 13, 14, 18: Limited to sector 5 and greenhouses of less than 2.87 hectares.

• Bonus: Production must not exceed a predefined threshold, with adjustable parameters for this threshold.

5 Modeling
The modeling uses decision variables represented by a three-dimensional tensor of binary variables. The details of the
modeling are as follows:

5.1 Decision Variables


A dictionary that can be interpreted as a three-dimensional tensor of binary variables such that:

X[ijk] = 1 if greenhouse i is chosen for scenario j and week k.

5.2 Objective Function


The objective function to maximize is given by:
X
Margin(greenhouse, scenario, week) × X[greenhouse, scenario, week]
greenhouse, scenario, week

5.3 Mathematical Formulation


 
ngreenhouse 37
X X X X
maximize  (X(i, j, t) · CA(i, j, t)) − (X(i, j, t) · CV (i, j))
i=1 j∈scenarios t∈scenario weeks(j) t=0

subject to:
X(i, j, t) = 1, ∀i ∈ {1, . . . , ngreenhouse }
X(i, 5, t) = 0, X(i, 4, t) = 0, X(i, j, t) = 0, ∀i ∈ {1, . . . , ngreenhouse }, i∈
/ sector greenhouse(6), ∀t ∈ scenario weeks(5)
X(i, j, t) = 0, ∀i ∈ {1, . . . , ngreenhouse }, i∈
/ sector greenhouse(6), ∀t ∈ scenario weeks(4)
∀i ∈ {1, . . . , ngreenhouse }, i∈
/ sector greenhouse(5), ∀j ∈ {12, 13, 14, 18}, ∀t ∈ scenario weeks(j)
∀i ∈ {1, . . . , ngreenhouse }, greenhouse surface(i) > 2.87, ∀j ∈ {12, 13, 14, 18}, ∀t ∈ scenario weeks(j)

5.4 Revenue and Variable Cost


We need to calculate revenue and variable cost per (greenhouse, scenario, and planting week).
37
X

CA(i, j, t ) = prod(j, t) × surface(i) × price(j, t′ + t + delay(j)) (1)
t=0

CV (i, j) = surface(i) × Charges(j) (2)


with: i is the greenhouse, j is the scenario, and t′ is the planting week.

6 Explanation of the Profit Maximization Code


The necessary data comes from four CSV files: Simulation.csv, Charges var.csv, Prices.csv, and Production.csv.

6.1 Importing Libraries and Reading CSV Files


The code begins by importing the necessary libraries (pandas for data manipulation and PuLP for linear programming)
and reading the CSV files containing the data.

6.2 Data Extraction


The data from the CSV files is converted into lists of tuples for easier manipulation.

2
6.3 Initialization of Scenario and Greenhouse Lists
The code initializes the lists of scenario and greenhouse indices.

6.4 Definition of Utility Functions


Several functions are defined to extract the necessary information from the data:

• Function delai(j): Returns the delay for a given scenario.


• Function prix(j, t, t1, t2): Returns the price for a given scenario and a specific period.
• Function surface(i): Returns the surface area of the given greenhouse.

• Function prod(j, t): Returns the production for a given scenario and a specific period.
• Function Charges(j): Returns the variable costs for a given scenario.
• Function CV(i, j): Computes the variable costs for a given greenhouse and scenario.

• Function CA(i, j, t1): Computes the revenue for a given greenhouse, scenario, and period.
• Function scenario week(j): Returns the weeks where production is not zero for a given scenario.
• Function scenario week1(j): Returns the weeks (index - 1) where production is not zero for a given scenario.
• Function secteur serre(i): Returns the indices of greenhouses for a given sector.

6.5 Initialization of the Linear Programming Problem


Creation of the maximization problem using PuLP.

6.6 Definition of Decision Variables


Definition of binary decision variables.

6.7 Insertion of the Objective Function


Definition of the objective function to maximize profit.

6.8 Adding Constraints & Solving the Problem


Adding the necessary constraints and solving the problem using PuLP.

6.9 Displaying the Results


Displaying the decision variables and the objective value.

6.10 Solution Analysis


• Scenario 12 is optimal for all greenhouses in week 10. This may be due to a favorable combination of costs,
prices, and production for this particular scenario at that time.

• All greenhouses are used for the same scenario. This uniformity may indicate consistency in production and
market conditions that favor scenario 12 in week 10.

6.11 Objective Achieved


The total profit of $11,509,792.5 represents the best solution found by the model, indicating an optimal strategy for
allocating crops to greenhouses.

6.12 Conclusion
This code implements a linear programming approach to optimize greenhouse usage and maximize profit. By respecting
the specified constraints and using the provided data, it determines the best allocation of crops over multiple weeks to
achieve maximum profit.

6.13 The Source Code

3
import pandas as pd
import pulp as pl

#Les données sont stockées sous forme d'une liste des tuples et de même ordre que celui étant dans les fichiers.

# Extraction des données du fichier Simulation.csv :


simulation = pd.read_csv("Simulation.csv")
indexsi = []
for col in simulation.columns:
indexsi.append(col)
colonnes = simulation[indexsi]
simulation_valeurs = list(map(tuple, colonnes.values))

# Extraction des données du fichier Charges_var.csv :


charges = pd.read_csv("Charges_var.csv")
indexch = []
for col in charges.columns:
indexch.append(col)
colonnesc = charges[indexch]
charges_valeurs = list(map(tuple, colonnesc.values))

# Extraction des données du fichier Prices.csv :


prices = pd.read_csv("Prices.csv")
indexpri = []
for col in prices.columns:
indexpri.append(col)
colonnespr = prices[indexpri]
prices_valeurs = list(map(tuple, colonnespr.values))

# Extraction des données du fichier Production.csv :


production = pd.read_csv("Production.csv")
indexpro = []
for col in production.columns:
indexpro.append(col)
colonnesp = production[indexpro]
production_valeurs = list(map(tuple, colonnesp.values))

# Liste des indices des scénarios :


scenarios = []
for k in production_valeurs:
scenarios.append(k[0])

# Liste des serres :


serres = []
for k in simulation_valeurs:
serres.append(k[1])

# Fonction delai(j) :
def delai(j):
if j in scenarios :
for k in production_valeurs:
if k[0]==j: return k[6]
return 0

# Fonction prix(j, t + t' + delai(j)) :


def prix(j, t, t1, t2):
m = t + t1 + t2
if m>0 and m<=90:
if j in scenarios:
if (j>= 1 and j<=8) or j==13:
return prices_valeurs[0][m]
return prices_valeurs[1][m]
return 0
return 0

# Fonction surface(i) :
def surface(i):
for k in simulation_valeurs:
if k[1]==i:
return k[2]
return 0

# Fonction prod(j,t) :
def prod(j,t):
if t==0 : return 0
if t>=38 : return 0
t1=t+7
if j in scenarios:
for k in production_valeurs:
if k[0]==j : return k[t1]
return 0
# Fonction Charges(j) :
def Charges(j):
if j in scenarios:
for k in charges_valeurs:
if j ==k[0] : return k[6]
return 0

# Fonction CV(i,j) :
def CV(i,j):
return surface(i+1)*Charges(j+1)

# Fonction CA(i, j, t') :

def CA(i, j, t1):


S = 0
t2 = delai(j+1)
for t in range(38):
S += prod(j+1,t)*surface(i+1)*prix(j+1, t, t1+1, t2)
return S

# Résolution du problème :

# Implémentation de la fonction scénario_week(j) :

def scenario_week(j):
l=[]
if j in scenarios:
for k in production_valeurs:
if j==k[0]:
for t in range (1,38):
if k[t+7] != 0:
l.append(t)
return l
# Fonction qui retourne la liste des indices -1 (t-1, avec t indice de semaine) de semaines étant non nulles pour un scénario j:
def scenario_week1(j):
l=[]
if j in scenarios:
for k in production_valeurs:
if j==k[0]:
for t in range (1,38):
if k[t+7] != 0:
l.append(t-1)
return l

# Implémentation de la fonction secteur_serre(i) :


def secteur_serre(i):
l=[]
for k in simulation_valeurs:
if k[0]==i:
l.append(k[1]-1)
return l

# Initialisation du problème :

problème = pl.LpProblem("Maximisation", pl.LpMaximize)

#Implémentation du variable de décision :


X = pl.LpVariable.dicts("X", ((i, j, k) for i in range(24) for j in range(15) for k in range(37)),
lowBound=0, upBound=1, cat='Binary')

# Insertion de la fonction objective :

P = pl.lpSum(X[i, j, t] * (CA(i, j, t) - CV(i, j)) for i in range(24) for j in range(15) for t in scenario_week1(j+1)
if (i, j, t) in X)
problème.setObjective(P)

# Implémentation des contraintes :


LC3 = [9, 10, 11, 13]

for i in range(24):
problème += pl.lpSum(X[i, j, t] for j in range(15) for t in range(37) ) == 1
if i not in secteur_serre(6):
for t in scenario_week1(5):
problème += X[i, 4, t] == 0
for t1 in scenario_week1(4):
problème += X[i, 3, t1] == 0
if i not in secteur_serre(5):
for j in LC3 :
for t in scenario_week1(j+1) :
problème += X[i, j, t] == 0
if surface(i) > 2.87:
for j in LC3 :
for t in scenario_week1(j+1):
problème += X[i, j, t] ==0

problème.solve()

# Liste des tuples qui donnent (serre, scénario, semaine) :


liste_indices = []
for i in range(24):
for j in range(15):
for k in range(37) :
if pl.value(X[i,j,k])!=0:
print(f"X[{i}, {j}, {k}] = {pl.value(X[i,j,k])}")
liste_indices.append((i+1, j+1, k+1))
print(pl.value(problème.objective))
print(f"Liste des indices (serre, scénario, semaine) : {liste_indices}")

You might also like