Skip to content

Commit 5c42f52

Browse files
authored
Add condition before execution of the endpoint validate (#218)
Control dimensions of the matrix only if a time series is provided by the user in edition mode
1 parent e2a4c53 commit 5c42f52

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

NEWS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ NEW FEATURES :
1414
- **New properties** (*efficiencywithdrawal*, *penalize-variation-injection*, *penalize-variation-withdrawal*, see list of properties according to study version of Antares with `storage_values_default()`)
1515
- **New optional time series** (cost-injection, cost-withdrawal, cost-level, cost-variation-injection, cost-variation-withdrawal)
1616
* `updateScenarioBuilder()` New type of series "hfl" ("hydro final level", similar to "hydrolevels") is available
17+
* `editBindingConstraint()` : control the dimemnsions of the matrix only if a time series is provided by the user for optimization
1718

1819

1920
### Breaking changes :

R/editBindingConstraint.R

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,7 @@ editBindingConstraint <- function(name,
292292

293293
# api part code
294294
.editBC_api <- function(..., opts){
295+
295296
body <- list(...)
296297
# checks for any study version (legacy)
297298
if (is.null(body$time_step))
@@ -333,9 +334,9 @@ editBindingConstraint <- function(name,
333334
}
334335

335336
# >=v870
336-
337+
with_time_series <- !is.null(body$values)
337338
# reforge list structure
338-
if(!is.null(body$values)){
339+
if (with_time_series) {
339340
list_values <- list(less_term_matrix = body$values$lt,
340341
equal_term_matrix = body$values$eq,
341342
greater_term_matrix = body$values$gt)
@@ -405,12 +406,15 @@ editBindingConstraint <- function(name,
405406
body = body,
406407
encode = "raw")
407408

408-
# /validate
409-
api_get(opts = opts,
410-
endpoint = file.path(opts$study_id,
411-
"constraint-groups",
412-
result$group,
413-
"validate"))
409+
# /validate only if user provides a time series for optimization reason
410+
if (with_time_series) {
411+
api_get(opts = opts,
412+
endpoint = file.path(opts$study_id,
413+
"constraint-groups",
414+
result$group,
415+
"validate")
416+
)
417+
}
414418

415419
# specific endpoint for coeffs/terms
416420
if(!is.null(body_terms))

0 commit comments

Comments
 (0)