This file has been generated by the package antaresXpansion. It gives an overview of the results of the investment optimisation problem solved by the package.

## load packages
library(plotly)
library(magrittr)
library(dplyr)
library(tidyr)
library(data.table)
library(knitr)
library(shiny)

General information

Study :

cat(x$study_options$studyPath)

Date :

lubridate::now()

Expansion planning options :

str(x$expansion_options)

Package version :

packageVersion("antaresXpansion")

Best found solution

best_solutions <- x$costs[which(x$costs$overall_costs == min(x$costs$overall_costs, na.rm = TRUE)),"it"]
sol_id <- paste0("it", best_solutions)

n_best_solution <- length(best_solutions)
n_iteration <- max(x$costs$it)

Total cost :

cat(subset(x$costs, it == best_solutions[1])$overall_costs, "euros\n")
cat(subset(x$costs, it == best_solutions[1])$overall_costs/10^6, "million euros\n")

if(n_best_solution > 1)
{
  cat("There is", n_best_solution, "equivalent solutions leading to this cost")
}

Investment cost :

if(n_best_solution == 1)
{
  cat(subset(x$costs, it == best_solutions[1])$investment_costs, "euros\n")
  cat(subset(x$costs, it == best_solutions[1])$investment_costs/10^6, "million euros\n")
}
if(n_best_solution > 1)
{
  for(i in 1:n_best_solution)
  {
    cat("solution", i, ":\n")
    cat("   -",subset(x$costs, it == best_solutions[i])$investment_costs, "euros\n")
    cat("   -",subset(x$costs, it == best_solutions[i])$investment_costs/10^6, "million euros\n") 
  }
}

Production cost :

if(n_best_solution == 1)
{
  cat(subset(x$costs, it == best_solutions[1])$operation_costs, "euros\n")
  cat(subset(x$costs, it == best_solutions[1])$operation_costs/10^6, "million euros\n")
}
if(n_best_solution > 1)
{
  for(i in 1:n_best_solution)
  {
    cat("solution", i, ":\n")
    cat("   -",subset(x$costs, it == best_solutions[i])$operation_costs, "euros\n")
    cat("   -",subset(x$costs, it == best_solutions[i])$operation_costs/10^6, "million euros\n") 
  }
}

Invested capacities (in MW):

kable(subset(x$invested_capacities, it %in% best_solutions), format = "markdown")

Convergence

Number of iterations :

cat(n_iteration)

Number of simulated weeks :

n_weeks <- sum(sapply(1:n_iteration, FUN = function(i){length(x$iterations[[i]]$weeks) * length(x$iterations[[i]]$mc_years)}))

cat(n_weeks)

Iteration with the (first) best solution :

cat(min(best_solutions))

Optimality gap - Distance between greatest lower bound and best solution - equal to zero when optimal solution has been reached: (When UC mode is fast or accurate, this gap can be negative due to the approximations of ANTARES' heuristics. When relaxed UC mode are used, this gap can be slightly negative due to numeric approximations in cuts)

cat(subset(x$costs, it == best_solutions[1])$overall_costs - max(x$under_estimator), "euros")

Convergence of costs

# prepare data.frame structure for plotly
costs <- x$costs
costs$best_bound  <-  x$under_estimator

min_1_n <- function(n, vect)
{
  if(!all(is.na(vect[1:n])))
  {
    return(min(vect[1:n], na.rm = TRUE))
  }
  else{return(NA)}
}

costs$best_solution_until_now <- sapply(1:n_iteration, min_1_n, vect = x$costs$overall_costs)

# plot (ov_cost, best_bound, best_sol) = f(it)

p <- plot_ly(costs, x = ~it, width = "100%") %>%
  add_trace(y = ~best_solution_until_now, name = 'Best solution until this iteration', mode = 'lines+markers', type = "scatter") %>%
  add_trace(y = ~best_bound, name = 'Lower bound', mode = 'lines+markers', type = "scatter") %>%
  add_trace(x = ~it[!is.na(overall_costs)], y = ~na.omit(overall_costs), name = 'Total cost',mode = 'lines+markers', type = "scatter") %>%
  layout(yaxis = list(title = "(euros)"), legend = list(orientation = 'h'))

p

Details for each iteration

Table - invested capacity at each iteration (in MW) :

# transpose 

kable(spread(x$invested_capacities[, -2], key = "candidate", value = "value"), format = "markdown")

Table - costs a each iteration (in euros) :

kable(costs, format = "markdown")

Table - Loss of Load Expectation(in hours) :

lold_matrix <- sapply(x$digest, FUN = function(it){return(it$LOLD)})
rownames(lold_matrix) <- x$digest$it1$area
kable(t(lold_matrix), format = "markdown")


rte-antares-rpackage/antaresXpansion documentation built on June 16, 2019, 2:35 p.m.