Update main.py
Browse files
main.py
CHANGED
|
@@ -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(40)]
|
| 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)
|
|
@@ -154,7 +154,7 @@ def run_bayesian_optimization():
|
|
| 154 |
@use_named_args(skopt_space)
|
| 155 |
def objective(**params):
|
| 156 |
return -calculate_project_kpis(**params)['irr']
|
| 157 |
-
res = gp_minimize(objective, skopt_space, n_calls=
|
| 158 |
best_params = {space.name: val for space, val in zip(skopt_space, res.x)}
|
| 159 |
kpis = calculate_project_kpis(**best_params)
|
| 160 |
return {"Method": "Bayesian Opt", **kpis, "Params": best_params}
|
|
|
|
| 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(40)]
|
| 126 |
best_overall_individual = None
|
| 127 |
best_overall_fitness = -float('inf')
|
| 128 |
+
for _ in range(80):
|
| 129 |
fitnesses = [calculate_project_kpis(**ind)['irr'] for ind in population]
|
| 130 |
if max(fitnesses) > best_overall_fitness:
|
| 131 |
best_overall_fitness = max(fitnesses)
|
|
|
|
| 154 |
@use_named_args(skopt_space)
|
| 155 |
def objective(**params):
|
| 156 |
return -calculate_project_kpis(**params)['irr']
|
| 157 |
+
res = gp_minimize(objective, skopt_space, n_calls=90, random_state=42, n_initial_points=20)
|
| 158 |
best_params = {space.name: val for space, val in zip(skopt_space, res.x)}
|
| 159 |
kpis = calculate_project_kpis(**best_params)
|
| 160 |
return {"Method": "Bayesian Opt", **kpis, "Params": best_params}
|