// File: richardposner[P]BioNetFit2/src/code/Swarm.cpp
// Function: Swarm::generateBestFitModel(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
void Swarm::generateBestFitModel(string outputDir) {
	map<string, double> paramSet;

	vector<string> paramVals;
	auto best = allGenFits.begin();
	split(best->second, paramVals);

	auto fp = this->getFreeParams_().begin();
	for (unsigned int i = 1; i < paramVals.size(); i++) {
		paramSet.insert(pair<string, double> (fp->first, stod(paramVals[i])));
		++fp;
	}
	if (options.verbosity>=3) cout<<"Swarm: Generating Best Fit Model in path:"<< outputDir<< " File:"<<options.jobName<<".bngl .\n";

	//razi TODO:   adjust paramSet based on the model
	for (unsigned int mid =0; mid < options.models.size(); mid++){
		options.models[mid]->outputModelWithParams(paramSet, outputDir, (options.jobName + ".bngl"), "", false, false, false, false, false);
	}

	if(options.verbosity>=3){
		cout << "Finished saving " << options.jobName << ".bngl" << endl;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x250, %rsp            # imm = 0x250
movq %rsi, -0x1a8(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x1a0(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x8de30
leaq -0x58(%rbp), %rdi
callq 0x448b0
movq -0x1a0(%rbp), %rdi
addq $0x8, %rdi
callq 0x1250c0
movq %rax, -0x60(%rbp)
leaq -0x60(%rbp), %rdi
callq 0x1250f0
addq $0x8, %rax
movq %rax, -0x198(%rbp)
leaq -0x81(%rbp), %rdi
movq %rdi, -0x190(%rbp)
callq 0x30a70
movq -0x190(%rbp), %rdx
leaq 0xdb33f(%rip), %rsi     # 0x1e40cf
leaq -0x80(%rbp), %rdi
callq 0x44470
jmp 0x108d9b
movq -0x198(%rbp), %rdi
leaq -0x58(%rbp), %rsi
leaq -0x80(%rbp), %rdx
callq 0x17d490
jmp 0x108db1
leaq -0x80(%rbp), %rdi
callq 0x311e8
leaq -0x81(%rbp), %rdi
callq 0x311c0
movq -0x1a0(%rbp), %rdi
callq 0x125110
movq %rax, -0x1b0(%rbp)
jmp 0x108ddb
movq -0x1b0(%rbp), %rdi
callq 0xb3200
movq %rax, -0xa0(%rbp)
movl $0x1, -0xa4(%rbp)
movl -0xa4(%rbp), %eax
movq %rax, -0x1b8(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x44960
movq %rax, %rcx
movq -0x1b8(%rbp), %rax
cmpq %rcx, %rax
jae 0x108f66
leaq -0xa0(%rbp), %rdi
callq 0xb3230
movq %rax, -0x1c8(%rbp)
movl -0xa4(%rbp), %eax
movl %eax, %esi
leaq -0x58(%rbp), %rdi
callq 0x449e0
movq %rax, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x44830
movsd %xmm0, -0x1c0(%rbp)
jmp 0x108e5b
movq -0x1c8(%rbp), %rsi
movsd -0x1c0(%rbp), %xmm0
movsd %xmm0, -0xd8(%rbp)
leaq -0xd0(%rbp), %rdi
leaq -0xd8(%rbp), %rdx
callq 0x8e760
jmp 0x108e87
leaq -0x40(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
callq 0x8e720
movb %dl, -0x1d1(%rbp)
movq %rax, -0x1d0(%rbp)
jmp 0x108ea6
movb -0x1d1(%rbp), %al
movq -0x1d0(%rbp), %rcx
movq %rcx, -0xe8(%rbp)
movb %al, -0xe0(%rbp)
leaq -0xd0(%rbp), %rdi
callq 0x8e7a0
leaq -0xa0(%rbp), %rdi
callq 0xb3260
movl -0xa4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xa4(%rbp)
jmp 0x108df8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
jmp 0x108f1b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x311e8
leaq -0x81(%rbp), %rdi
callq 0x311c0
jmp 0x1092b1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
jmp 0x1092b1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
leaq -0xd0(%rbp), %rdi
callq 0x8e7a0
jmp 0x1092b1
movq -0x1a0(%rbp), %rax
cmpl $0x3, 0x1614(%rax)
jb 0x109008
movq 0x1cbfcf(%rip), %rdi    # 0x2d4f50
leaq 0xdb1c7(%rip), %rsi     # 0x1e414f
callq 0x2ff50
movq %rax, -0x1e0(%rbp)
jmp 0x108f96
movq -0x1a8(%rbp), %rsi
movq -0x1e0(%rbp), %rdi
callq 0x2f780
movq %rax, -0x1e8(%rbp)
jmp 0x108fb2
movq -0x1e8(%rbp), %rdi
leaq 0xd8124(%rip), %rsi     # 0x1e10e4
callq 0x2ff50
movq %rax, -0x1f0(%rbp)
jmp 0x108fce
movq -0x1f0(%rbp), %rdi
movq -0x1a0(%rbp), %rsi
addq $0x14c0, %rsi           # imm = 0x14C0
callq 0x2f780
movq %rax, -0x1f8(%rbp)
jmp 0x108ff1
movq -0x1f8(%rbp), %rdi
leaq 0xdb17a(%rip), %rsi     # 0x1e4179
callq 0x2ff50
jmp 0x109006
jmp 0x109008
movl $0x0, -0xec(%rbp)
movq -0x1a0(%rbp), %rdi
movl -0xec(%rbp), %eax
movq %rax, -0x200(%rbp)
addq $0x14c0, %rdi           # imm = 0x14C0
addq $0x100, %rdi            # imm = 0x100
callq 0x45170
movq %rax, %rcx
movq -0x200(%rbp), %rax
cmpq %rcx, %rax
jae 0x109214
movq -0x1a0(%rbp), %rdi
addq $0x15c0, %rdi           # imm = 0x15C0
movl -0xec(%rbp), %eax
movl %eax, %esi
callq 0x45b40
movq (%rax), %rax
movq %rax, -0x208(%rbp)
leaq -0x120(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x9c620
jmp 0x109083
movq -0x1a8(%rbp), %rsi
leaq -0x140(%rbp), %rdi
callq 0x2f300
jmp 0x109098
movq -0x1a0(%rbp), %rsi
addq $0x14c0, %rsi           # imm = 0x14C0
leaq 0xd2ad1(%rip), %rdx     # 0x1dbb7e
leaq -0x160(%rbp), %rdi
callq 0x447b0
jmp 0x1090bb
leaq -0x181(%rbp), %rdi
movq %rdi, -0x210(%rbp)
callq 0x30a70
movq -0x210(%rbp), %rdx
leaq 0xd0424(%rip), %rsi     # 0x1d9500
leaq -0x180(%rbp), %rdi
callq 0x44470
jmp 0x1090ea
movq -0x208(%rbp), %rdi
movq %rsp, %rax
movl $0x0, 0x18(%rax)
movl $0x0, 0x10(%rax)
movl $0x0, 0x8(%rax)
movl $0x0, (%rax)
leaq -0x120(%rbp), %rsi
leaq -0x140(%rbp), %rdx
leaq -0x160(%rbp), %rcx
leaq -0x180(%rbp), %r8
xorl %r9d, %r9d
callq 0x99b90
jmp 0x109135
leaq -0x180(%rbp), %rdi
callq 0x311e8
leaq -0x181(%rbp), %rdi
callq 0x311c0
leaq -0x160(%rbp), %rdi
callq 0x311e8
leaq -0x140(%rbp), %rdi
callq 0x311e8
leaq -0x120(%rbp), %rdi
callq 0x8de70
movl -0xec(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xec(%rbp)
jmp 0x109012
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
jmp 0x109203
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
jmp 0x1091f7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
jmp 0x1091df
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
leaq -0x180(%rbp), %rdi
callq 0x311e8
leaq -0x181(%rbp), %rdi
callq 0x311c0
leaq -0x160(%rbp), %rdi
callq 0x311e8
leaq -0x140(%rbp), %rdi
callq 0x311e8
leaq -0x120(%rbp), %rdi
callq 0x8de70
jmp 0x1092b1
movq -0x1a0(%rbp), %rax
cmpl $0x3, 0x1614(%rax)
jb 0x109296
movq 0x1cbd25(%rip), %rdi    # 0x2d4f50
leaq 0xdaf50(%rip), %rsi     # 0x1e4182
callq 0x2ff50
movq %rax, -0x218(%rbp)
jmp 0x109240
movq -0x218(%rbp), %rdi
movq -0x1a0(%rbp), %rsi
addq $0x14c0, %rsi           # imm = 0x14C0
callq 0x2f780
movq %rax, -0x220(%rbp)
jmp 0x109263
movq -0x220(%rbp), %rdi
leaq 0xd290d(%rip), %rsi     # 0x1dbb7e
callq 0x2ff50
movq %rax, -0x228(%rbp)
jmp 0x10927f
movq -0x228(%rbp), %rdi
movq 0x1cbd3b(%rip), %rsi    # 0x2d4fc8
callq 0x30c10
jmp 0x109294
jmp 0x109296
leaq -0x58(%rbp), %rdi
callq 0x448d0
leaq -0x40(%rbp), %rdi
callq 0x8de70
addq $0x250, %rsp            # imm = 0x250
popq %rbp
retq
leaq -0x58(%rbp), %rdi
callq 0x448d0
leaq -0x40(%rbp), %rdi
callq 0x8de70
movq -0x90(%rbp), %rdi
callq 0x30170
nop