Skip to content

Commit cab3d29

Browse files
authored
fix: value stored energy against s_initial, not the first step's SOC (#129)
1 parent a50b33d commit cab3d29

17 files changed

Lines changed: 65 additions & 17 deletions

src/optimizer/optimizer.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -989,10 +989,12 @@ def get_clean_objective_value(self):
989989
for t in self.time_steps:
990990
clean_objective += pulp.value(self.variables['e'][t]) * self.time_series.p_E[t]
991991

992-
# Final state of charge value [currency unit]
992+
# Value of the energy the horizon added to the batteries [currency unit]. The reference is
993+
# bat.s_initial and not s[0]: s[0] is the state after the first time step and already
994+
# carries that step's charging, so subtracting it dropped the first step from the result.
993995
for i, bat in enumerate(self.batteries):
994996
clean_objective += (pulp.value(self.variables['s'][i][self.T-1])
995-
- pulp.value(self.variables['s'][i][0])) * bat.p_a
997+
- bat.s_initial) * bat.p_a
996998

997999
# charge for import power demand rate. The demand rate is applied to the maximum
9981000
# power draw beyond the threshold within the time horizon.

test_cases/009-discharge-before-import.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@
448448
506.67163
449449
],
450450
"limit_violations": {},
451-
"objective_value": 2.6513393,
451+
"objective_value": 2.66254976413256,
452452
"status": "Optimal"
453453
},
454454
"request": {

test_cases/010-infesible-charge-goal.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@
412412
0
413413
],
414414
"limit_violations": {},
415-
"objective_value": 0.21802653,
415+
"objective_value": 0.552987729936,
416416
"status": "Optimal"
417417
},
418418
"request": {

test_cases/011-infeasible-charge-demand.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@
327327
},
328328
"expected_response": {
329329
"status": "Optimal",
330-
"objective_value": 1.037952770013092,
330+
"objective_value": 1.7419335994530019,
331331
"limit_violations": {
332332
"grid_import_limit_exceeded": false,
333333
"grid_export_limit_hit": false

test_cases/012-early-charging-not-perfect.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@
412412
506.25586
413413
],
414414
"limit_violations": {},
415-
"objective_value": 1.5244173,
415+
"objective_value": 1.56517752866355,
416416
"status": "Optimal"
417417
},
418418
"request": {

test_cases/013-grid-export-limit-hit.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@
199199
},
200200
"expected_response": {
201201
"status": "Optimal",
202-
"objective_value": 17.5372629588039,
202+
"objective_value": 17.527010877312602,
203203
"limit_violations": {
204204
"grid_import_limit_exceeded": false,
205205
"grid_export_limit_hit": true

test_cases/014-grid-import-limit-violation.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@
319319
"limit_violations": {
320320
"grid_import_limit_exceeded": true
321321
},
322-
"objective_value": -7.0956674,
322+
"objective_value": -7.094530917713852,
323323
"status": "Optimal"
324324
},
325325
"request": {

test_cases/015-low-soc-initial.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@
363363
},
364364
"expected_response": {
365365
"status": "Optimal",
366-
"objective_value": -6.4224528091250015,
366+
"objective_value": -6.294173947715001,
367367
"limit_violations": {
368368
"grid_import_limit_exceeded": false,
369369
"grid_export_limit_hit": false

test_cases/016-battery-charge-priotization-1.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@
448448
506.67163
449449
],
450450
"limit_violations": {},
451-
"objective_value": 2.6513393,
451+
"objective_value": 2.66254976413256,
452452
"status": "Optimal"
453453
},
454454
"request": {

test_cases/017-battery-charge-priotization-2.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@
381381
0
382382
],
383383
"limit_violations": {},
384-
"objective_value": 5.6556706,
384+
"objective_value": 5.591261368,
385385
"status": "Optimal"
386386
},
387387
"request": {

0 commit comments

Comments
 (0)