MyNixOS website logo
Description

Simulate Rehabilitation Strategies for Water Distribution Systems.

The outcome of various rehabilitation strategies for water distribution systems can be modeled with the Water Management Simulator (WaMaSim). Pipe breaks and the corresponding damage and rehabilitation costs are simulated. It is mainly intended to be used as educational tool for the Water Infrastructure Experimental and Computer Laboratory at ETH Zurich, Switzerland.

WaMaSim - Water Management Simulator

WaMaSim is an R package that simulates the effect of different rehabilitation strategies for water distribution systems. It is an education tool used for the Water Infrastructure Experimental and Computer Laboratory at ETH Zurich, Switzerland.

Installation

  1. Install R and R-Studio or any other editor.

  2. Install devtools (type in the R command line)

install.packages("devtools")
  1. Install WaMaSim (type in the R command line)
library(devtools)
install_github("scheidan/WaMaSim")

Usage

This is a minimal example of how you can run the simulation:

library(WaMaSim)

## -----------
## define model parameters

## Define the annual probability of a failure
prob.failure.exp <- function(age, age.last.failure, n.failure) {
  if(n.failure==0){
    return(1/30)
  } else {
    return(1/10)
  }
}

## define a complicated (and probably useless) rehabilitation strategy
mystrategy <- . %>%
  replace.n.highest.risk(n=2, prob.failure=prob.failure.exp) %>%
  replace.more.failures.than(failures=5) %>%
  replace.older.than(age=70, max.cost=2e6)  %>%
  replace.n.oldest(n=3) %>%
  replace.n.random(n=2)
## This means: every year (if we have enough budget!), replace first the 2 pipes
## with the highest risk, then all pipes with more than 5 failures,
## then all pipes older then 70 years (up to costs of 2e6), then the 3
## oldest pipes remaining, and finally replace 2 randomly selected pipes.


## -----------
## run the simulation

result <- simulate_network(n.years = 100,                   # run it for 100 years
                           expansion = 10,                  # build 10 pipes per year (if money is available)
                           rehabilitation = mystrategy,     # use the strategy defined above
                           prob.failure = prob.failure.exp, # use the probability function defined above
                           income = 1e6,                    # the annual income
                           initial.budget = 1e7,
                           initial.inventory = 50,          # start the simulation with 50 new pipes
                           free.expansion = FALSE)          #

## look at some results
str(result)
str(result$time.100)


## -----------
## plots

par(mfrow=c(3,1))

## budget
plot(result$time, result$budget, type="l")
abline(h=0, col=2)

## pipes built per year
plot(result$time, pipes.built.per.year(result))

## annual costs
plot(result$time, costs.per.year(result, income=1e6))

See the package help for more information.

Package development

The packages devtools, testthat, and roxygen2 are required. To build and test this package use the following workflow:

library(devtools)

package.path = "WaMaSim/"     # path must point to the folder containing the WaMaSim files

## simulate a new package installation
load_all(package.path)

## run tests
test(package.path)            # this runs the tests in the `test` folder of the package
test_coverage(package.path)       # needs package 'covr' to be installed

## build documentation (uses Roxygen2)
document(package.path)

## run R CMD checks
check(package.path, cran=TRUE, manual=TRUE)

## build package for CRAN submission
build(pkg=package.path)

Metadata

Version

1.0.0

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows