Introduction
In this tutorial, we'll explore how to build a simulation model for analyzing automotive production decisions, inspired by Stellantis's strategic move to produce Chinese EVs in Mexico and Canada. This simulation will help us understand factors that influence manufacturing location decisions, particularly focusing on supply chain logistics, cost analysis, and market accessibility. We'll use Python with pandas and matplotlib to create a decision-making framework that could be applied to real-world automotive manufacturing scenarios.
Prerequisites
- Basic understanding of Python programming
- Python installed on your system
- Required libraries: pandas, matplotlib, numpy
- Text editor or IDE for writing code
Step-by-Step Instructions
1. Setting Up the Environment
1.1 Install Required Libraries
First, we need to install the necessary Python libraries. Open your terminal or command prompt and run:
pip install pandas matplotlib numpy
Why this step? These libraries provide the foundation for data manipulation (pandas), visualization (matplotlib), and numerical operations (numpy) needed for our simulation.
1.2 Import Libraries
Create a new Python file and import the required modules:
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
Why this step? These imports give us access to the tools we'll need to create our data structures, perform calculations, and visualize our results.
2. Creating the Manufacturing Decision Framework
2.1 Define Manufacturing Parameters
Let's create a DataFrame that represents key factors affecting manufacturing decisions:
# Define manufacturing factors and their weights
factors = {
'Production_Cost': 0.25,
'Supply_Chain': 0.20,
'Market_Access': 0.25,
'Regulatory_Compliance': 0.15,
'Infrastructure': 0.15
}
# Create DataFrame with country data
countries_data = {
'Country': ['United States', 'Mexico', 'Canada'],
'Production_Cost': [0.7, 0.5, 0.6],
'Supply_Chain': [0.6, 0.8, 0.7],
'Market_Access': [0.9, 0.8, 0.7],
'Regulatory_Compliance': [0.8, 0.7, 0.9],
'Infrastructure': [0.9, 0.7, 0.8]
}
countries_df = pd.DataFrame(countries_data)
print(countries_df)
Why this step? This creates a structured dataset that represents different countries' scores across key decision factors, similar to how Stellantis might evaluate locations.
2.2 Calculate Weighted Scores
Now, we'll calculate the weighted scores for each country:
# Calculate weighted scores
for country in countries_df['Country']:
score = 0
for factor, weight in factors.items():
score += countries_df.loc[countries_df['Country'] == country, factor].values[0] * weight
countries_df.loc[countries_df['Country'] == country, 'Decision_Score'] = score
print(countries_df)
Why this step? This weighted scoring system helps us quantify and compare manufacturing decisions, similar to how automotive companies might evaluate locations based on multiple criteria.
3. Visualizing the Decision Matrix
3.1 Create a Bar Chart
Visualize the decision scores to easily compare countries:
# Create bar chart
plt.figure(figsize=(10, 6))
plt.bar(countries_df['Country'], countries_df['Decision_Score'], color=['red', 'blue', 'green'])
plt.title('Manufacturing Location Decision Scores')
plt.xlabel('Country')
plt.ylabel('Decision Score')
plt.ylim(0, 1)
# Add value labels on bars
for i, (country, score) in enumerate(zip(countries_df['Country'], countries_df['Decision_Score'])):
plt.text(i, score + 0.02, f'{score:.2f}', ha='center')
plt.tight_layout()
plt.show()
Why this step? Visualization makes it easier to understand the relative advantages of each location, helping stakeholders quickly grasp the decision framework.
3.2 Create a Heatmap of Factors
Display how each factor contributes to the decision:
# Create heatmap
plt.figure(figsize=(10, 6))
# Prepare data for heatmap
heatmap_data = countries_df[['Production_Cost', 'Supply_Chain', 'Market_Access', 'Regulatory_Compliance', 'Infrastructure']]
plt.imshow(heatmap_data, cmap='coolwarm', aspect='auto')
plt.colorbar(label='Score (0-1)')
plt.xticks(range(len(heatmap_data.columns)), heatmap_data.columns, rotation=45)
plt.yticks(range(len(heatmap_data.index)), countries_df['Country'])
plt.title('Factor Scores by Country')
plt.tight_layout()
plt.show()
Why this step? The heatmap provides a comprehensive view of how each country performs across all factors, offering insights into why certain locations might be preferred.
4. Advanced Analysis with Scenario Planning
4.1 Simulate Different Scenarios
Let's simulate how changes in factors might affect decisions:
# Create scenario analysis
scenarios = {
'Base_Case': [0.7, 0.5, 0.6, 0.8, 0.9],
'High_Market_Access': [0.7, 0.5, 0.9, 0.8, 0.9],
'Low_Regulatory': [0.7, 0.5, 0.6, 0.5, 0.9]
}
scenario_df = pd.DataFrame(scenarios, index=['Production_Cost', 'Supply_Chain', 'Market_Access', 'Regulatory_Compliance', 'Infrastructure'])
print('Scenario Analysis:')
print(scenario_df)
Why this step? Scenario planning helps companies understand how sensitive their decisions are to changes in key variables, which is crucial for strategic planning like Stellantis's international expansion.
4.2 Generate Decision Recommendations
Create a function to automatically recommend the best location:
def recommend_location(df):
"""Recommend the best manufacturing location based on weighted scores"""
best_location = df.loc[df['Decision_Score'].idxmax(), 'Country']
best_score = df['Decision_Score'].max()
return best_location, best_score
# Get recommendation
recommended_location, score = recommend_location(countries_df)
print(f'Recommended Location: {recommended_location} (Score: {score:.2f})')
Why this step? This automated recommendation system can be integrated into decision-making processes, providing quick insights from complex data sets.
5. Exporting Results
5.1 Save Analysis to CSV
Export the results for further analysis or sharing:
# Export results
countries_df.to_csv('manufacturing_decision_analysis.csv', index=False)
print('Analysis saved to manufacturing_decision_analysis.csv')
Why this step? Saving results allows for future reference, collaboration with team members, and integration with other business intelligence tools.
Summary
In this tutorial, we've built a simulation framework for analyzing automotive manufacturing location decisions. We created a weighted scoring system that evaluates countries based on key factors like production costs, supply chain efficiency, market access, regulatory compliance, and infrastructure. Using Python libraries like pandas and matplotlib, we visualized the decision matrix and performed scenario analysis to understand how different variables might influence the final choice.
This framework mirrors the strategic thinking behind Stellantis's decision to focus on Mexico and Canada rather than the US for Chinese EV production. By quantifying these factors, companies can make more informed decisions about international expansion, supply chain optimization, and market positioning. The simulation can be easily extended with additional factors, updated with real data, or integrated into larger business intelligence systems.



