Bottle Battles
Published:
This is a blog post about the 2019 High School Mathematical Modeling Contest(HiMCM) Problem B. The problem is about modeling the impact of banning the sale of single-serving plastic water bottles in Concord and San Francisco. To be honest, I have participated in the HiMCM contest in 2019; however, I have not solved this problem well. Therefore, it would be a good opportunity for me to revisit this problem and provide a detailed analysis and solution.
The problem is a multi-criteria decision-making problem, and we use the Analytic Hierarchy Process(AHP) to solve it. The AHP is a structured technique for organizing and analyzing complex decisions, based on mathematics and psychology. It was developed by Thomas L. Saaty in the 1970s and has been extensively studied and refined since then. The AHP is a powerful tool for decision-making, and it has been used in a wide range of applications, including business, engineering, and public policy. In this blog post, we will use the AHP to model the impact of banning single-serving plastic water bottles in Concord and San Francisco. We will analyze the problem, develop a mathematical model, and use Python to implement the model and analyze the results. We will also discuss the limitations of our model and suggest possible extensions and improvements.
Problem Background
A number of communities (campuses, towns, cities, etc.) around the world have proposed and enacted plastic water bottle bans in some form.
In 2013 the small town of Concord, Massachusetts (population approximately 19,000) became the first town or city in the United States to ban the sale of single-serving Polyethylene terephthalate (PET) bottles less than or equal to 1 liter (34 ounces) containing water which is non-sparkling and non-flavored (in other words, plain water). The sale of water in bottles of any size made of other types of plastic or other materials, as well as PET bottles of flavored or sparkling water, soda, tea, juices, and other non-plain water beverages, regardless of size, is allowed.
Concord citizens supporting this action stated various reasons including: concerns of plastic garbage and litter, use of fossil fuels in the production of plastic, product transportation emissions, damage to water-providing aquifers, and beliefs that businesses shouldn’t profit on the sale of a free resource.
Since enactment of Concord’s ban, a handful of other communities in the United States have enacted single-serving water bottle bans, the largest being the city of San Francisco (population approximately 885,000) who banned the sale of single-serving water bottles on city property in 2014. Just recently, the San Fran Francisco Airport decided to comply with its city’s law and banned the sale of single-serving water bottles, making it the first airport to do so.
Not everyone is in favor of these bans, nor does everyone think that these bans will have any impact on the issues they are trying to address. Opponents include the International Bottled Water Association (IBWA) who, after the San Francisco ban, stated that there are unintended consequences to these bans as they may lead to “more packaging, more additives (e.g., sugar, caffeine), and greater environmental impacts than bottled water.” Additionally, as we have seen in recent world news, in some areas (e.g. unavailability/ inaccessibility of fresh water) and under some circumstances (e.g. natural disasters, compromises in water delivery) bottled water is a necessary and critical resource.
- Model the impacts of a ban on the sale of single-serving water bottles in a town or city. Use your model to discuss the impacts of the bans in the Town of Concord and the City of San Francisco.
- Identify the possible impacts (positive and negative) of a ban on the sale of single-serving water bottles within a town or city.
- What information and data do you need to model and measure these impacts? How would you collect this information and these data? (Note: You do not need to actually collect information and data, but need to identify what you need and how you might obtain it.)
- Develop a model or set of models to measure water bottle ban impacts.
- Discuss the application of your model to Concord and San Francisco.
- Address the impacts of a ban on the sale of single-serving water bottles within an airport. How are the impacts similar to and different from a ban in a town or city? How would your initial model for a town or city change, if at all, to model bottle ban impacts within an airport?
- Discuss and recommend possible changes to Concord’s water bottle ban, or other related community measures, that would enhance beneficial impacts and reduce adverse impacts. Use your suggested changes to adjust your impact model. Address whether or not your new model is generalizable to larger communities (e.g. large cities, regions, states, countries).
Analysis
For this blog post, I will only focus on the first and second parts of the problem. I will analyze the impacts of a ban on the sale of single-serving plastic water bottles in Concord, San Francisco, and San Francisco Airport. I will develop a mathematical model using both the Analytic Hierarchy Process(AHP) and the Technique for Order Preference by Similarity to Ideal Solution(TOPSIS) to measure the impacts of the bans and compare the results. I will also discuss the limitations of our model and suggest possible extensions and improvements.
Analytic Hierarchy Process(AHP)
In our analysis, we will use the Analytic Hierarchy Process(AHP) to model the impact of banning single-serving plastic water bottles in Concord and San Francisco. The AHP is a structured technique for organizing and analyzing complex decisions, based on mathematics and psychology.
The AHP involves the following steps:
- Define the decision problem and the criteria for evaluating the alternatives.
- Construct a hierarchy of the decision problem, with the goal at the top, the criteria in the middle, and the alternatives at the bottom.
- Pairwise comparisons of the criteria and alternatives, using a scale of 1 to 9 to indicate the relative importance of each pair.
- Calculate the weights of the criteria and alternatives, based on the pairwise comparisons.
- Evaluate the alternatives based on the criteria weights and the performance of the alternatives.
- Sensitivity analysis to test the robustness of the results.
- Interpret the results and make recommendations.
- Implement the decision.
- Monitor the decision and adjust as necessary.
- Review the decision and learn from the experience.
- Improve the decision-making process.
- Repeat the process for future decisions.
In our case, the decision problem is whether to ban the sale of single-serving plastic water bottles in Concord and San Francisco. The criteria for evaluating the alternatives include environmental impact, economic impact, social impact, and health impact. The alternatives are to ban the sale of single-serving plastic water bottles in Concord, to ban the sale of single-serving plastic water bottles in San Francisco, or to do nothing.
Therefore, we have the following mathematical formulas to calculate the weights of the criteria and alternatives:
- Calculate the weights of the criteria:
- $W_{i} = \frac{1}{n} \sum_{j=1}^{n} w_{ij}$ where $W_{i}$ is the weight of criteria $i$, $n$ is the number of criteria, and $w_{ij}$ is the pairwise comparison of criteria $i$ and $j$.
- $w_{ij}$ is the pairwise comparison of criteria $i$ and $j$.
- Calculate the weights of the alternatives:
- $W_{i} = \frac{1}{n} \sum_{j=1}^{n} w_{ij}$ where $W_{i}$ is the weight of alternative $i$, $n$ is the number of alternatives, and $w_{ij}$ is the pairwise comparison of alternative $i$ and $j$.
- $w_{ij}$ is the pairwise comparison of alternative $i$ and $j$.
- Evaluate the alternatives:
- $V_{i} = \sum_{j=1}^{n} W_{j} \times P_{ij}$ where $V_{i}$ is the value of alternative $i$, $W_{j}$ is the weight of criteria $j$, and $P_{ij}$ is the performance of alternative $i$ on criteria $j$.
- Sensitivity analysis:
- Test the robustness of the results by varying the pairwise comparisons and evaluating the impact on the weights of the criteria and alternatives.
- Interpret the results:
- Make recommendations based on the weights of the criteria and alternatives, and the performance of the alternatives.
- Consistency check:
- Check the consistency of the pairwise comparisons using the consistency ratio.
- Implement the decision:
- Implement the decision based on the recommendations and monitor the results.
- Adjust the decision as necessary based on the feedback.
- Review the decision and learn from the experience.
TOPSIS (Technique for Order Preference by Similarity to Ideal Solution)
Another model, I would like to introduce is the Technique for Order Preference by Similarity to Ideal Solution(TOPSIS). TOPSIS is a multi-criteria decision-making method that is based on the concept of minimizing the distance between the ideal solution and the worst solution, while maximizing the distance between the ideal solution and the alternatives. The TOPSIS method involves the following steps:
- Normalize the decision matrix.
- Calculate the weighted normalized decision matrix.
- Determine the ideal and anti-ideal solutions.
- Calculate the Euclidean distance between each alternative and the ideal and anti-ideal solutions.
- Calculate the relative closeness to the ideal solution for each alternative.
- Rank the alternatives based on the relative closeness to the ideal solution.
- Interpret the results and make recommendations.
- Implement the decision.
- Monitor the decision and adjust as necessary.
- Review the decision and learn from the experience.
Similar to the AHP, the TOPSIS method is a powerful tool for decision-making and has been used in a wide range of applications, including business, engineering, and public policy. In our case, we can also use the TOPSIS method to model the impact of banning single-serving plastic water bottles in Concord and San Francisco. We can compare the results of the AHP and TOPSIS methods to evaluate the robustness of the results and make more informed decisions.
Consequently, we provide the following mathematical formulas to calculate the weights of the criteria and alternatives:
- Calculate the normalized decision matrix:
- $R_{ij} = \frac{X_{ij}}{\sqrt{\sum_{i=1}^{m} X_{ij}^{2}}}$
- $X_{ij}$ is the original decision matrix.
- $m$ is the number of alternatives.
- $R_{ij}$ is the normalized decision matrix.
- $X_{ij}$ is the original decision matrix.
- $m$ is the number of alternatives.
- $R_{ij}$ is the normalized decision matrix.
- $R_{ij} = \frac{X_{ij}}{\sqrt{\sum_{i=1}^{m} X_{ij}^{2}}}$
- Calculate the weighted normalized decision matrix:
- $V_{ij} = w_{j} \times R_{ij}$
- $w_{j}$ is the weight of criteria $j$.
- $V_{ij}$ is the weighted normalized decision matrix.
- $R_{ij}$ is the normalized decision matrix.
- $V_{ij} = w_{j} \times R_{ij}$
- Determine the ideal and anti-ideal solutions:
- $A^{+} = (max(V_{1j}), max(V_{2j}), …, max(V_{mj}))$
- $A^{-} = (min(V_{1j}), min(V_{2j}), …, min(V_{mj}))$
- $A^{+}$ is the ideal solution.
- $A^{-}$ is the anti-ideal solution.
- Calculate the Euclidean distance between each alternative and the ideal and anti-ideal solutions:
- $D^{+}{i} = \sqrt{\sum{j=1}^{n}(V_{ij}-A^{+}_{j})^{2}}$
- $D^{-}{i} = \sqrt{\sum{j=1}^{n}(V_{ij}-A^{-}_{j})^{2}}$
- $D^{+}_{i}$ is the Euclidean distance between alternative $i$ and the ideal solution.
- $D^{-}_{i}$ is the Euclidean distance between alternative $i$ and the anti-ideal solution.
- Calculate the relative closeness to the ideal solution for each alternative:
- $C_{i} = \frac{D^{-}{i}}{D^{+}{i} + D^{-}_{i}}$
- $C_{i}$ is the relative closeness to the ideal solution for alternative $i$.
- $D^{+}_{i}$ is the Euclidean distance between alternative $i$ and the ideal solution.
- $D^{-}_{i}$ is the Euclidean distance between alternative $i$ and the anti-ideal solution.
- Rank the alternatives based on the relative closeness to the ideal solution.
- $C_{i} = \frac{D^{-}{i}}{D^{+}{i} + D^{-}_{i}}$
- Interpret the results:
- Make recommendations based on the relative closeness to the ideal solution and the performance of the alternatives.
Solution
Now is the time to implement the AHP and TOPSIS methods in Python to model the impact of banning single-serving plastic water bottles in Concord and San Francisco. We will use the following Python libraries to implement the models:
Of the greatest importance, we will use the following Python libraries to implement the models:
import numpy as np
import matplotlib.pyplot as plt
Then we set up the random seed for reproducibility since we are using random numbers in our model:
# Setting up random seed for reproducibility
np.random.seed(42)
Next, we implemented both the AHP and TOPSIS methods by establishing the class AHPTOPSISModel:
# Implementing the Analytic Hierarchy Process (AHP) and Technique for Order Preference by Similarity to Ideal Solution (TOPSIS) methods
class AHPTOPSISModel:
# Initialize the model with criteria, sub-criteria, alternatives, weights, scores, and random index (RI)
def __init__(self):
self.criteria = ['Environmental', 'Economic', 'Social', 'Health']
self.sub_criteria = {
'Environmental': ['Plastic Waste Reduction', 'Carbon Footprint', 'Water Source Impact'],
'Economic': ['Local Business Impact', 'Tourism Effect', 'Alternative Product Sales'],
'Social': ['Public Awareness', 'Consumer Convenience', 'Community Engagement'],
'Health': ['Water Consumption Patterns', 'Beverage Choice Impact']
}
self.alternatives = []
self.weights = {'criteria': None}
self.scores = {}
self.RI = {1: 0, 2: 0, 3: 0.58, 4: 0.9, 5: 1.12, 6: 1.24, 7: 1.32, 8: 1.41, 9: 1.45, 10: 1.49}
# Set criteria weights using the pairwise comparison matrix
def set_criteria_weights(self, matrix):
self.weights['criteria'], cr = self._calculate_weights_with_cr(matrix)
consistency_status = "Good" if cr < 0.1 else "Poor"
print(f"Consistency Ratio for criteria: {cr:.4f} - {consistency_status}")
return cr
# Set sub-criteria weights using the pairwise comparison matrix
def set_sub_criteria_weights(self, criterion, matrix):
if criterion not in self.weights:
self.weights[criterion] = {}
self.weights[criterion], cr = self._calculate_weights_with_cr(matrix)
consistency_status = "Good" if cr < 0.1 else "Poor"
print(f"Consistency Ratio for {criterion} sub-criteria: {cr:.4f} - {consistency_status}")
return cr
# Add alternatives to the model
def add_alternative(self, name):
self.alternatives.append(name)
# Set scores for each alternative based on criteria and sub-criteria
def set_alternative_scores(self, alternative, scores):
self.scores[alternative] = scores
# Calculate weights and consistency ratio using the eigenvector method
def _calculate_weights_with_cr(self, matrix):
n = len(matrix)
if n < 2:
return np.array([1.0]), 0.0 # Perfect consistency for 1x1 matrix
eigenvalues, eigenvectors = np.linalg.eig(matrix)
max_index = np.argmax(np.real(eigenvalues))
lambda_max = np.real(eigenvalues[max_index])
weights = np.real(eigenvectors[:, max_index])
weights = weights / np.sum(weights)
ci = (lambda_max - n) / (n - 1)
ri = self.RI.get(n, 1.49) # Use 1.49 for n > 10
cr = ci / ri if ri != 0 else 0.0
return weights, cr
# Calculate the final scores for each alternative based on the weights and scores
def calculate_final_scores(self):
if self.weights['criteria'] is None:
raise ValueError("Criteria weights have not been set.")
final_scores = {}
for alt in self.alternatives:
if alt not in self.scores:
raise ValueError(f"Scores for alternative '{alt}' have not been set.")
score = 0
for i, criterion in enumerate(self.criteria):
if criterion not in self.weights:
print(f"Warning: Weights for '{criterion}' sub-criteria have not been set. Using equal weights.")
sub_weights = np.ones(len(self.sub_criteria[criterion])) / len(self.sub_criteria[criterion])
else:
sub_weights = self.weights[criterion]
for j, sub_criterion in enumerate(self.sub_criteria[criterion]):
if sub_criterion not in self.scores[alt][criterion]:
raise ValueError(f"Score for '{sub_criterion}' in '{criterion}' for alternative '{alt}' is missing.")
score += (
self.weights['criteria'][i] *
sub_weights[j] *
self.scores[alt][criterion][sub_criterion]
)
final_scores[alt] = score
return final_scores
# Rank alternatives based on final scores
def rank_alternatives(self):
scores = self.calculate_final_scores()
return sorted(scores.items(), key=lambda x: x[1], reverse=True)
# Perform sensitivity analysis by randomly perturbing criteria weights
def sensitivity_analysis(self, n_simulations=1000):
base_weights = self.weights['criteria'].copy()
rankings = {alt: [] for alt in self.alternatives}
for _ in range(n_simulations):
new_weights = np.random.dirichlet(base_weights * 10)
self.weights['criteria'] = new_weights
new_ranking = self.rank_alternatives()
for rank, (alt, _) in enumerate(new_ranking):
rankings[alt].append(rank + 1)
self.weights['criteria'] = base_weights
return rankings
# Integration with TOPSIS method for multi-criteria decision analysis
def topsis_normalization(self, decision_matrix):
return decision_matrix / np.sqrt(np.sum(decision_matrix**2, axis=0))
def topsis_weighted_normalized(self, normalized_matrix, weights):
return normalized_matrix * weights
def topsis_ideal_solutions(self, weighted_normalized):
return np.max(weighted_normalized, axis=0), np.min(weighted_normalized, axis=0)
def topsis_distances(self, weighted_normalized, ideal_best, ideal_worst):
s_best = np.sqrt(np.sum((weighted_normalized - ideal_best)**2, axis=1))
s_worst = np.sqrt(np.sum((weighted_normalized - ideal_worst)**2, axis=1))
return s_best, s_worst
def topsis_scores(self, s_best, s_worst):
return s_worst / (s_best + s_worst)
def calculate_topsis_scores(self):
if self.weights['criteria'] is None:
raise ValueError("Criteria weights have not been set.")
# Prepare decision matrix
decision_matrix = []
for alt in self.alternatives:
alt_scores = []
for criterion in self.criteria:
for sub_criterion in self.sub_criteria[criterion]:
alt_scores.append(self.scores[alt][criterion][sub_criterion])
decision_matrix.append(alt_scores)
decision_matrix = np.array(decision_matrix)
# Prepare weights
weights = []
for i, criterion in enumerate(self.criteria):
for j, sub_criterion in enumerate(self.sub_criteria[criterion]):
weights.append(self.weights['criteria'][i] * self.weights[criterion][j])
weights = np.array(weights)
# Apply TOPSIS
normalized = self.topsis_normalization(decision_matrix)
weighted_normalized = self.topsis_weighted_normalized(normalized, weights)
ideal_best, ideal_worst = self.topsis_ideal_solutions(weighted_normalized)
s_best, s_worst = self.topsis_distances(weighted_normalized, ideal_best, ideal_worst)
topsis_scores = self.topsis_scores(s_best, s_worst)
return dict(zip(self.alternatives, topsis_scores))
def rank_alternatives_topsis(self):
scores = self.calculate_topsis_scores()
return sorted(scores.items(), key=lambda x: x[1], reverse=True)
def sensitivity_analysis_topsis(self, n_simulations=1000):
base_weights = self.weights['criteria'].copy()
rankings = {alt: [] for alt in self.alternatives}
for _ in range(n_simulations):
new_weights = np.random.dirichlet(base_weights * 10)
self.weights['criteria'] = new_weights
new_ranking = self.rank_alternatives_topsis()
for rank, (alt, _) in enumerate(new_ranking):
rankings[alt].append(rank + 1)
self.weights['criteria'] = base_weights
return rankings
Since we discussed the implementation of the AHP and TOPSIS methods, we can now proceed to model the impact of banning single-serving plastic water bottles in Concord and San Francisco. However, we can also still define functions for visualizing the results of the models:
# Visualization functions
def visualize_results_AHP(rankings):
alternatives, scores = zip(*rankings)
plt.figure(figsize=(10, 6))
plt.bar(alternatives, scores)
plt.title('Water Bottle Ban Impact Rankings (AHP)')
plt.xlabel('Alternatives')
plt.ylabel('AHP Score')
plt.ylim(0, max(scores) * 1.1)
for i, v in enumerate(scores):
plt.text(i, v, f'{v:.3f}', ha='center', va='bottom')
plt.tight_layout()
plt.legend(['AHP Score'])
plt.show()
def visualize_results_TOPSIS(rankings):
alternatives, scores = zip(*rankings)
plt.figure(figsize=(10, 6))
plt.bar(alternatives, scores)
plt.title('Water Bottle Ban Impact Rankings (TOPSIS)')
plt.xlabel('Alternatives')
plt.ylabel('TOPSIS Score')
plt.ylim(0, max(scores) * 1.1)
for i, v in enumerate(scores):
plt.text(i, v, f'{v:.3f}', ha='center', va='bottom')
plt.tight_layout()
plt.legend(['TOPSIS Score'])
plt.show()
# Visulize the results of AHP and TOPSIS
def visualize_results_comparison(rankings_AHP, rankings_TOPSIS):
alternatives, scores_AHP = zip(*rankings_AHP)
_, scores_TOPSIS = zip(*rankings_TOPSIS)
plt.figure(figsize=(12, 6))
positions = range(1, len(alternatives) + 1)
plt.bar(positions, scores_AHP, width=0.4, align='center', label='AHP', color='b', alpha=0.7)
plt.bar([pos + 0.4 for pos in positions], scores_TOPSIS, width=0.4, align='center', label='TOPSIS', color='r', alpha=0.7)
# Add labels and legend
plt.title('Water Bottle Ban Impact Rankings (AHP vs. TOPSIS)')
plt.xlabel('Alternatives')
plt.ylabel('Score')
plt.xticks([pos + 0.2 for pos in positions], alternatives)
plt.ylim(0, max(max(scores_AHP), max(scores_TOPSIS)) * 1.1)
plt.legend()
plt.tight_layout()
plt.show()
# Visualize the distribution of rankings from sensitivity analysis
def visualize_sensitivity_AHP(sensitivity_results):
plt.figure(figsize=(12, 6))
positions = range(1, len(sensitivity_results) + 1)
box = plt.boxplot([sensitivity_results[alt] for alt in sensitivity_results], positions=positions, patch_artist=True)
colors = plt.cm.Set3(np.linspace(0, 1, len(sensitivity_results)))
for patch, color in zip(box['boxes'], colors):
patch.set_facecolor(color)
# Add labels and legend
plt.title('Sensitivity Analysis: Ranking Distribution (AHP)')
plt.xlabel('Alternatives')
plt.ylabel('Rank')
plt.xticks(positions, sensitivity_results.keys())
plt.ylim(0.5, len(sensitivity_results) + 0.5)
plt.gca().invert_yaxis()
plt.tight_layout()
plt.show()
# plt.savefig('sensitivity_analysis.png') # Save the plot as an image file
def visualize_sensitivity_TOPSIS(sensitivity_results):
plt.figure(figsize=(12, 6))
positions = range(1, len(sensitivity_results) + 1)
box = plt.boxplot([sensitivity_results[alt] for alt in sensitivity_results], positions=positions, patch_artist=True)
colors = plt.cm.Set3(np.linspace(0, 1, len(sensitivity_results)))
for patch, color in zip(box['boxes'], colors):
patch.set_facecolor(color)
# Add labels and legend
plt.title('Sensitivity Analysis: Ranking Distribution (TOPSIS)')
plt.xlabel('Alternatives')
plt.ylabel('Rank')
plt.xticks(positions, sensitivity_results.keys())
plt.ylim(0.5, len(sensitivity_results) + 0.5)
plt.gca().invert_yaxis()
plt.tight_layout()
plt.show()
# plt.savefig('sensitivity_analysis.png') # Save the plot as an image file
# Visualize the distribution of rankings from sensitivity analysis for both AHP and TOPSIS
def visualize_sensitivity_comparison(sensitivity_results_AHP, sensitivity_results_TOPSIS):
plt.figure(figsize=(12, 6))
positions = range(1, len(sensitivity_results_AHP) + 1)
box1 = plt.boxplot([sensitivity_results_AHP[alt] for alt in sensitivity_results_AHP], positions=positions, patch_artist=True, widths=0.4)
positions = [pos + 0.4 for pos in positions]
box2 = plt.boxplot([sensitivity_results_TOPSIS[alt] for alt in sensitivity_results_TOPSIS], positions=positions, patch_artist=True, widths=0.4)
colors = plt.cm.Set3(np.linspace(0, 1, len(sensitivity_results_AHP)))
for patch, color in zip(box1['boxes'], colors):
patch.set_facecolor(color)
for patch, color in zip(box2['boxes'], colors):
patch.set_facecolor(color)
# Add labels and legend
plt.title('Sensitivity Analysis: Ranking Distribution (AHP vs. TOPSIS)')
plt.xlabel('Alternatives')
plt.ylabel('Rank')
plt.xticks([pos + 0.2 for pos in range(1, len(sensitivity_results_AHP) + 1)], sensitivity_results_AHP.keys())
plt.ylim(0.5, len(sensitivity_results_AHP) + 0.5)
plt.legend(['AHP', 'TOPSIS'])
plt.gca().invert_yaxis()
plt.tight_layout()
plt.show()
Now, we can proceed to model the impact of banning single-serving plastic water bottles in Concord and San Francisco using the AHP and TOPSIS methods. We will define the criteria, sub-criteria, alternatives, and scores for each alternative:
We use an example to illustrate the implementation of the AHP and TOPSIS methods, but one have to note that the data used in this example is randomly generated and does not represent the actual impact of banning single-serving plastic water bottles in Concord and San Francisco. Therefore, one should collect real data to model the impact of the bans accurately.
# Example usage
model = AHPTOPSISModel()
# Set criteria weights, for better results, one should consider the real data
criteria_matrix = np.array([
[1, 2, 3, 2],
[1/2, 1, 2, 1],
[1/3, 1/2, 1, 1],
[1/2, 1, 1, 1]
])
cr = model.set_criteria_weights(criteria_matrix)
# Set sub-criteria weights for all criteria
for criterion in model.criteria:
n = len(model.sub_criteria[criterion])
matrix = np.ones((n, n))
for i in range(n):
for j in range(i+1, n):
matrix[i, j] = np.random.uniform(1, 3)
matrix[j, i] = 1 / matrix[i, j]
cr = model.set_sub_criteria_weights(criterion, matrix)
# Add alternatives
model.add_alternative('Concord')
model.add_alternative('San Francisco')
model.add_alternative('SF Airport')
# Set alternative scores (example for all alternatives)
for alt in model.alternatives:
scores = {}
for criterion in model.criteria:
scores[criterion] = {sub: np.random.uniform(0, 1) for sub in model.sub_criteria[criterion]}
model.set_alternative_scores(alt, scores)
Finally, we calculate and visualize the results of the AHP and TOPSIS models:
# Calculate and visualize AHP rankings
ahp_rankings = model.rank_alternatives()
visualize_results_AHP(ahp_rankings)
# Calculate and visualize TOPSIS rankings
topsis_rankings = model.rank_alternatives_topsis()
visualize_results_TOPSIS(topsis_rankings)
visualize_results_comparison(ahp_rankings, topsis_rankings)
# Perform sensitivity analysis for both methods
ahp_sensitivity = model.sensitivity_analysis()
topsis_sensitivity = model.sensitivity_analysis_topsis()
visualize_sensitivity_AHP(ahp_sensitivity)
visualize_sensitivity_TOPSIS(topsis_sensitivity)
visualize_sensitivity_comparison(ahp_sensitivity, topsis_sensitivity)
# Compare AHP and TOPSIS results
print("AHP Rankings:", ahp_rankings)
print("TOPSIS Rankings:", topsis_rankings)
Therefore, we can have the following figure for the water bottle ban impact rankings using the AHP method:

