# Resultado con numeros negativos y ACT no se actualiza de nuevo a 10,que podria estar pasando?

``````set.seed(45644529)
t_collected <- c()
t_notcollected <- c()
WRT <- 8
CT<- 0## tiempo acumulado de trabajo
WH <- 8
Trec <- 0
Tret_land <- 0
TrecACT <- 0
TTB<-array(
rnorm(20,5,.5),
dim = c(20, 20, 1),
dimnames = list(paste0("In", 1:20), paste0("Out", 1:20), paste0("Truck"))
)
#(5,max(20,rnorm(5,5,10)))
TC <- 10
ACT <-replicate(20,10)
t_landfill <-0
t_returning <-0
t_recollection <- 0

# repeat{if (CT[i]>= WH){
#   break
# }

for (i in 1:ncol(TTB)){ #primer set the condiciones
if(is.na(TTB[i])<= is.na(ACT[i])){
ACT[i]<-ACT[i]-TTB[i]
t_recollection[i]<-min(0.5,max(1.5,rnorm(1,1,0.5)))
Trec[i]=t_recollection[i]+CT[i]

if(is.na(Trec[i]) <= WH){
CT[i]<- sum(t_recollection,t_landfill,t_returning)
Trec[i]=t_recollection[i]+CT[i]
t_collected[i]<-TTB[i]
t_notcollected[i] <-ACT[i]
TrecACT[i] <- (ACT[i]*t_recollection[i])/t_collected[i]

}else if (is.na(TrecACT[i])<= is.na(WH)){
t_recollection[i]<-min(0.5,max(1.5,rnorm(1,1,0.5)))
t_collected[i]<-ACT[i]
TTB[i] <- TTB[i]-ACT[i]
t_notcollected[i] <-TTB[i]
ACT[i]<-0
CT[i]<- sum(t_recollection,t_landfill,t_returning)
Tret_land[i] <-t_returning[i]+t_landfill[i]+CT[i]

}else if(Tret_land[i]<=WH){
t_recollection[i]<-min(0.5,max(1.5,rnorm(1,1,0.5)))
t_landfill[i]<-min(0.5,max(1.5,rnorm(1,1,0.5)))
t_returning[i]<-min(0.5,max(1.5,rnorm(1,1,0.5)))
t_collected[i]<-ACT[i]
CT[i]<- sum(t_recollection,t_landfill,t_returning)
ACT[i]=TC

}else{
t_recollection[i]<-min(0.5,max(1.5,rnorm(1,1,0.5)))
t_landfill[i]<-min(0.5,max(1.5,rnorm(1,1,0.5)))
ACT[i]=ACT[i]-(ACT[i]*(WRT[i]/t_recollection[i]))
TTB[i]=TTB[i]-(ACT[i]*(WRT[i]/t_recollection[i]))
CT[i]=8
}

}

t_recollection[i]=t_recollection[i]
t_landfill[i]=t_landfill[i]
t_returning[i]=t_returning[i]
CT[i] <- CT[i]
WRT[i] <- WH-CT[i]
Trec[i] <- Trec[i]
TrecACT[i] <- TrecACT[i]
Tret_land[i] <- Tret_land[i]
t_notcollected[i] <-t_notcollected[i]
TTB[i] <- TTB[i]
ACT[i] <- ACT[i]

ACT[i+1]<-ACT[i]
WRT[i+1] <- WRT[i]
t_recollection[i+1]=t_recollection[i]
t_landfill[i+1]=t_landfill[i]
t_returning[i+1]=t_returning[i]
CT[i+1]=CT[i]
Trec[i+1] <- t_recollection[i]+CT[i]
t_notcollected[i+1] <-t_notcollected[i]
TrecACT[i+1] <- (ACT[i]*t_recollection[i])/t_collected[i]
Tret_land[i+1] <-t_returning[i]+t_landfill[i]+CT[i]
TTB[i+1] <- TTB[i]

if(CT[i]==WH){
break
}

}

Result <-cbind(TTB=TTB[1:20],t_collected=t_collected[1:20],#AcumTcollec,
CT=CT[1:10],t_recollection=t_recollection[1:20],
t_landfill=t_landfill[1:20],
t_returning=t_returning[1:20],

ACT=ACT[1:20],Trec=Trec[1:20],WRT=WRT[1:20],
t_notcollected=t_notcollected[1:20],TrecACT=TrecACT[1:20],
Tret_land= Tret_land[1:20] )
``````

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.