Update app.py
Browse files
app.py
CHANGED
|
@@ -43,6 +43,7 @@ def index():
|
|
| 43 |
"cap_min": project_main.OPTIMIZATION_SPACE['capacity_kta'][0],
|
| 44 |
"cap_max": project_main.OPTIMIZATION_SPACE['capacity_kta'][1],
|
| 45 |
"export_mix": project_main.OPTIMIZATION_SPACE['export_market_mix'][0],
|
|
|
|
| 46 |
}
|
| 47 |
return render_template("index.html", import_error=None, project=project_main, techs=techs, defaults=defaults)
|
| 48 |
|
|
@@ -57,7 +58,7 @@ def run():
|
|
| 57 |
project_years = int(request.form.get("years", project_main.PROJECT_YEARS))
|
| 58 |
capacity_min = float(request.form.get("cap_min", project_main.OPTIMIZATION_SPACE['capacity_kta'][0]))
|
| 59 |
capacity_max = float(request.form.get("cap_max", project_main.OPTIMIZATION_SPACE['capacity_kta'][1]))
|
| 60 |
-
technology = request.form.get("technology",
|
| 61 |
export_mix = float(request.form.get("export_mix", project_main.OPTIMIZATION_SPACE['export_market_mix'][0]))
|
| 62 |
sell_byproducts = request.form.get("sell_byproducts") == "on"
|
| 63 |
tech_json = request.form.get("tech_json", "")
|
|
@@ -72,9 +73,9 @@ def run():
|
|
| 72 |
project_main.PROJECT_YEARS = project_years
|
| 73 |
|
| 74 |
project_main.OPTIMIZATION_SPACE['capacity_kta'] = (capacity_min, capacity_max)
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
project_main.OPTIMIZATION_SPACE['export_market_mix'] = (0.6, 0.8)
|
| 79 |
project_main.OPTIMIZATION_SPACE['sell_byproducts'] = [bool(sell_byproducts)]
|
| 80 |
|
|
@@ -90,7 +91,7 @@ def run():
|
|
| 90 |
df_results = pd.DataFrame(results).sort_values(by="irr", ascending=False).reset_index(drop=True)
|
| 91 |
df_results = df_results.round(2)
|
| 92 |
|
| 93 |
-
RESULTS_CSV =
|
| 94 |
df_results.to_csv(RESULTS_CSV, index=False, encoding='utf-8-sig')
|
| 95 |
|
| 96 |
try:
|
|
@@ -148,12 +149,4 @@ def download_results():
|
|
| 148 |
|
| 149 |
if __name__ == "__main__":
|
| 150 |
|
| 151 |
-
project_main.OPTIMIZATION_SPACE.update({
|
| 152 |
-
'capacity_kta': (500, 600),
|
| 153 |
-
'technology': list(project_main.TECHNOLOGY_DATA.keys())[:2],
|
| 154 |
-
'sourcing_strategy': ['Integrated_Production'],
|
| 155 |
-
'export_market_mix': (0.6, 0.8),
|
| 156 |
-
'sell_byproducts': [True]
|
| 157 |
-
})
|
| 158 |
-
|
| 159 |
app.run(host="0.0.0.0", port=int(os.environ.get("PORT", 7860)))
|
|
|
|
| 43 |
"cap_min": project_main.OPTIMIZATION_SPACE['capacity_kta'][0],
|
| 44 |
"cap_max": project_main.OPTIMIZATION_SPACE['capacity_kta'][1],
|
| 45 |
"export_mix": project_main.OPTIMIZATION_SPACE['export_market_mix'][0],
|
| 46 |
+
"technology": "Engro_Pakistan", # FIX: default برای match IRR main.py
|
| 47 |
}
|
| 48 |
return render_template("index.html", import_error=None, project=project_main, techs=techs, defaults=defaults)
|
| 49 |
|
|
|
|
| 58 |
project_years = int(request.form.get("years", project_main.PROJECT_YEARS))
|
| 59 |
capacity_min = float(request.form.get("cap_min", project_main.OPTIMIZATION_SPACE['capacity_kta'][0]))
|
| 60 |
capacity_max = float(request.form.get("cap_max", project_main.OPTIMIZATION_SPACE['capacity_kta'][1]))
|
| 61 |
+
technology = request.form.get("technology", "Engro_Pakistan") # FIX: default Engro
|
| 62 |
export_mix = float(request.form.get("export_mix", project_main.OPTIMIZATION_SPACE['export_market_mix'][0]))
|
| 63 |
sell_byproducts = request.form.get("sell_byproducts") == "on"
|
| 64 |
tech_json = request.form.get("tech_json", "")
|
|
|
|
| 73 |
project_main.PROJECT_YEARS = project_years
|
| 74 |
|
| 75 |
project_main.OPTIMIZATION_SPACE['capacity_kta'] = (capacity_min, capacity_max)
|
| 76 |
+
# FIX: همخوانی با main.py (technology پرهزینه، sourcing صریح)
|
| 77 |
+
project_main.OPTIMIZATION_SPACE['technology'] = ["Engro_Pakistan", "Shin_Etsu_2004"] if technology not in ["Engro_Pakistan", "Shin_Etsu_2004"] else [technology]
|
| 78 |
+
project_main.OPTIMIZATION_SPACE['sourcing_strategy'] = ['Integrated_Production'] # FIX: صریح
|
| 79 |
project_main.OPTIMIZATION_SPACE['export_market_mix'] = (0.6, 0.8)
|
| 80 |
project_main.OPTIMIZATION_SPACE['sell_byproducts'] = [bool(sell_byproducts)]
|
| 81 |
|
|
|
|
| 91 |
df_results = pd.DataFrame(results).sort_values(by="irr", ascending=False).reset_index(drop=True)
|
| 92 |
df_results = df_results.round(2)
|
| 93 |
|
| 94 |
+
RESULTS_CSV = Path.cwd() / "results_flask.csv" # FIX: ذخیره در دایرکتوری فعلی
|
| 95 |
df_results.to_csv(RESULTS_CSV, index=False, encoding='utf-8-sig')
|
| 96 |
|
| 97 |
try:
|
|
|
|
| 149 |
|
| 150 |
if __name__ == "__main__":
|
| 151 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 152 |
app.run(host="0.0.0.0", port=int(os.environ.get("PORT", 7860)))
|