Update main.py
Browse files
main.py
CHANGED
|
@@ -21,21 +21,21 @@ DEPRECIATION_YEARS = 15
|
|
| 21 |
|
| 22 |
TECHNOLOGY_DATA = {
|
| 23 |
"JNC": {"capex_base_M": 180.0, "opex_base_cents_kg": 150.0},
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
}
|
| 40 |
|
| 41 |
STRATEGY_DATA = {
|
|
@@ -50,7 +50,7 @@ PRODUCT_PRICES_USD_PER_TON = {
|
|
| 50 |
|
| 51 |
OPTIMIZATION_SPACE = {
|
| 52 |
'capacity_kta': (500, 600),
|
| 53 |
-
'technology': ["Engro_Pakistan"],
|
| 54 |
'sourcing_strategy': ['Integrated_Production'],
|
| 55 |
'export_market_mix': (0.6, 0.8),
|
| 56 |
'sell_byproducts': [True]
|
|
@@ -125,7 +125,7 @@ def run_genetic_algorithm():
|
|
| 125 |
population = [{k: random.choice(v) if isinstance(v, list) else random.uniform(*v) for k,v in OPTIMIZATION_SPACE.items()} for _ in range(50)]
|
| 126 |
best_overall_individual = None
|
| 127 |
best_overall_fitness = -float('inf')
|
| 128 |
-
for _ in range(
|
| 129 |
fitnesses = [calculate_project_kpis(**ind)['irr'] for ind in population]
|
| 130 |
if max(fitnesses) > best_overall_fitness:
|
| 131 |
best_overall_fitness = max(fitnesses)
|
|
@@ -171,7 +171,7 @@ def run_optuna_direct():
|
|
| 171 |
}
|
| 172 |
return calculate_project_kpis(**params)['irr']
|
| 173 |
study = optuna.create_study(direction="maximize")
|
| 174 |
-
study.optimize(objective, n_trials=
|
| 175 |
kpis = calculate_project_kpis(**study.best_params)
|
| 176 |
return {"Method": "Optuna (TPE - Direct)", **kpis, "Params": study.best_params}
|
| 177 |
|
|
|
|
| 21 |
|
| 22 |
TECHNOLOGY_DATA = {
|
| 23 |
"JNC": {"capex_base_M": 180.0, "opex_base_cents_kg": 150.0},
|
| 24 |
+
"Hoechst_AG": {"capex_base_M": 230.0, "opex_base_cents_kg": 155.0},
|
| 25 |
+
"BF_Goodrich": {"capex_base_M": 280.0, "opex_base_cents_kg": 160.0},
|
| 26 |
+
"Shin_Etsu_1991": {"capex_base_M": 260.0, "opex_base_cents_kg": 155.0},
|
| 27 |
+
"Shin_Etsu_2004": {"capex_base_M": 1500.0, "opex_base_cents_kg": 150.0},
|
| 28 |
+
"Vinnolit": {"capex_base_M": 240.0, "opex_base_cents_kg": 155.0},
|
| 29 |
+
"QVC_Qatar": {"capex_base_M": 200.0, "opex_base_cents_kg": 145.0},
|
| 30 |
+
"SP_Chemicals": {"capex_base_M": 250.0, "opex_base_cents_kg": 145.0},
|
| 31 |
+
"Engro_Pakistan": {"capex_base_M": 1400.0, "opex_base_cents_kg": 155.0},
|
| 32 |
+
"Formosa_BR_USA": {"capex_base_M": 380.0, "opex_base_cents_kg": 150.0},
|
| 33 |
+
"Shintech_USA_Exp": {"capex_base_M": 1700.0, "opex_base_cents_kg": 160.0},
|
| 34 |
+
"Zhongtai_China": {"capex_base_M": 1100.0, "opex_base_cents_kg": 155.0},
|
| 35 |
+
"Shintech_USA_2021": {"capex_base_M": 1700.0, "opex_base_cents_kg": 160.0},
|
| 36 |
+
"Reliance_India_2024": {"capex_base_M": 2200.0, "opex_base_cents_kg": 155.0},
|
| 37 |
+
"Orbia_Germany_2023": {"capex_base_M": 180.0, "opex_base_cents_kg": 155.0},
|
| 38 |
+
"Westlake_USA_2022": {"capex_base_M": 850.0, "opex_base_cents_kg": 160.0}
|
| 39 |
}
|
| 40 |
|
| 41 |
STRATEGY_DATA = {
|
|
|
|
| 50 |
|
| 51 |
OPTIMIZATION_SPACE = {
|
| 52 |
'capacity_kta': (500, 600),
|
| 53 |
+
'technology': ["Engro_Pakistan"], "Shin_Etsu_2004"],
|
| 54 |
'sourcing_strategy': ['Integrated_Production'],
|
| 55 |
'export_market_mix': (0.6, 0.8),
|
| 56 |
'sell_byproducts': [True]
|
|
|
|
| 125 |
population = [{k: random.choice(v) if isinstance(v, list) else random.uniform(*v) for k,v in OPTIMIZATION_SPACE.items()} for _ in range(50)]
|
| 126 |
best_overall_individual = None
|
| 127 |
best_overall_fitness = -float('inf')
|
| 128 |
+
for _ in range(100):
|
| 129 |
fitnesses = [calculate_project_kpis(**ind)['irr'] for ind in population]
|
| 130 |
if max(fitnesses) > best_overall_fitness:
|
| 131 |
best_overall_fitness = max(fitnesses)
|
|
|
|
| 171 |
}
|
| 172 |
return calculate_project_kpis(**params)['irr']
|
| 173 |
study = optuna.create_study(direction="maximize")
|
| 174 |
+
study.optimize(objective, n_trials=200, n_jobs=-1)
|
| 175 |
kpis = calculate_project_kpis(**study.best_params)
|
| 176 |
return {"Method": "Optuna (TPE - Direct)", **kpis, "Params": study.best_params}
|
| 177 |
|