################################################################################
#  Copyright 2020, Tom Van Acker                                               #
################################################################################
# MultiStateSystems.jl                                                         #
# A Julia package to solve multi-state system models.                          #
# See http://github.com/timmyfaraday/MultiStateSystems.jl                      #
################################################################################

"""
Example considering a tree-like wind farm with four wind turbines.

The output generated by the wind turbines depend on a single stochastic source:
the wind speed. To enforce this, the argument `dep` must be passed as true.

  WT₁         WT₂           n₃
   |----///----|----///----|
   n₁    c₁     n₂    c₂     |
                           |--⋅ PCC
  WT₄         WT₃           |
   |----///----|----///----|
   n₅    c₄     n₄    c₃
Fig. 1: Tree-like wind farm with four wind turbines.
"""

# load pkgs
using Unitful
using MultiStateSystems

# include the state-transition diagrams for the wind turbines and cables
stdʷᵗᵒ = solvedSTD(prob = [0.3,0.7], power = [0.0u"MW",2.0u"MW"])
stdᶜᵇˡ = solvedSTD(prob = [0.1,0.9], power = [0.0u"MW",4.0u"MW"])

# initialize the network corresponding to the wind farm
ntwʷᶠ = Network()

# add the user, sources and components to the network
add_user!(ntwʷᶠ, node = 3)
add_sources!(ntwʷᶠ, node = [1,2,4,5], std = stdʷᵗᵒ, dep = true)
add_components!(ntwʷᶠ, edge = [(1,2),(2,3),(4,3),(5,4)],
                       std  = stdᶜᵇˡ)

# return the network
return ntwʷᶠ