|
| 1 | + |
| 2 | + |
| 3 | +# v920 ---- |
| 4 | +# st-storage ---- |
| 5 | + |
| 6 | +# build structure directory |
| 7 | +# input/st-storage/clusters/list.ini |
| 8 | +# input/st-storage/series/{area}/{cluster}/{ts.txt} |
| 9 | + |
| 10 | +# input/st-storage/constraints/{area}/{cluster}/additional-constraints.ini |
| 11 | +# input/st-storage/constraints/{area}/{cluster}/rhs_{constaints}.txt |
| 12 | + |
| 13 | +# mock study |
| 14 | +areas <- c("fr", "be") |
| 15 | +opts <- list( |
| 16 | + "studyPath" = tempdir(), |
| 17 | + "inputPath" = file.path(tempdir(), "input"), |
| 18 | + "typeLoad"= "txt", |
| 19 | + "areaList" = areas, |
| 20 | + "antaresVersion" = 920 |
| 21 | +) |
| 22 | + |
| 23 | +class(opts) <- c("simOptions") |
| 24 | + |
| 25 | +# properties |
| 26 | +fr <- c( |
| 27 | + "[withdrawal-1]", |
| 28 | + "variable = withdrawal", |
| 29 | + "operator = equal", |
| 30 | + "hours = [1,3,5], [120,121,122,123,124,125,126,127,128]", |
| 31 | + "", |
| 32 | + "[withdrawal-2]", |
| 33 | + "variable = withdrawal", |
| 34 | + "operator = equal", |
| 35 | + "hours = [1,3,5], [120,121,122,123,124]" |
| 36 | + ) |
| 37 | + |
| 38 | +be <- c( |
| 39 | + "[netting-1]", |
| 40 | + "variable = netting", |
| 41 | + "operator = less", |
| 42 | + "hours = [1, 168]", |
| 43 | + "", |
| 44 | + "[netting-2]", |
| 45 | + "variable = netting", |
| 46 | + "operator = less", |
| 47 | + "hours = [1, 167,168,169]" |
| 48 | + ) |
| 49 | + |
| 50 | +list_properties <- list(fr, be) |
| 51 | + |
| 52 | +# TS (8760, 1 column) |
| 53 | +TS_VALUE <- matrix(2, 8760) |
| 54 | + |
| 55 | +# create dir with properties |
| 56 | +cluster_names <- c("storage_1", "storage_2") |
| 57 | +comb <- merge(areas, cluster_names) |
| 58 | + |
| 59 | +dir_path <- file.path(tempdir(), |
| 60 | + "input", |
| 61 | + "st-storage", |
| 62 | + "constraints", |
| 63 | + areas, |
| 64 | + paste0(areas, "_", cluster_names)) |
| 65 | + |
| 66 | +# dir_path <- file.path(tempdir(), |
| 67 | +# "st-storage", |
| 68 | +# "constraints", |
| 69 | +# areas, |
| 70 | +# paste0(comb$x, "_", comb$y)) |
| 71 | + |
| 72 | +lapply(dir_path, dir.create, recursive = TRUE, showWarnings = FALSE) |
| 73 | + |
| 74 | + |
| 75 | +# write properties |
| 76 | +lapply(seq(1, length(list_properties)), function(x){ |
| 77 | + writeLines(list_properties[[x]], |
| 78 | + file.path(dir_path[x], "additional-constraints.ini")) |
| 79 | +}) |
| 80 | + |
| 81 | +# write TS |
| 82 | +names_constraints_1 <- c("withdrawal-1", "withdrawal-2") |
| 83 | +names_constraints_2 <- c("netting-1", "netting-2") |
| 84 | + |
| 85 | +lapply(names_constraints_1, function(x){ |
| 86 | + write.table(TS_VALUE, |
| 87 | + file = file.path(dir_path[1], |
| 88 | + paste0("rhs_", |
| 89 | + x, |
| 90 | + ".txt")), |
| 91 | + row.names = FALSE, |
| 92 | + col.names = FALSE) |
| 93 | +}) |
| 94 | + |
| 95 | +lapply(names_constraints_2, function(x){ |
| 96 | + write.table(TS_VALUE, |
| 97 | + file = file.path(dir_path[2], |
| 98 | + paste0("rhs_", |
| 99 | + x, |
| 100 | + ".txt")), |
| 101 | + row.names = FALSE, |
| 102 | + col.names = FALSE) |
| 103 | +}) |
| 104 | + |
| 105 | + |
| 106 | +test_that("Read without dir 'constraints'",{ |
| 107 | + |
| 108 | + # when |
| 109 | + read_storages_constraints(opts = opts) |
| 110 | +}) |
| 111 | + |
| 112 | + |
| 113 | + |
0 commit comments