The basic idea is that when two agents meet, they learn together. Later, this should happen in a network. In the beginning, I will let the agents meet randomly in the population to see if the implementation of joint learning works.
If it works as it should, it will be expanded so that a certain percentage of the population meets at the same time.
Definitions
Loading some Packages for easier Data management and Presentation of Results
A Population (Pop) with several Agents defined by ID’s
A value to add to the Knowledge. could be a scalar or e vector with the same length as the Population. if not defined 0 is used to add
A value to multiplie (fac) the Knowledge. could be a scalar or e vector with the same length as the Population. if not defined 1 is used for the multiplikation
optional for future implementations a name (Typ) for the specific Knowledge
Hints
The add operation is always used first!
If the Knowledge is not defined before it will be generated with the start value (add) and the multiplication with the value (fac)
Code
update_Knowledge<-function(Pop=Pop,Typ=FALSE,add=0,fac=1){Kname<-"Knowledge"if(Typ!=FALSE){Kname<-paste(Kname, Typ, sep ="_")}if(Kname%in%colnames(Pop)){Pop<-Pop%>%mutate(!!Kname:=(.data[[Kname]]+add)*fac)}else{Pop<-set_Knowledge(Pop =Pop, K =add, Typ =Typ)Pop<-Pop%>%mutate(!!Kname:=.data[[Kname]]*fac)}return(Pop)}
Output
Population with the defined Knowledge
Code
add<-seq_len(nA)/20fac<-seq_len(nA)/10Pop<-update_Knowledge( Pop =Pop, add =add)Pop<-update_Knowledge( Pop =Pop, Typ ="A", fac =fac)Pop<-update_Knowledge( Pop =Pop, Typ ="B", add =add, fac =fac)Pop
A Population (Pop) with several Agents defined by ID’s and StudyTime
A Time (dT) that should added.
Hints
If StudyTime isn’t defined in Population it will be initialising with dT
Code
update_StudyTime<-function(Pop=Pop,dT=TimeToAdd){STname<-"StudyTime"if(STname%in%colnames(Pop)){Pop<-Pop%>%mutate(!!STname:=.data[[STname]]+dT)}else{Pop<-set_StudyTime(Pop =Pop, ST =dT)}return(Pop)}
A Population (Pop) with several Agents defined by ID’s
A colname from the Population which should followed ver Time
optional parameter Sum. Ich Sum = 1 a mean and median is calculated for each Time
Code
get_Timeline<-function(TL=Timeline,Time=0,Pop=Pop,Info=name,Sum=0){TLadd<-tibble( ID =Pop[["ID"]], Time =Time,!!Info:=Pop[[Info]])if(Sum==1){Sumname1<-paste(Info,"mean", sep ="_")Sumname2<-paste(Info,"median", sep ="_")TLadd<-TLadd%>%mutate(!!Sumname1:=mean(Pop[[Info]], na.rm =TRUE),!!Sumname2:=median(Pop[[Info]], na.rm =TRUE))}if(Time==0){TL<-TLadd}else{TL<-bind_rows(TL, TLadd)}return(TL)}
Output
A Timeline in a long format
Code
Timeline<-get_Timeline( TL =Timeline, Time =0, Pop =Pop, Info ="Knowledge", Sum =1)Timeline<-get_Timeline( TL =Timeline, Time =1, Pop =Pop, Info ="Knowledge", Sum =1)Timeline
A Population (Pop) with several Agents defined by ID’s and Knowledge
optional for future implementations a name (Typ) for the specific Knowledge
A value for the learn rate (LR). could be a scalar or e vector with the same length as the Population
A value for the study time (ST). could be a scalar or e vector with the same length as the Population
Hints
If learn rate isn’t given the values from the Population will be used, if this is missing in the Population 0 is used.
Code
learn<-function(Pop=Pop,Typ=FALSE,LR=FALSE,ST=StudyTime){Kname<-"Knowledge"if(Typ!=FALSE){Kname<-paste(Kname, Typ, sep ="_")}if(Kname%in%colnames(Pop)){K<-Pop[[Kname]]}if(LR==FALSE){if("LearnRate"%in%colnames(Pop)){LR<-Pop[["LearnRate"]]}}T0<-(1-K)^(1/-LR)# assumed time learnd allreadyK<-1-(T0+ST)^(-LR)# Knowledge after time learndPop<-set_Knowledge(Pop =Pop, Typ =Typ, K =K)Pop<-update_StudyTime(Pop =Pop, dT =ST)return(Pop)}
Output
Population with updated Knowledge
Code
Pop<-tibble( ID =ID)Pop<-set_Knowledge(Pop =Pop, K =0.1)Pop<-set_LearnRate(Pop =Pop, LR =1)Pop
Functions to select and sets learning slots from a Population
Select a random Slot of pairs
Needs
A Population (Pop) with several Agents defined by ID’s
A size of the Slot in percents of the population
Hints
because it leads to trouble will selecting otherwise the calculated n is limited at the moment between 1 and half of the Population
Code
sel_Slot_rnd<-function(Pop=Pop,psize=PrecentOfPop){sID<-"Slot_ID"n<-round(nrow(Pop)*psize/2, 0)n<-max(n, 1)n<-min(n, round(nrow(Pop)/2, 0))SubPop<-sel_SubPop( Pop =Pop, n =n)Slot1<-SubPop$sel%>%mutate(!!sID:=seq_len(n))SubPop<-sel_SubPop( Pop =SubPop$rest, n =n)Slot2<-SubPop$sel%>%mutate(!!sID:=seq_len(n))Slot<-bind_rows(Slot1, Slot2)return(Slot)}
Output
A random Slot-Population with Slot ID’s which marks the pairs
Learning with a exponential learn rate defined by pairs
Needs
A Slot-Population with several paired Agents defined by Slot-ID’s. Prepaerd by the function set_SlotPar()
optional for future implementations a name (Typ) for the specific Knowledge
Code
learn_Slot<-function(Slot=Slot,Typ=FALSE){Kname<-"Knowledge"if(Typ!=FALSE){Kname<-paste(Kname, Typ, sep ="_")}LRname<-"Slot_LearnRate"STname<-"Slot_Duration"K<-Slot[[Kname]]LR<-Slot[[LRname]]ST<-Slot[[STname]]T0<-(1-K)^(1/-LR)# assumed time learnd allreadyK<-1-(T0+ST)^(-LR)# Knowledge after time learndSlot<-set_Knowledge(Pop =Slot, Typ =Typ, K =K)Slot<-update_StudyTime(Pop =Slot, dT =ST)return(Slot)}
plt_Timeline<-function(TL=Timeline){ggplot(data =TL, aes(x =Time))+geom_line(aes(y =Knowledge, group =ID, color ="Agents"), alpha =0.5, linetype ="solid")+geom_line(aes(y =Knowledge_mean, color ="Mean"), linetype ="solid")+geom_line(aes(y =Knowledge_median, color ="Median"), linetype ="dashed")+ggtitle("Timeline")+xlab("Number of Slots")+ylab("Knowledge")+scale_y_continuous( limits =c(0, 1), breaks =seq(0, 1, 0.2))+scale_color_manual( values =c("Agents"="grey", "Mean"="black", "Median"="black"), labels =c("Agents"="Agents", "Mean"="Mean", "Median"="Median"))+theme_light()+theme(legend.title =element_blank(), legend.position ="top", legend.justification ="left")}
Output
ggplot2
Simulation
A learning process with updated learn rate by current knowledge when Agents meet randomly by Slots
Needs
A Population (Pop) with several Agents defined by ID’s and Knowledge
optional for future implementations a name (Typ) for the specific Knowledge
A size of the Slot in percents of the population
A duration of the slot. could be a scalar or a vector with the same length as the number of pairs in the Slot
A number of Slots (STn)
Code
sim_Slot<-function(Pop=Pop,Typ=FALSE,psize=PrecentOfPop,ST=1,STn=Itterations){Kname<-"Knowledge"if(Typ!=FALSE){Kname<-paste(Kname, Typ, sep ="_")}Pop<-update_LearnRate_Knowledge( Pop =Pop)Pop<-set_StudyTime( Pop =Pop)TL<-get_Timeline( TL =TL, Time =0, Pop =Pop, Info =Kname, Sum =1)for(iin1:STn){Slot<-sel_Slot_rnd( Pop =Pop, psize =psize)Slot<-set_SlotPar(Slot =Slot, ST =ST)Slot<-learn_Slot(Slot =Slot, Typ =Typ)Slot<-update_LearnRate_Knowledge( Pop =Slot)Pop<-int_SubPop( SubPop =Slot, Pop =Pop)TL<-get_Timeline( TL =TL, Time =i, Pop =Pop, Info =Kname, Sum =1)}Output<-list( Pop =Pop, TL =TL)return(Output)}
Output
A List with the new Population and a Timeline over the number of itterations
Code
nA<-50# number of AgentsID<-seq_len(nA)# ID of the AgentsK<-(seq_len(nA)-1)/50# KnowledgenM<-160# number of meetings(mean)psize<-0.6STn<-(nM*nA)/(psize*nA)Pop<-tibble( ID =ID)Pop<-set_Knowledge( Pop =Pop, K =K)Pop
---title: "Grouped in Slots"author: "Hubert Baechli"execute: cache: false---# Simulating random meetings (Grouped in Slots)The basic idea is that when two agents meet, they learn together. Later, this should happen in a network. In the beginning, I will let the agents meet randomly in the population to see if the implementation of joint learning works.If it works as it should, it will be expanded so that a certain percentage of the population meets at the same time.# DefinitionsLoading some Packages for easier Data management and Presentation of Results```{r}library(tidyverse) # set.seed(1)```## Population for testing the Functions```{r}nA =5# number of AgentsID =seq_len(nA) # ID of the AgentsPop <-tibble( ID = ID )Pop```# Functions## KnowledgeFunctions to set and update Knowledge### Set Knowledge#### Needs1. A Population (Pop) with several Agents defined by ID's2. A value for the Knowledge (K) between 0 and 1. could be a scalar or e vector with the same length as the Population3. optional for future implementations a name (Typ) for the specific Knowledge```{r}set_Knowledge <-function(Pop = Pop,Typ =FALSE,K = Knowledge) { Kname <-"Knowledge"if (Typ !=FALSE) { Kname <-paste(Kname, Typ, sep ="_") } Pop <- Pop %>%mutate(!!Kname := K)return(Pop)}```#### Output1. Population with the defined Knowledge```{r}K <-seq_len(nA)/5Pop <-set_Knowledge( Pop = Pop, K =0.5 )Pop <-set_Knowledge( Pop = Pop, Typ ="A", K = K )Pop```### Update Knowledge#### Needs1. A Population (Pop) with several Agents defined by ID's2. A value to add to the Knowledge. could be a scalar or e vector with the same length as the Population. if not defined 0 is used to add3. A value to multiplie (fac) the Knowledge. could be a scalar or e vector with the same length as the Population. if not defined 1 is used for the multiplikation4. optional for future implementations a name (Typ) for the specific Knowledge#### Hints- The add operation is always used first!- If the Knowledge is not defined before it will be generated with the start value (add) and the multiplication with the value (fac)```{r}update_Knowledge <-function(Pop = Pop,Typ =FALSE,add =0,fac =1) { Kname <-"Knowledge"if (Typ !=FALSE) { Kname <-paste(Kname, Typ, sep ="_") }if (Kname %in%colnames(Pop)) { Pop <- Pop %>%mutate( !!Kname := ( .data[[Kname]] + add ) * fac ) } else { Pop <-set_Knowledge(Pop = Pop, K = add, Typ = Typ) Pop <- Pop %>%mutate( !!Kname := .data[[Kname]] * fac ) }return(Pop)}```#### Output1. Population with the defined Knowledge```{r}add <-seq_len(nA)/20fac <-seq_len(nA)/10Pop <-update_Knowledge( Pop = Pop, add = add ) Pop <-update_Knowledge( Pop = Pop, Typ ="A", fac = fac ) Pop <-update_Knowledge( Pop = Pop, Typ ="B", add = add, fac = fac ) Pop```## LearnRateFunctions to set and update the learn rate### Set LearnRate#### Needs1. A Population (Pop) with several Agents defined by ID's2. A value for the learn rate (LR) greater than 0 and up to 1. could be a scalar or e vector with the same length as the Population#### Hints- LernRate 0 leads to Problems so it ist limited it to 1E-3```{r}set_LearnRate <-function(Pop = Pop,LR = LearnRate) { LRname <-"LearnRate" Pop <- Pop %>%mutate(!!LRname := LR,!!LRname :=pmax(.data[[LRname]],1E-3))return(Pop)}```#### Output1. Population with the defined learn rate```{r}LR <-seq_len(nA)/5Pop <-set_LearnRate( Pop = Pop, LR =1 ) Pop```### Update LearnRate by Knowledge#### Needs1. A Population (Pop) with several Agents defined by ID's and Knowledge2. optional for future implementations a name (Typ) for the specific Knowledge#### Hints- The learn rate is defined as 50% of the Knowledge for each Agent```{r}update_LearnRate_Knowledge <-function(Pop = Pop,Typ =FALSE) { LR <-"LearnRate" Kname <-"Knowledge"if (Typ !=FALSE) { Kname <-paste(Kname, Typ, sep ="_") }if (Kname %in%colnames(Pop)) { Pop <- Pop %>%mutate( !!LR := .data[[Kname]] *0.5 ) }return(Pop)}```#### Output1. Population with the defined learn rate```{r}Pop <-update_LearnRate_Knowledge( Pop = Pop ) Pop```## StudyTimeFunctions to set and update the StudyTime### Set StudyTime#### Needs1. A Population (Pop) with several Agents defined by ID's2. A value for the StudyTime (ST). could be a scalar or a vector with the same length as the Population#### Hints- If StudyTime isn't given the Population will be initialising with 0```{r}set_StudyTime <-function(Pop = Pop,ST =0) { STname <-"StudyTime" Pop <- Pop %>%mutate(!!STname := ST)return(Pop)}```#### Output1. Population with the defined StudyTime```{r}Pop <-set_StudyTime( Pop = Pop, ST =3) Pop```### Update StudyTime#### Needs1. A Population (Pop) with several Agents defined by ID's and StudyTime2. A Time (dT) that should added.#### Hints- If StudyTime isn't defined in Population it will be initialising with dT```{r}update_StudyTime <-function(Pop = Pop,dT = TimeToAdd) { STname <-"StudyTime"if (STname %in%colnames(Pop)) { Pop <- Pop %>%mutate( !!STname := .data[[STname]] + dT ) } else { Pop <-set_StudyTime(Pop = Pop, ST = dT ) }return(Pop)}```#### Output1. Population with the defined StudyTime```{r}Pop <-update_StudyTime( Pop = Pop, dT =1) Pop```## Data ManagementFunctions to select and reintegrate a Sub Populations### Select a Sub Population#### Needs1. A Population (Pop) with several Agents defined by ID's2. A vector wit ID's(IDs). If no vector is defined it needs a (n, witch is initialised by 2) for selecting random ID's3. A value (n) if the selection should be random#### Hints- If StudyTime isn't given the Population will be initialising with 0```{r}sel_SubPop <-function(Pop = Pop,IDs =NULL,n =2) {if (is.null(IDs)) { IDs <-sample( Pop[["ID"]], size=n ) } SubPop <-list() SubPop$sel <- Pop %>%filter(ID %in% IDs) %>%arrange(match(ID, IDs)) SubPop$rest <- Pop %>%filter(!ID %in% IDs)return(SubPop)}```#### Output1. List with Sub Population (\$sel) and the rest of the Population(\$rest)```{r}SubPop <-sel_SubPop( Pop = Pop )SubPop$selSubPop$rest``````{r}SubPop <-sel_SubPop( Pop = Pop , IDs =c(2, 1))SubPop$selSubPop$rest```### Integrate Sub Population#### Needs1. A Sub Population (SubPop) with Agents defined by ID's which are also defined in Population2. A Population (Pop) with several Agents defined by ID's#### Hints- SubPop and Pop has to have the same cols```{r}int_SubPop <-function(SubPop = SubPop,Pop = Pop) { col_sort <-colnames(Pop) SubPop <- SubPop[, col_sort] IDs <- SubPop[["ID"]] Pop[Pop$ID %in% IDs,] <- SubPop Pop <- Pop %>%arrange(ID)return(Pop)}```#### Output1. Population with the defined StudyTime```{r}PopSubPop <-sel_SubPop(Pop = Pop, n =2 )$selSubPop <-set_Knowledge(Pop = SubPop, K =0)SubPopPop <-int_SubPop(SubPop = SubPop, Pop = Pop)Pop```## Timelinessaving Timelines during Simulations### Get Agents-Timelines#### Needs1. A container name for the Timeline2. A value for the Time3. A Population (Pop) with several Agents defined by ID's4. A colname from the Population which should followed ver Time5. optional parameter Sum. Ich Sum = 1 a mean and median is calculated for each Time```{r}get_Timeline <-function(TL = Timeline,Time =0,Pop = Pop,Info = name,Sum =0) { TLadd <-tibble( ID = Pop[["ID"]],Time = Time,!!Info := Pop[[Info]])if (Sum ==1) { Sumname1 <-paste(Info,"mean", sep ="_") Sumname2 <-paste(Info,"median", sep ="_") TLadd <- TLadd %>%mutate(!!Sumname1 :=mean(Pop[[Info]], na.rm =TRUE),!!Sumname2 :=median(Pop[[Info]], na.rm =TRUE)) }if (Time ==0) { TL <- TLadd } else { TL <-bind_rows(TL, TLadd) }return(TL) }```#### Output1. A Timeline in a long format```{r}Timeline <-get_Timeline( TL = Timeline, Time =0, Pop = Pop, Info ="Knowledge", Sum =1)Timeline <-get_Timeline( TL = Timeline, Time =1, Pop = Pop, Info ="Knowledge", Sum =1)Timeline```## **Learning**Learning with a exponential lern rate#### Needs1. A Population (Pop) with several Agents defined by ID's and Knowledge2. optional for future implementations a name (Typ) for the specific Knowledge3. A value for the learn rate (LR). could be a scalar or e vector with the same length as the Population4. A value for the study time (ST). could be a scalar or e vector with the same length as the Population#### Hints- If learn rate isn't given the values from the Population will be used, if this is missing in the Population 0 is used.```{r}learn <-function(Pop = Pop,Typ =FALSE,LR =FALSE,ST = StudyTime) { Kname <-"Knowledge"if (Typ !=FALSE) { Kname <-paste(Kname, Typ, sep ="_") }if (Kname %in%colnames(Pop)) { K <- Pop[[Kname]] }if (LR ==FALSE) {if ("LearnRate"%in%colnames(Pop)) { LR <- Pop[["LearnRate"]] } } T0 <- ( 1- K )^( 1/-LR ) # assumed time learnd allready K <-1- ( T0 + ST )^( -LR ) # Knowledge after time learnd Pop <-set_Knowledge(Pop = Pop, Typ = Typ, K = K) Pop <-update_StudyTime(Pop = Pop, dT = ST)return(Pop)}```#### Output1. Population with updated Knowledge```{r}Pop <-tibble( ID = ID )Pop <-set_Knowledge(Pop = Pop, K =0.1)Pop <-set_LearnRate(Pop = Pop, LR =1)PopPop <-learn( Pop = Pop, ST =1)Pop```## SlotsFunctions to select and sets learning slots from a Population### Select a random Slot of pairs#### Needs1. A Population (Pop) with several Agents defined by ID's2. A size of the Slot in percents of the population#### Hints- because it leads to trouble will selecting otherwise the calculated n is limited at the moment between 1 and half of the Population```{r}sel_Slot_rnd <-function(Pop = Pop,psize = PrecentOfPop) { sID <-"Slot_ID" n <-round(nrow(Pop)*psize /2, 0) n <-max(n, 1) n <-min(n, round(nrow(Pop) /2, 0)) SubPop <-sel_SubPop( Pop = Pop, n = n) Slot1 <- SubPop$sel %>%mutate(!!sID :=seq_len(n)) SubPop <-sel_SubPop( Pop = SubPop$rest, n = n) Slot2 <- SubPop$sel %>%mutate(!!sID :=seq_len(n)) Slot <-bind_rows(Slot1, Slot2)return(Slot) } ```#### Output1. A random Slot-Population with Slot ID's which marks the pairs```{r}Popround(nrow(Pop) /2,0)Slot <-sel_Slot_rnd(Pop = Pop, psize =0.8)Slot```### Sets Slot parameter by Slot-ID's#### Needs1. A Slot of paird Agents defined by Slot_ID's2. A duration of the slot. could be a scalar or a vector with the same length as the number of pairs in the Slot```{r}set_SlotPar <-function(Slot = Slot,ST = SlotDuration) { LRname <-"LearnRate" sLRname <-"Slot_LearnRate" Slot <- Slot %>%group_by(Slot_ID) %>%mutate( !!sLRname :=mean(.data[[LRname]], na.rm =TRUE),Slot_Duration := ST) %>%ungroup()return(Slot)}```#### Output1. A random Slot-Population with Slot ID's which marks the pairs, learn rate and duration of the Slot defined by pairs```{r}Slot <-set_SlotPar(Slot = Slot, ST =1)Slot```### **Learning by Slots**Learning with a exponential learn rate defined by pairs#### Needs1. A Slot-Population with several paired Agents defined by Slot-ID's. Prepaerd by the function set_SlotPar()2. optional for future implementations a name (Typ) for the specific Knowledge```{r}learn_Slot <-function(Slot = Slot,Typ =FALSE) { Kname <-"Knowledge"if (Typ !=FALSE) { Kname <-paste(Kname, Typ, sep ="_") } LRname <-"Slot_LearnRate" STname <-"Slot_Duration" K <- Slot[[Kname]] LR <- Slot[[LRname]] ST <- Slot[[STname]] T0 <- ( 1- K )^( 1/-LR ) # assumed time learnd allready K <-1- ( T0 + ST )^( -LR ) # Knowledge after time learnd Slot <-set_Knowledge(Pop = Slot, Typ = Typ, K = K) Slot <-update_StudyTime(Pop = Slot, dT = ST)return(Slot)}```#### Output1. Slot-Population with updated Knowledge```{r}Slot <-learn_Slot(Slot = Slot)SlotPop <-int_SubPop(SubPop = Slot, Pop = Pop)Pop```## **Plots**### Plot Timeline#### Needs1. A Timeline from get_Timeline```{r}plt_Timeline <-function(TL = Timeline) {ggplot(data = TL, aes(x = Time)) +geom_line(aes(y = Knowledge, group = ID, color ="Agents"), alpha =0.5,linetype ="solid") +geom_line(aes(y = Knowledge_mean, color ="Mean"),linetype ="solid") +geom_line(aes(y = Knowledge_median, color ="Median"),linetype ="dashed") +ggtitle("Timeline") +xlab("Number of Slots") +ylab("Knowledge") +scale_y_continuous(limits =c(0, 1),breaks =seq(0, 1, 0.2) ) +scale_color_manual(values =c("Agents"="grey", "Mean"="black", "Median"="black"),labels =c("Agents"="Agents", "Mean"="Mean", "Median"="Median") ) +theme_light() +theme(legend.title =element_blank(),legend.position ="top",legend.justification ="left" )}```#### Output1. ggplot2# **Simulation**A learning process with updated learn rate by current knowledge when Agents meet randomly by Slots#### Needs1. A Population (Pop) with several Agents defined by ID's and Knowledge2. optional for future implementations a name (Typ) for the specific Knowledge3. A size of the Slot in percents of the population4. A duration of the slot. could be a scalar or a vector with the same length as the number of pairs in the Slot5. A number of Slots (STn)```{r}sim_Slot <-function(Pop = Pop,Typ =FALSE,psize = PrecentOfPop,ST =1,STn = Itterations) { Kname <-"Knowledge"if (Typ !=FALSE) { Kname <-paste(Kname, Typ, sep ="_") } Pop <-update_LearnRate_Knowledge( Pop = Pop ) Pop <-set_StudyTime( Pop = Pop ) TL <-get_Timeline( TL =TL,Time =0,Pop = Pop,Info = Kname,Sum =1 )for(i in1:STn) { Slot <-sel_Slot_rnd( Pop = Pop, psize = psize ) Slot <-set_SlotPar(Slot = Slot, ST = ST) Slot <-learn_Slot(Slot = Slot, Typ = Typ) Slot <-update_LearnRate_Knowledge( Pop = Slot ) Pop <-int_SubPop( SubPop = Slot, Pop = Pop ) TL <-get_Timeline( TL =TL,Time = i,Pop = Pop,Info = Kname,Sum =1 ) } Output <-list( Pop = Pop,TL = TL)return(Output)}```#### Output1. A List with the new Population and a Timeline over the number of itterations```{r}nA <-50# number of AgentsID <-seq_len(nA) # ID of the AgentsK <- (seq_len(nA)-1)/50# KnowledgenM <-160# number of meetings(mean)psize <-0.6STn <- (nM * nA ) / (psize * nA )Pop <-tibble( ID = ID )Pop <-set_Knowledge( Pop = Pop, K = K )Popres <-sim_Slot(Pop = Pop,psize = psize,ST =1,STn = STn)mean(res$Pop[["StudyTime"]])res$Popplt_Timeline(res$TL)```## ... Special Cases### Only one Agent with Knowledge (0.8)```{r}K <-0# KnowledgePop <-tibble( ID = ID )Pop <-set_Knowledge( Pop = Pop, K = K )Pop[ID ==1, "Knowledge"] <-0.8Popres <-sim_Slot(Pop = Pop,psize = psize,ST =1,STn = STn)res$Popplt_Timeline(res$TL)```