While the result of the water bottle ban impact rankings using the TOPSIS method is shown below:

In comparison, the figure below shows the comparison of the water bottle ban impact rankings using both the AHP and TOPSIS methods:

We may note that even using randomly generated data, the AHP and TOPSIS methods provide the same rankings for the alternatives. Therefore, we may conclude that the impact of banning single-serving plastic water bottles in Concord and San Francisco is similar based on the criteria and sub-criteria used in our model. However, one should collect real data to model the impact of the bans accurately and make informed decisions.
We have also performed sensitivity analysis for both the AHP and TOPSIS methods to test the robustness of the results. The distribution of rankings from the sensitivity analysis is shown below:

While the distribution of rankings from the sensitivity analysis for the TOPSIS method is shown below:

We may note that from the box plot of the sensitivity analysis for the TOPSIS that there is no “box” for all three alternatives. This is because the TOPSIS method does not consider the consistency of the pairwise comparisons, unlike the AHP method. Therefore, the TOPSIS method may provide more robust results in some cases, but it may also be less transparent and harder to interpret.
Finally, the comparison of the distribution of rankings from the sensitivity analysis for both the AHP and TOPSIS methods is shown below:

From the comparison of the sensitivity analysis results, we may conclude that the AHP and TOPSIS methods provide similar rankings for the alternatives, but the TOPSIS method may be more robust and less sensitive to the pairwise comparisons. Therefore, one should consider the trade-offs between transparency, interpretability, and robustness when choosing between the AHP and TOPSIS methods for multi-criteria decision-making problems.
Last but not least, we also apply consistency check for the pairwise comparisons using the consistency ratio. The consistency ratio is calculated as follows:
Consistency Ratio for criteria: 0.0170 - Good
Consistency Ratio for Environmental sub-criteria: 0.0150 - Good
Consistency Ratio for Economic sub-criteria: 0.0597 - Good
Consistency Ratio for Social sub-criteria: 0.0011 - Good
Consistency Ratio for Health sub-criteria: 0.0000 - Good
The consistency ratio for the criteria and sub-criteria is less than 0.1, which indicates good consistency in the pairwise comparisons. Therefore, we may conclude that the AHP and TOPSIS methods provide robust and reliable results for modeling the impact of banning single-serving plastic water bottles in Concord and San Francisco.
Limitations
The model we have developed has several limitations that should be considered when interpreting the results. Some of the limitations include:
- The model is based on randomly generated data and does not represent the actual impact of banning single-serving plastic water bottles in Concord and San Francisco. Therefore, one should collect real data to model the impact of the bans accurately.
- The model assumes that the criteria and sub-criteria are equally important, which may not be the case in practice. One should consider the relative importance of the criteria and sub-criteria when making decisions.
- The model does not consider the trade-offs between the criteria and sub-criteria, which may affect the results. One should consider the trade-offs when evaluating the impact of the bans.
- The model does not consider the uncertainty and variability in the data, which may affect the robustness of the results. One should perform sensitivity analysis to test the robustness of the results.
Therefore, one should consider the following suggestions for improving the model and making more informed decisions:
- Collect real GIS data to model the impact of banning single-serving plastic water bottles in Concord and San Francisco accurately.
- Consider the relative importance of the criteria and sub-criteria when making decisions.
- Evaluate the trade-offs between the criteria and sub-criteria to make more informed decisions.
Conclusion
In conclusion, we have modeled the impact of banning single-serving plastic water bottles in Concord and San Francisco using the Analytic Hierarchy Process(AHP) and the Technique for Order Preference by Similarity to Ideal Solution(TOPSIS). We have developed a mathematical model, implemented the model in Python, and analyzed the results. We have also discussed the limitations of our model and suggested possible extensions and improvements.
Comments