// File: richardposner[P]BioNetFit2/src/code/Swarm.cpp
// Function: Swarm::calcQPSOmBests()
vector<double> Swarm::calcQPSOmBests() {
	// Eq 2b Liu et al
	//cout<<"Modification needed\n...."; mypause();

	vector<double> mBests;

	//for (unsigned int param = 0; param < options.model->getFreeParams_().size(); ++param) {
	//for (auto param = this->getFreeParams_().begin(); param != this->getFreeParams_().end(); ++param) { //for (auto param = options.model->getFreeParams_().begin(); param != options.model->getFreeParams_().end(); ++param) {
	unsigned int i = 0;



		double sum = 0;
		for (int particle = 1; particle <= options.swarmSize; ++particle) {
			i = 0;
			for (auto param = particleCurrParamSets_.at(particle).begin(); param != particleCurrParamSets_.at(particle).end(); ++param) {

//				for(int mid=0; mid < options.models.size(); mid++){

					sum += abs(particleBestParamSets_.at(particle)[i]);

	//			}
				++i;
			}



			double mean = sum / (double)options.swarmSize;

			// TODO: Adaptive mutation ala Liu 2005
			if (options.mutateQPSO) {
				boost::random::cauchy_distribution<double> dist(0, cauchyMutator_);
				double mutator = dist(generalRand);
				mean += mutator;
				//cout << mean << " mutated by: " << mutator << endl;
			}
			mBests.push_back(sum / (double)options.swarmSize);

		}


	//}

	return mBests;

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xc0, %rsp
movq %rdi, -0x98(%rbp)
movq %rdi, %rax
movq %rax, -0x90(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x88(%rbp)
movb $0x0, -0x11(%rbp)
callq 0xb2580
movl $0x0, -0x18(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x20(%rbp)
movl $0x1, -0x24(%rbp)
movq -0x88(%rbp), %rcx
movl -0x24(%rbp), %eax
cmpl 0x1620(%rcx), %eax
jg 0xef619
movq -0x88(%rbp), %rdi
movl $0x0, -0x18(%rbp)
addq $0x1400, %rdi           # imm = 0x1400
movl -0x24(%rbp), %eax
movl %eax, -0x34(%rbp)
leaq -0x34(%rbp), %rsi
callq 0x122470
movq %rax, -0xa0(%rbp)
jmp 0xef471
movq -0xa0(%rbp), %rdi
callq 0xb2ea0
movq %rax, -0x30(%rbp)
movq -0x88(%rbp), %rdi
addq $0x1400, %rdi           # imm = 0x1400
movl -0x24(%rbp), %eax
movl %eax, -0x54(%rbp)
leaq -0x54(%rbp), %rsi
callq 0x122470
movq %rax, -0xa8(%rbp)
jmp 0xef4a7
movq -0xa8(%rbp), %rdi
callq 0xbdfd0
movq %rax, -0x50(%rbp)
leaq -0x30(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x122510
testb $0x1, %al
jne 0xef4cd
jmp 0xef55d
movq -0x88(%rbp), %rdi
addq $0x1cc0, %rdi           # imm = 0x1CC0
movl -0x24(%rbp), %eax
movl %eax, -0x58(%rbp)
leaq -0x58(%rbp), %rsi
callq 0x122470
movq %rax, -0xb0(%rbp)
jmp 0xef4f3
movq -0xb0(%rbp), %rdi
movl -0x18(%rbp), %eax
movl %eax, %esi
callq 0xb2610
movsd (%rax), %xmm0
callq 0x9c8a0
movsd %xmm0, -0xb8(%rbp)
jmp 0xef517
movsd -0xb8(%rbp), %xmm0
addsd -0x20(%rbp), %xmm0
movsd %xmm0, -0x20(%rbp)
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
leaq -0x30(%rbp), %rdi
callq 0xb2ef0
jmp 0xef481
movq -0x98(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
callq 0xb2660
jmp 0xef63f
movq -0x88(%rbp), %rax
movsd -0x20(%rbp), %xmm0
cvtsi2sdl 0x1620(%rax), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0x60(%rbp)
testb $0x1, 0x16ac(%rax)
je 0xef5da
movq -0x88(%rbp), %rax
movsd 0x1da8(%rax), %xmm1
leaq -0x70(%rbp), %rdi
xorps %xmm0, %xmm0
callq 0x122550
jmp 0xef5a0
movq -0x88(%rbp), %rsi
addq $0x58, %rsi
leaq -0x70(%rbp), %rdi
callq 0x122580
movsd %xmm0, -0xc0(%rbp)
jmp 0xef5be
movsd -0xc0(%rbp), %xmm0
movsd %xmm0, -0x78(%rbp)
movsd -0x78(%rbp), %xmm0
addsd -0x60(%rbp), %xmm0
movsd %xmm0, -0x60(%rbp)
movq -0x98(%rbp), %rdi
movq -0x88(%rbp), %rax
movsd -0x20(%rbp), %xmm0
cvtsi2sdl 0x1620(%rax), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0x80(%rbp)
leaq -0x80(%rbp), %rsi
callq 0xb2630
jmp 0xef609
jmp 0xef60b
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0xef42e
movb $0x1, -0x11(%rbp)
testb $0x1, -0x11(%rbp)
jne 0xef62f
movq -0x98(%rbp), %rdi
callq 0xb2660
movq -0x90(%rbp), %rax
addq $0xc0, %rsp
popq %rbp
retq
movq -0x40(%rbp), %rdi
callq 0x30170
nopl (%rax,%rax)