[LONGITUDINAL]  
  input={K, KDE, KPQ, KQPP, LAMBDAP, GAMMA, DELTAQP, PT0, Q0}
  
  PK:
  depot(target=C)
  
  EQUATION:
  t0 = 0
  PT_0 = PT0
  Q_0 = Q0
  PSTAR = PT+Q+QP
  ddt_C = -KDE*C
  ddt_PT = LAMBDAP*PT*(1-PSTAR/K) + KQPP*QP - KPQ*PT - GAMMA*KDE*PT*C
  ddt_Q = KPQ*PT - GAMMA*KDE*Q*C
  ddt_QP = GAMMA*KDE*Q*C - KQPP*QP - DELTAQP*QP  
shinyUI(fluidPage(
  tabsetPanel(
    tabPanel("Plot",
        fluidRow(
          column(4,
            tabsetPanel(
               tabPanel("Treatment",
                        br(),
                        sliderInput("tfd", "time of first dose:", value=50, min=0, max = 100, step=5),
                        sliderInput("nd", "number of doses:", value=6, min=0, max = 20, step=1),
                        sliderInput("ii", "interdose interval:", value = 15, min = 1, max = 20, step=1),
                        sliderInput("amt", "amount:", value = 1, min = 0, max = 5, step=0.2),
                        br()
               ),
               tabPanel("Parameters",
                        sliderInput("GAMMA", "GAMMA:", value = 1, min = 0, max = 4, step=0.1), 
                        sliderInput("K", "K:", value = 100, min = 0, max = 200, step=5),
                        sliderInput("KDE", "KDE:", value = 0.3, min = 0, max = 1, step=0.05),
                        sliderInput("LAMBDAP", "LAMBDAP:", value = 0.12, min = 0, max = 0.5, step=0.025) ,
                        sliderInput("DELTAQP", "DELTAQP:", value = 0.01, min = 0, max = 0.05, step=0.0025),
                        sliderInput("KPQ", "KPQ:", value = 0.025, min = 0, max = 0.1, step=0.005),
                        sliderInput("KQPP", "KQPP:", value = 0.004, min = 0, max = 0.01, step=0.0005),
                        sliderInput("PT0", "PT0:", value = 5, min = 1, max = 10, step=1),
                        sliderInput("Q0", "Q0:", value = 40, min = 10, max = 100, step=5),
                        br()
               )
                )),
       column(8,
          plotOutput("plot",  height="500px"))
       )),
    tabPanel("Mlxtran", pre(includeText("ribba.txt"))),
    tabPanel("ui.R", pre(includeText("ui.R"))),
    tabPanel("server.R", pre(includeText("server.R")))
  )
))
my.dir=getwd()
source("../../initMlxR.R")
setwd(my.dir)

shinyServer(function(input, output) {
  
  r <- reactive({  
    param.value=c(input$K,input$KDE,input$KPQ,input$KQPP,input$LAMBDAP,input$GAMMA,input$DELTAQP,
                  input$PT0,input$Q0)
    t.value=seq(0,250)
    t1=input$tfd
    t2=input$ii*(input$nd-1)+t1
    if (t2>=t1){
      t.dose=seq(t1,t2,by=input$ii)
      adm <- list(time=t.dose, amount=input$amt)
    }else{
      adm <- list(time=t1, amount=0)
    }
    
    f  <- list(name=c('PSTAR'),time=t.value)
    p   <- list(name=c('K','KDE','KPQ','KQPP','LAMBDAP','GAMMA','DELTAQP','PT0','Q0'), 
                value=param.value)
    
    res <- simulx( model     = 'ribba.txt',
                   treatment = adm, 
                   parameter = p,
                   output    = f)
    return(res)
  })
  
  output$plot <- renderPlot({
    withProgress(message = 'Creating plot', detail='Wait...', value = 0.1, expr={
      r=r()
    pl=ggplot(data=r$PSTAR, aes(x=time, y=PSTAR)) + geom_line(size=0.75)
    print(pl)
    })
  })
  
})