// File: /workspace/github_cpp_makefile_star2_O1/richardposner[P]BioNetFit2/src/code/Swarm.cpp
// Function: Swarm::runSGA()
void Swarm::runSGA() {
	if (options.verbosity >= 3) {
		cout << "Running synchronous genetic fit" << endl;
	}

	if (!checkIfFileExists(options.jobOutputDir + "1")) {
		string createDirCmd = "mkdir " + options.jobOutputDir + "1";
		if (runCommand(createDirCmd) != 0) {
			outputError("Error: Couldn't create first generation output directory with command: " + createDirCmd + ". Quitting.");
		}
	}

	bool stopCriteria = false;
	while (!stopCriteria){
		//cout << "RAQUEL: starting runGeneration" << endl;
		runGeneration();
		//cout << "RAQUEL: finished runGeneration" << endl;
		//cout << "RAQUEL: starting checkStopCriteria" << endl;
		//cout << "RAQUEL: STOP CRITERIA value" << stopCriteria << endl;
		//cout << "RAQUEL: starting saveSwarmState" << endl;

		saveSwarmState();
		//cout << "RAQUEL: finished saveSwarmState" << endl;

		string currentDirectory = options.jobOutputDir + toString(currentGeneration);
		if (options.deleteOldFiles) {
			//cout << "RAQUEL: starting cleanupFiles" << endl;

			cleanupFiles(currentDirectory.c_str());
			//cout << "RAQUEL: finished cleanupFiles" << endl;

		}

		string outputPath = options.jobOutputDir + toString(currentGeneration - 1 ) + "_summary.txt";
		cout << "Generation: " << toString(currentGeneration - 1 ) << endl;
		//cout << "RAQUEL: starting outputRunSummary from runSGA" << endl;

		outputRunSummary(outputPath);
		if(options.verbosity>=3){
			cout << "RAQUEL: finished outputRunSummary from runSGA" << endl;
			//cout << "RAQUEL: starting breedGenerationGA from runSGA" << endl;
		}
		stopCriteria = checkStopCriteria();

		if (!stopCriteria) {

			breedGenerationGA();
			if(options.verbosity>=3){

				cout << "Finished breedGenerationGA from runSGA" << endl;
			}
		}
	}
	//cout << "RAQUEL: got out from WHILE STOP CRITERIA" << endl;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x118, %rsp            # imm = 0x118
movq %rdi, %rbx
cmpl $0x3, 0x1614(%rdi)
jb 0x7e03f
movq 0xf7f8c(%rip), %r14     # 0x175f90
leaq 0x82703(%rip), %rsi     # 0x10070e
movl $0x1f, %edx
movq %r14, %rdi
callq 0x22ab0
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x22940
movsbl %al, %esi
movq %r14, %rdi
callq 0x22050
movq %rax, %rdi
callq 0x22660
leaq 0xa8(%rsp), %r15
movq %r15, -0x10(%r15)
movq 0x1520(%rbx), %rsi
movq 0x1528(%rbx), %rdx
addq %rsi, %rdx
leaq 0x98(%rsp), %r14
movq %r14, %rdi
callq 0x32180
leaq 0x7ab89(%rip), %rsi     # 0xf8bfc
movq %r14, %rdi
callq 0x233b0
leaq 0x98(%rsp), %rdi
callq 0xbf2c2
movl %eax, %ebp
movq 0x98(%rsp), %rdi
cmpq %r15, %rdi
je 0x7e0a7
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x229c0
testl %ebp, %ebp
jne 0x7e1a9
leaq 0x1520(%rbx), %rdx
leaq 0x79eda(%rip), %rsi     # 0xf7f97
leaq 0x20(%rsp), %r14
movq %r14, %rdi
callq 0x319d8
leaq 0x7ab2b(%rip), %rsi     # 0xf8bfc
movq %r14, %rdi
callq 0x233b0
leaq 0x10(%rsp), %r14
movq %r14, -0x10(%r14)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x7e0ff
movq %rdx, (%rsp)
movq (%rcx), %rdx
movq %rdx, 0x10(%rsp)
jmp 0x7e106
movups (%rcx), %xmm0
movups %xmm0, (%r14)
movq 0x8(%rax), %rdx
movq %rdx, 0x8(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0x30(%rsp), %r15
movq -0x10(%r15), %rdi
cmpq %r15, %rdi
je 0x7e139
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x229c0
leaq 0xe8(%rsp), %r12
movq %r12, -0x10(%r12)
movq (%rsp), %rsi
movq 0x8(%rsp), %rdx
addq %rsi, %rdx
leaq 0xd8(%rsp), %rdi
callq 0x32180
leaq 0xd8(%rsp), %rdi
callq 0xc038e
movl %eax, %ebp
movq 0xd8(%rsp), %rdi
cmpq %r12, %rdi
je 0x7e18b
movq 0xe8(%rsp), %rsi
incq %rsi
callq 0x229c0
testl %ebp, %ebp
jne 0x7e5a7
movq (%rsp), %rdi
cmpq %r14, %rdi
je 0x7e1a9
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x229c0
leaq 0x10(%rsp), %r14
leaq 0x30(%rsp), %r15
leaq 0xb8(%rsp), %r12
movq 0xf7dce(%rip), %rbp     # 0x175f90
movq %r15, %r13
movq %r12, %r15
movq %rbx, %rdi
callq 0x8d672
movq %rbx, %rdi
callq 0x9c93c
movl 0x13e8(%rbx), %esi
leaq 0x20(%rsp), %r12
movq %r12, %rdi
callq 0xc03b8
movq 0x1520(%rbx), %rcx
movq 0x1528(%rbx), %r8
movq %r12, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x22a80
movq %r14, (%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x7e226
movq %rdx, (%rsp)
movq (%rcx), %rdx
movq %rdx, 0x10(%rsp)
jmp 0x7e22d
movups (%rcx), %xmm0
movups %xmm0, (%r14)
movq %r15, %r12
movq 0x8(%rax), %rdx
movq %rdx, 0x8(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq 0x20(%rsp), %rdi
movq %r13, %r15
cmpq %r13, %rdi
je 0x7e262
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x229c0
cmpb $0x1, 0x1646(%rbx)
jne 0x7e274
movq (%rsp), %rsi
callq 0x91f58
movl 0x13e8(%rbx), %esi
decl %esi
movq %r12, %rdi
callq 0xc03b8
movq 0x1520(%rbx), %rcx
movq 0x1528(%rbx), %r8
movq %r12, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x22a80
leaq 0x50(%rsp), %rsi
movq %rsi, 0x40(%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x7e2c6
movq %rdx, 0x40(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x50(%rsp)
jmp 0x7e2cc
movups (%rcx), %xmm0
movups %xmm0, (%rsi)
movq 0x8(%rax), %rdx
movq %rdx, 0x48(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0x40(%rsp), %rdi
leaq 0x82486(%rip), %rsi     # 0x100776
callq 0x233b0
movq %r15, 0x20(%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x7e318
movq %rdx, 0x20(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x30(%rsp)
jmp 0x7e31f
movups (%rcx), %xmm0
movups %xmm0, (%r15)
movq 0x8(%rax), %rdx
movq %rdx, 0x28(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0x7e353
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x229c0
movq 0xb8(%rsp), %rdi
leaq 0xc8(%rsp), %rax
cmpq %rax, %rdi
je 0x7e378
movq 0xc8(%rsp), %rsi
incq %rsi
callq 0x229c0
movl $0xc, %edx
movq %rbp, %rdi
leaq 0x80f6b(%rip), %rsi     # 0xff2f2
callq 0x22ab0
movl 0x13e8(%rbx), %esi
decl %esi
leaq 0x40(%rsp), %rdi
callq 0xc03b8
movq 0x40(%rsp), %rsi
movq 0x48(%rsp), %rdx
movq %rbp, %rdi
callq 0x22ab0
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x22940
movsbl %al, %esi
movq %r14, %rdi
callq 0x22050
movq %rax, %rdi
callq 0x22660
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0x7e3f6
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x229c0
leaq 0x70(%rsp), %rax
movq %rax, 0x60(%rsp)
movq 0x20(%rsp), %rsi
movq 0x28(%rsp), %rdx
addq %rsi, %rdx
leaq 0x60(%rsp), %rdi
callq 0x32180
movq %rbx, %rdi
leaq 0x60(%rsp), %rsi
callq 0x92400
movq 0x60(%rsp), %rdi
leaq 0x70(%rsp), %rax
cmpq %rax, %rdi
je 0x7e440
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x229c0
cmpl $0x3, 0x1614(%rbx)
jb 0x7e485
movl $0x2d, %edx
movq %rbp, %rdi
leaq 0x8232b(%rip), %rsi     # 0x100783
callq 0x22ab0
movq (%rbp), %rax
movq -0x18(%rax), %rdi
addq %rbp, %rdi
movl $0xa, %esi
callq 0x22940
movsbl %al, %esi
movq %rbp, %rdi
callq 0x22050
movq %rax, %rdi
callq 0x22660
movq %rbx, %rdi
callq 0x8795e
movl %eax, %r14d
testb %al, %al
jne 0x7e563
xorps %xmm0, %xmm0
movaps %xmm0, 0x80(%rsp)
movq $0x0, 0x90(%rsp)
movq %rbx, %rdi
leaq 0x80(%rsp), %rsi
callq 0x9d6f8
movq 0x80(%rsp), %rdi
testq %rdi, %rdi
je 0x7e4dc
movq 0x90(%rsp), %rsi
subq %rdi, %rsi
callq 0x229c0
cmpl $0x3, 0x1614(%rbx)
jb 0x7e521
movl $0x26, %edx
movq %rbp, %rdi
leaq 0x822bd(%rip), %rsi     # 0x1007b1
callq 0x22ab0
movq (%rbp), %rax
movq -0x18(%rax), %rdi
addq %rbp, %rdi
movl $0xa, %esi
callq 0x22940
movsbl %al, %esi
movq %rbp, %rdi
callq 0x22050
movq %rax, %rdi
callq 0x22660
movq 0x20(%rsp), %rdi
cmpq %r15, %rdi
je 0x7e538
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x229c0
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x7e553
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x229c0
testb %r14b, %r14b
leaq 0x10(%rsp), %r14
je 0x7e1c2
jmp 0x7e595
movq 0x20(%rsp), %rdi
cmpq %r15, %rdi
je 0x7e57a
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x229c0
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x7e595
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x229c0
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x82180(%rip), %rsi     # 0x10072e
leaq 0x20(%rsp), %rdi
movq %rsp, %rdx
callq 0x319d8
leaq 0x83410(%rip), %rsi     # 0x1019d2
leaq 0x20(%rsp), %rdi
callq 0x233b0
leaq 0x108(%rsp), %r12
movq %r12, -0x10(%r12)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
jne 0x7e5f2
movups (%rcx), %xmm0
movups %xmm0, (%r12)
jmp 0x7e605
movq %rdx, 0xf8(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x108(%rsp)
movq 0x8(%rax), %rdx
leaq 0xf8(%rsp), %rsi
movq %rdx, 0x8(%rsi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq %rbx, %rdi
callq 0x78b66
movq %rax, %rbx
movq 0xf8(%rsp), %rdi
cmpq %r12, %rdi
je 0x7e651
movq 0x108(%rsp), %rsi
incq %rsi
callq 0x229c0
jmp 0x7e651
movq %rax, %rbx
movq 0x20(%rsp), %rdi
cmpq %r15, %rdi
jne 0x7e7b5
jmp 0x7e7c2
jmp 0x7e6c2
movq %rax, %rbx
movq 0xd8(%rsp), %rdi
cmpq %r12, %rdi
je 0x7e7c2
movq 0xe8(%rsp), %rsi
jmp 0x7e7ba
jmp 0x7e6c2
movq %rax, %rbx
leaq 0x30(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
jne 0x7e70c
jmp 0x7e7d8
jmp 0x7e6a1
movq %rax, %rbx
movq 0x98(%rsp), %rdi
cmpq %r15, %rdi
je 0x7e7d8
movq 0xa8(%rsp), %rsi
jmp 0x7e7d0
movq %rax, %rbx
jmp 0x7e7c2
movq %rax, %rbx
movq 0x80(%rsp), %rdi
testq %rdi, %rdi
je 0x7e79e
movq 0x90(%rsp), %rsi
subq %rdi, %rsi
jmp 0x7e799
movq %rax, %rbx
jmp 0x7e79e
movq %rax, %rbx
jmp 0x7e74e
movq %rax, %rbx
movq 0x20(%rsp), %rdi
cmpq %r13, %rdi
je 0x7e7d8
movq 0x30(%rsp), %rsi
jmp 0x7e7d0
movq %rax, %rbx
movq 0x60(%rsp), %rdi
leaq 0x70(%rsp), %rax
cmpq %rax, %rdi
je 0x7e79e
movq 0x70(%rsp), %rsi
jmp 0x7e796
movq %rax, %rbx
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0x7e74e
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x229c0
movq 0xb8(%rsp), %rdi
leaq 0xc8(%rsp), %rax
cmpq %rax, %rdi
je 0x7e778
movq 0xc8(%rsp), %rsi
incq %rsi
callq 0x229c0
jmp 0x7e778
movq %rax, %rbx
leaq 0x10(%rsp), %r14
jmp 0x7e7c2
movq %rax, %rbx
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0x7e79e
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x229c0
movq %r13, %r15
jmp 0x7e7a6
movq %rax, %rbx
movq 0x20(%rsp), %rdi
cmpq %r15, %rdi
leaq 0x10(%rsp), %r14
je 0x7e7c2
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x229c0
movq (%rsp), %rdi
cmpq %r14, %rdi
je 0x7e7d8
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x229c0
movq %rbx, %rdi
callq 0x23240