From eea3b545faa5b947f4899d3aa0842e970c4ba0d7 Mon Sep 17 00:00:00 2001 From: kemihak Date: Tue, 6 Feb 2024 17:51:01 +0100 Subject: [PATCH 1/3] Set 366 rows for the daily binding constraint instead of 365 --- R/createDSR.R | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/R/createDSR.R b/R/createDSR.R index 53940034..ad4b0e2a 100644 --- a/R/createDSR.R +++ b/R/createDSR.R @@ -262,10 +262,10 @@ createDSR <- function(areasAndDSRParam = NULL, #coef binding coefficientsDSR <- .getCoefDsr(areaName, nameDsr) - + # A binding constraint at a daily timestep expects 366 rows createBindingConstraint( nameBindDSR, - values = matrix(data = c(rep(installedCapacityLink * as.double(numberHour), 365), rep(0, 365 * 2)), ncol = 3), + values = matrix(data = c(rep(installedCapacityLink * as.double(numberHour), 366), rep(0, 366 * 2)), ncol = 3), enabled = TRUE, timeStep = "daily", operator = c("less"), @@ -440,9 +440,10 @@ editDSR <- function(area = NULL, #coef binding coefficientsDSR <- .getCoefDsr(area, previousNameDsr) + # A binding constraint at a daily timestep expects 366 rows createBindingConstraint( previousNameDsr, - values = matrix(data = c(rep(newCapacityLink * as.double(previousNumberHour), 365), rep(0, 365 * 2)), ncol = 3), + values = matrix(data = c(rep(newCapacityLink * as.double(previousNumberHour), 366), rep(0, 366 * 2)), ncol = 3), enabled = TRUE, timeStep = "daily", operator = c("less"), From f33609418c20bcfe519b1d68cf059f38d1a88ed6 Mon Sep 17 00:00:00 2001 From: kemihak Date: Tue, 6 Feb 2024 17:51:32 +0100 Subject: [PATCH 2/3] Check number of rows of the RHS in the daily binding constraint --- tests/testthat/test-createDSR.R | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/testthat/test-createDSR.R b/tests/testthat/test-createDSR.R index 5b1d7aec..5eb4a1c8 100644 --- a/tests/testthat/test-createDSR.R +++ b/tests/testthat/test-createDSR.R @@ -35,7 +35,9 @@ sapply(studies, function(study) { expect_equal(bindingList$a_dsr_3h$operator, "less") expect_equal(as.double(bindingList$a_dsr_3h$coefs["a%a_dsr_3h"]), -1) expect_equal(as.double(bindingList$b_dsr_7h$coefs["b%b_dsr_7h"]), -1) - + expect_equal(nrow(bindingList$a_dsr_3h$values), 366) + expect_equal(nrow(bindingList$b_dsr_7h$values), 366) + expect_equal(unique(bindingList$a_dsr_3h$values$less)[1], dsrData[dsrData$area=="a",]$unit*dsrData[dsrData$area=="a",]$nominalCapacity*dsrData[dsrData$area=="a",]$hour) expect_equal(unique(bindingList$b_dsr_7h$values$less)[1], dsrData[dsrData$area=="b",]$unit*dsrData[dsrData$area=="b",]$nominalCapacity*dsrData[dsrData$area=="b",]$hour) @@ -136,4 +138,3 @@ sapply(studies, function(study) { unlink(x = file.path(pathstd, "test_case"), recursive = TRUE) }) - From 0594a66ef96ab1a725953b320b8be20ef1eba6b4 Mon Sep 17 00:00:00 2001 From: kemihak Date: Wed, 14 Feb 2024 11:44:59 +0100 Subject: [PATCH 3/3] Update NEWS.md with the bug fix description in createDSR() --- NEWS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/NEWS.md b/NEWS.md index fd0c285a..53c85c24 100644 --- a/NEWS.md +++ b/NEWS.md @@ -13,6 +13,7 @@ NEW FEATURES : BUGFIXES : * Fix `filter_synthesis` and `filter_year_by_year` parameters of `editLink()` in API mode +* Fix `createDSR()` in API mode : daily binding constraint takes 366 rows # antaresEditObject 0.6.1