Update app.py
Browse files
app.py
CHANGED
|
@@ -97,9 +97,9 @@ def optimize_energy_system(city_code, solar_cost, onshore_wind_cost, offshore_wi
|
|
| 97 |
# Battery storage constraints
|
| 98 |
for t in time_steps:
|
| 99 |
if t == 0:
|
| 100 |
-
model += battery_storage[t] == battery_capacity * 0.5 + battery_charge[t] * battery_efficiency - battery_discharge[t] / battery_efficiency, f"StorageBalance_{t}"
|
| 101 |
else:
|
| 102 |
-
model += battery_storage[t] == battery_storage[t - 1] + battery_charge[t] * battery_efficiency - battery_discharge[t] / battery_efficiency, f"StorageBalance_{t}"
|
| 103 |
model += battery_storage[t] <= battery_capacity, f"StorageCapacity_{t}"
|
| 104 |
model += battery_storage[t] >= 0, f"StorageNonNegative_{t}"
|
| 105 |
|
|
@@ -130,19 +130,19 @@ def optimize_energy_system(city_code, solar_cost, onshore_wind_cost, offshore_wi
|
|
| 130 |
alt_model = pulp.LpProblem(f"AlternativeModel_{tech}_{threshold}", pulp.LpMinimize)
|
| 131 |
|
| 132 |
# Variables (need to create new variables for the new model)
|
| 133 |
-
alt_renewable_capacity = pulp.LpVariable.dicts("
|
| 134 |
[(r, g) for r in regions for g in technologies],
|
| 135 |
lowBound=0, cat='Continuous')
|
| 136 |
-
alt_battery_capacity = pulp.LpVariable("
|
| 137 |
|
| 138 |
-
alt_renewable_generation = pulp.LpVariable.dicts("
|
| 139 |
[(t, g) for t in time_steps for g in technologies],
|
| 140 |
lowBound=0, cat='Continuous')
|
| 141 |
-
alt_battery_charge = pulp.LpVariable.dicts("
|
| 142 |
time_steps, lowBound=0, cat='Continuous')
|
| 143 |
-
alt_battery_discharge = pulp.LpVariable.dicts("
|
| 144 |
time_steps, lowBound=0, cat='Continuous')
|
| 145 |
-
alt_battery_storage = pulp.LpVariable.dicts("
|
| 146 |
time_steps, lowBound=0, cat='Continuous')
|
| 147 |
|
| 148 |
# Objective: minimize or maximize the capacity of the selected technology
|
|
@@ -170,9 +170,9 @@ def optimize_energy_system(city_code, solar_cost, onshore_wind_cost, offshore_wi
|
|
| 170 |
# Battery storage constraints
|
| 171 |
for t in time_steps:
|
| 172 |
if t == 0:
|
| 173 |
-
alt_model += alt_battery_storage[t] == alt_battery_capacity * 0.5 + alt_battery_charge[t] * battery_efficiency - alt_battery_discharge[t] / battery_efficiency, f"StorageBalance_{t}"
|
| 174 |
else:
|
| 175 |
-
alt_model += alt_battery_storage[t] == alt_battery_storage[t - 1] + alt_battery_charge[t] * battery_efficiency - alt_battery_discharge[t] / battery_efficiency, f"StorageBalance_{t}"
|
| 176 |
alt_model += alt_battery_storage[t] <= alt_battery_capacity, f"StorageCapacity_{t}"
|
| 177 |
alt_model += alt_battery_storage[t] >= 0, f"StorageNonNegative_{t}"
|
| 178 |
|
|
|
|
| 97 |
# Battery storage constraints
|
| 98 |
for t in time_steps:
|
| 99 |
if t == 0:
|
| 100 |
+
model += battery_storage[t] == battery_capacity * 0.5 + battery_charge[t] * battery_efficiency - battery_discharge[t] * (1 / battery_efficiency), f"StorageBalance_{t}"
|
| 101 |
else:
|
| 102 |
+
model += battery_storage[t] == battery_storage[t - 1] + battery_charge[t] * battery_efficiency - battery_discharge[t] * (1 / battery_efficiency), f"StorageBalance_{t}"
|
| 103 |
model += battery_storage[t] <= battery_capacity, f"StorageCapacity_{t}"
|
| 104 |
model += battery_storage[t] >= 0, f"StorageNonNegative_{t}"
|
| 105 |
|
|
|
|
| 130 |
alt_model = pulp.LpProblem(f"AlternativeModel_{tech}_{threshold}", pulp.LpMinimize)
|
| 131 |
|
| 132 |
# Variables (need to create new variables for the new model)
|
| 133 |
+
alt_renewable_capacity = pulp.LpVariable.dicts("alt_renewable_capacity",
|
| 134 |
[(r, g) for r in regions for g in technologies],
|
| 135 |
lowBound=0, cat='Continuous')
|
| 136 |
+
alt_battery_capacity = pulp.LpVariable("alt_battery_capacity", lowBound=0, cat='Continuous')
|
| 137 |
|
| 138 |
+
alt_renewable_generation = pulp.LpVariable.dicts("alt_renewable_generation",
|
| 139 |
[(t, g) for t in time_steps for g in technologies],
|
| 140 |
lowBound=0, cat='Continuous')
|
| 141 |
+
alt_battery_charge = pulp.LpVariable.dicts("alt_battery_charge",
|
| 142 |
time_steps, lowBound=0, cat='Continuous')
|
| 143 |
+
alt_battery_discharge = pulp.LpVariable.dicts("alt_battery_discharge",
|
| 144 |
time_steps, lowBound=0, cat='Continuous')
|
| 145 |
+
alt_battery_storage = pulp.LpVariable.dicts("alt_battery_storage",
|
| 146 |
time_steps, lowBound=0, cat='Continuous')
|
| 147 |
|
| 148 |
# Objective: minimize or maximize the capacity of the selected technology
|
|
|
|
| 170 |
# Battery storage constraints
|
| 171 |
for t in time_steps:
|
| 172 |
if t == 0:
|
| 173 |
+
alt_model += alt_battery_storage[t] == alt_battery_capacity * 0.5 + alt_battery_charge[t] * battery_efficiency - alt_battery_discharge[t] * (1 / battery_efficiency), f"StorageBalance_{t}"
|
| 174 |
else:
|
| 175 |
+
alt_model += alt_battery_storage[t] == alt_battery_storage[t - 1] + alt_battery_charge[t] * battery_efficiency - alt_battery_discharge[t] * (1 / battery_efficiency), f"StorageBalance_{t}"
|
| 176 |
alt_model += alt_battery_storage[t] <= alt_battery_capacity, f"StorageCapacity_{t}"
|
| 177 |
alt_model += alt_battery_storage[t] >= 0, f"StorageNonNegative_{t}"
|
| 178 |
|