function [globalparameters,globalmins]=tlbo(T,seq,indsol,ng,ni,runtimes)
[jobnum,macnum]=size(T);
oprnum=jobnum*macnum;
globalmins=zeros(runtimes,1);
globalparameters=zeros(runtimes,oprnum);
for R=1:runtimes
%%%% number of induvidual solutions or population in algorithm
[jobnum,macnum]=size(T);
oprnum=jobnum*macnum; %%%% total number of operations
solutions=zeros(indsol,oprnum); %%%% processing sequence for individual solutions
number=zeros(1,jobnum);
for i=1:jobnum
number(i)=macnum;
end
for j=1:indsol %%% initial solutions
jobopr=number;
for i=1:oprnum
val=unidrnd(jobnum);
while jobopr(val)==0
val=unidrnd(jobnum);
end
solutions(j,i)= val; %%%% processing sequence for individual solutions
jobopr(val)=jobopr(val)-1;
end
end
%%%%% calculating %%%%%%
%%%%%% best solution, minimum makespan value and process sequence for that value
%%%%%% makespan for individual solutions
makespan=zeros(indsol,1);
for i=1:indsol %%% initial makespan : [makespan1]=makespancal(s,seq,T) %%%%%%%%%%%%%%%%%%%%
s=solutions(i,:);
[makespan1]=makespancal(s,seq,T);
makespan(i,1)=makespan1;
end
bestindex=find(makespan==min(makespan));
globalmin=makespan(bestindex);
globalparameter=solutions(bestindex,:);
true=1;
while(true)
ni=ni+1;
%%%%% teachers phase bigins %%%%%%%
sorted_span=sort(makespan);
index=(fix(indsol/2));
mean_makespan=sorted_span(index,:);
mindex=find(makespan==mean_makespan);
md=solutions(mindex(1,1),:);
md_makespan=makespan(mindex(1,1),:);
indext=find(makespan==min(makespan));
teacher=solutions(indext(1,1),:);
teacher_makespan=makespan(indext(1,1),:);
a=teacher(1,1:oprnum);
b=md(1,1:oprnum);
[newsolution,newmakespan] = pbc(T,a,b,seq);
diff=newsolution;
diff_makespan=newmakespan;
Chrom=solutions;
teachersolutions=zeros(indsol,oprnum);
tmakespan=zeros(indsol,1);
for i=1:indsol %%%% finding teacher's phase solutions
a=Chrom(i,1:oprnum);
b=diff(1,1:oprnum);
[newsolution,newmakespan] = pbc(T,a,b,seq);
teachersolutions(i,:)=newsolution;
tmakespan(i,1)=newmakespan;
end
for i=1:indsol %%% applying greedy selection process at teacher's phase
if(makespan(i,1)>tmakespan(i,1))
solutions(i,:)=teachersolutions(i,:); % updating the solutions
makespan(i)=tmakespan(i);
end
end
%%%%%%%%%%%%% learners phase %%%%%%%%%%%%%%%%%
indexl=find(makespan==min(makespan));
bl=indexl;
best_learner=solutions(bl(1,1),:);
best_learnermakespan=makespan(bl(1,1),1);
[lsolutions,lmakespan] = TLBOvariablesearch(T,seq,solutions,makespan,indsol);
learner_solutions=lsolutions;
learner_makespan=lmakespan;
for i=1:indsol %%% applying greedy selection process at learner's phase
if(makespan(i,1)>learner_makespan(i,1))
solutions(i,:)=learner_solutions(i,:); % updating the solutions
makespan(i)=learner_makespan(i);
end
end
ind=find(makespan==min(makespan)); % best food source position is captured
ind=ind(end);
if (makespan(ind)<globalmin)
globalmin=makespan(ind);
globalparameter=solutions(ind,:);
end
if(ni==ng)
ni=0;
true=0;
else
true=1;
end
fprintf('no of runs =%d num of iterations =%d Global min=%g\n',R,ni,globalmin);
end
globalparameters(R,:)=globalparameter(:,:);
globalmins(R,1)=globalmin;
disp('globalmins')
disp(globalmins)
end