Update app.py
Browse files
app.py
CHANGED
|
@@ -3,23 +3,28 @@ import numpy as np
|
|
| 3 |
|
| 4 |
# Optimization function
|
| 5 |
def optimize_process(resource_allocation, machine_efficiency, production_goal, time_frame, waste_tolerance):
|
| 6 |
-
#
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
expected_output = machines_needed * time_frame * machine_efficiency
|
| 11 |
waste_output = (expected_output * waste_tolerance) / 100
|
| 12 |
|
| 13 |
-
#
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
return {
|
| 18 |
'Machines Needed': machines_needed,
|
| 19 |
'Expected Output': expected_output,
|
| 20 |
'Waste Output': waste_output,
|
| 21 |
'Efficiency Improvement Needed': efficiency_improvement_needed,
|
| 22 |
-
'
|
|
|
|
| 23 |
}
|
| 24 |
|
| 25 |
# Streamlit App Layout
|
|
@@ -33,7 +38,7 @@ This tool helps you **optimize your manufacturing processes** by adjusting **res
|
|
| 33 |
with st.sidebar:
|
| 34 |
st.header("π§ Enter Manufacturing Parameters")
|
| 35 |
resource_allocation = st.number_input("π’ Number of machines available", min_value=1, max_value=100, value=10, step=1)
|
| 36 |
-
machine_efficiency = st.slider("βοΈ Machine Efficiency (%)", min_value=
|
| 37 |
production_goal = st.number_input("π Desired production goal (units)", min_value=1, max_value=1000, value=100, step=1)
|
| 38 |
time_frame = st.number_input("β³ Production time frame (hours)", min_value=1, max_value=24, value=8, step=1)
|
| 39 |
waste_tolerance = st.slider("β»οΈ Maximum waste tolerance (%)", min_value=0, max_value=100, value=5)
|
|
@@ -43,14 +48,20 @@ st.subheader("π Optimization Results")
|
|
| 43 |
|
| 44 |
if st.button("π Optimize Process"):
|
| 45 |
# Get optimization results
|
| 46 |
-
optimized_output = optimize_process(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
|
| 48 |
# Display the optimized configuration
|
| 49 |
st.write(f"### π οΈ Optimized Configuration:")
|
| 50 |
-
st.write(f"**Machines Needed**: {optimized_output['Machines Needed']}")
|
| 51 |
st.write(f"**Expected Output**: {optimized_output['Expected Output']} units")
|
| 52 |
-
st.write(f"**Expected Waste**: {optimized_output['Waste Output']} units")
|
| 53 |
-
st.write(f"**Efficiency Improvement Needed**: {optimized_output['Efficiency Improvement Needed']}%")
|
| 54 |
st.write(f"**Recommendation**: {optimized_output['Optimization Recommendation']}")
|
| 55 |
|
| 56 |
# Generate Optimization Report
|
|
@@ -62,12 +73,12 @@ if st.button("π Optimize Process"):
|
|
| 62 |
- **Resource Allocation**: The number of machines available is adequate, but you could potentially increase the machine count to optimize the process.
|
| 63 |
|
| 64 |
### Suggestions for Improvement:
|
| 65 |
-
1. **Improve Machine Efficiency**: A **{optimized_output['Efficiency Improvement Needed']}%** increase in machine efficiency will help meet the desired production standards.
|
| 66 |
2. **Increase Machines**: Allocating more machines could help meet the production goal faster and reduce the time required.
|
| 67 |
3. **Reduce Downtime**: Consider adjusting shift lengths or optimizing machine usage to reduce downtime and improve efficiency.
|
| 68 |
|
| 69 |
### Next Steps:
|
| 70 |
-
- Aim to **improve machine efficiency
|
| 71 |
- **Monitor waste** closely to reduce it further and ensure the production process remains efficient.
|
| 72 |
- Review your **production goals** to ensure you are using the most efficient configuration of resources.
|
| 73 |
""")
|
|
|
|
| 3 |
|
| 4 |
# Optimization function
|
| 5 |
def optimize_process(resource_allocation, machine_efficiency, production_goal, time_frame, waste_tolerance):
|
| 6 |
+
# Calculate current production capacity
|
| 7 |
+
current_capacity = resource_allocation * machine_efficiency * time_frame
|
| 8 |
+
machines_needed = np.ceil(production_goal / (machine_efficiency * time_frame))
|
| 9 |
+
expected_output = min(current_capacity, production_goal)
|
|
|
|
| 10 |
waste_output = (expected_output * waste_tolerance) / 100
|
| 11 |
|
| 12 |
+
# Determine realistic efficiency improvement recommendation
|
| 13 |
+
if current_capacity < production_goal:
|
| 14 |
+
required_efficiency = production_goal / (resource_allocation * time_frame)
|
| 15 |
+
realistic_efficiency = min(95, required_efficiency * 100) # Cap realistic efficiency at 95%
|
| 16 |
+
efficiency_improvement_needed = max(0, realistic_efficiency - machine_efficiency * 100)
|
| 17 |
+
else:
|
| 18 |
+
realistic_efficiency = machine_efficiency * 100
|
| 19 |
+
efficiency_improvement_needed = 0
|
| 20 |
+
|
| 21 |
return {
|
| 22 |
'Machines Needed': machines_needed,
|
| 23 |
'Expected Output': expected_output,
|
| 24 |
'Waste Output': waste_output,
|
| 25 |
'Efficiency Improvement Needed': efficiency_improvement_needed,
|
| 26 |
+
'Recommendation Efficiency': realistic_efficiency,
|
| 27 |
+
'Optimization Recommendation': f"Machines efficiency should be at least {realistic_efficiency:.1f}% for the best results."
|
| 28 |
}
|
| 29 |
|
| 30 |
# Streamlit App Layout
|
|
|
|
| 38 |
with st.sidebar:
|
| 39 |
st.header("π§ Enter Manufacturing Parameters")
|
| 40 |
resource_allocation = st.number_input("π’ Number of machines available", min_value=1, max_value=100, value=10, step=1)
|
| 41 |
+
machine_efficiency = st.slider("βοΈ Machine Efficiency (%)", min_value=50, max_value=95, value=80, step=1) # Max efficiency capped at 95%
|
| 42 |
production_goal = st.number_input("π Desired production goal (units)", min_value=1, max_value=1000, value=100, step=1)
|
| 43 |
time_frame = st.number_input("β³ Production time frame (hours)", min_value=1, max_value=24, value=8, step=1)
|
| 44 |
waste_tolerance = st.slider("β»οΈ Maximum waste tolerance (%)", min_value=0, max_value=100, value=5)
|
|
|
|
| 48 |
|
| 49 |
if st.button("π Optimize Process"):
|
| 50 |
# Get optimization results
|
| 51 |
+
optimized_output = optimize_process(
|
| 52 |
+
resource_allocation,
|
| 53 |
+
machine_efficiency / 100,
|
| 54 |
+
production_goal,
|
| 55 |
+
time_frame,
|
| 56 |
+
waste_tolerance
|
| 57 |
+
)
|
| 58 |
|
| 59 |
# Display the optimized configuration
|
| 60 |
st.write(f"### π οΈ Optimized Configuration:")
|
| 61 |
+
st.write(f"**Machines Needed**: {int(optimized_output['Machines Needed'])}")
|
| 62 |
st.write(f"**Expected Output**: {optimized_output['Expected Output']} units")
|
| 63 |
+
st.write(f"**Expected Waste**: {optimized_output['Waste Output']:.2f} units")
|
| 64 |
+
st.write(f"**Efficiency Improvement Needed**: {optimized_output['Efficiency Improvement Needed']:.2f}%")
|
| 65 |
st.write(f"**Recommendation**: {optimized_output['Optimization Recommendation']}")
|
| 66 |
|
| 67 |
# Generate Optimization Report
|
|
|
|
| 73 |
- **Resource Allocation**: The number of machines available is adequate, but you could potentially increase the machine count to optimize the process.
|
| 74 |
|
| 75 |
### Suggestions for Improvement:
|
| 76 |
+
1. **Improve Machine Efficiency**: A **{optimized_output['Efficiency Improvement Needed']:.2f}%** increase in machine efficiency will help meet the desired production standards.
|
| 77 |
2. **Increase Machines**: Allocating more machines could help meet the production goal faster and reduce the time required.
|
| 78 |
3. **Reduce Downtime**: Consider adjusting shift lengths or optimizing machine usage to reduce downtime and improve efficiency.
|
| 79 |
|
| 80 |
### Next Steps:
|
| 81 |
+
- Aim to **improve machine efficiency to {optimized_output['Recommendation Efficiency']:.1f}%** for optimal results.
|
| 82 |
- **Monitor waste** closely to reduce it further and ensure the production process remains efficient.
|
| 83 |
- Review your **production goals** to ensure you are using the most efficient configuration of resources.
|
| 84 |
""")
|