An error occurred while loading the file. Please try again.
-
Guillaume Perréal authored755db0a5
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/createController.R
\name{CreateController}
\alias{CreateController}
\title{Create and add a controller in a supervisor}
\usage{
CreateController(supervisor, ctrl.id, Y, U, FUN)
}
\arguments{
\item{supervisor}{\code{Supervisor} object, see \link{CreateSupervisor}}
\item{ctrl.id}{\link{character} id of the controller (see Details)}
\item{Y}{\link{character} location of the controlled and/or measured variables in the model. See \link{createControl}}
\item{U}{\link{character} location of the command variables in the model. See \link{createControl}}
\item{FUN}{\link{function} controller logic which calculates \code{U} from \code{Y} (see Details)}
}
\value{
\code{Controller}
}
\description{
Create and add a controller in a supervisor
}
\details{
\code{ctrl.id} parameter is a unique id for finding the controller in the supervisor.
If a controller with the same id already exists, it is overwritten by this new one.
\code{FUN} parameter should be a function with one \link{numeric} parameter.
This parameter will receive the measured values of at \code{Y} locations as input
for the previous time step and returns calculated \code{U}. These \code{U} will then be applied
at their location for the current time step of calculation of the model.
}
\examples{
# First create a Supervisor from a model
example("CreateSupervisor")
# A controller which usually releases 0.1 m3/s and provides
# extra release if the downstream flow is below 0.5 m3/s
logicDamRelease <- function(Y) max(0.5 - Y[1], 0.1)
CreateController(sv, "DamRelease", Y = c("54001"), U = c("54095"), FUN = logicDamRelease)
}