// File: /workspace/github_cpp_makefile_star2_O3/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 0x7d9af
movq 0xf8634(%rip), %r14     # 0x175fa8
leaq 0x82d7a(%rip), %rsi     # 0x1006f5
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 0xc8(%rsp), %r15
movq %r15, -0x10(%r15)
movq 0x1520(%rbx), %rsi
movq 0x1528(%rbx), %rdx
addq %rsi, %rdx
leaq 0xb8(%rsp), %r14
movq %r14, %rdi
callq 0x3213c
leaq 0x7b1f9(%rip), %rsi     # 0xf8bdc
movq %r14, %rdi
callq 0x233b0
leaq 0xb8(%rsp), %rdi
callq 0xbe9a8
movl %eax, %ebp
movq 0xb8(%rsp), %rdi
cmpq %r15, %rdi
je 0x7da17
movq 0xc8(%rsp), %rsi
incq %rsi
callq 0x229c0
testl %ebp, %ebp
jne 0x7db1a
leaq 0x1520(%rbx), %rdx
leaq 0x7a51a(%rip), %rsi     # 0xf7f47
movq %rsp, %r14
movq %r14, %rdi
callq 0x31944
leaq 0x7b19d(%rip), %rsi     # 0xf8bdc
movq %r14, %rdi
callq 0x233b0
leaq 0x30(%rsp), %r14
movq %r14, -0x10(%r14)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x7da6e
movq %rdx, 0x20(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x30(%rsp)
jmp 0x7da75
movups (%rcx), %xmm0
movups %xmm0, (%r14)
movq 0x8(%rax), %rdx
movq %rdx, 0x28(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0x10(%rsp), %r15
movq -0x10(%r15), %rdi
cmpq %r15, %rdi
je 0x7daa8
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x229c0
leaq 0xe8(%rsp), %r12
movq %r12, -0x10(%r12)
movq 0x20(%rsp), %rsi
movq 0x28(%rsp), %rdx
addq %rsi, %rdx
leaq 0xd8(%rsp), %rdi
callq 0x3213c
leaq 0xd8(%rsp), %rdi
callq 0xbfa1f
movl %eax, %ebp
movq 0xd8(%rsp), %rdi
cmpq %r12, %rdi
je 0x7dafb
movq 0xe8(%rsp), %rsi
incq %rsi
callq 0x229c0
testl %ebp, %ebp
jne 0x7df06
movq 0x20(%rsp), %rdi
cmpq %r14, %rdi
je 0x7db1a
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x229c0
leaq 0x30(%rsp), %r14
leaq 0x10(%rsp), %r15
leaq 0x50(%rsp), %r13
movq 0xf8478(%rip), %rbp     # 0x175fa8
movq %rbx, %rdi
callq 0x8cd7e
movq %rbx, %rdi
callq 0x9be92
movl 0x13e8(%rbx), %esi
movq %rsp, %r12
movq %r12, %rdi
callq 0xbfa49
movq 0x1520(%rbx), %rcx
movq 0x1528(%rbx), %r8
movq %r12, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x22a80
movq %r14, 0x20(%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x7db8e
movq %rdx, 0x20(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x30(%rsp)
jmp 0x7db95
movups (%rcx), %xmm0
movups %xmm0, (%r14)
leaq 0x80(%rsp), %r8
movq 0x8(%rax), %rdx
movq %rdx, 0x28(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq (%rsp), %rdi
cmpq %r15, %rdi
je 0x7dbd3
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x229c0
leaq 0x80(%rsp), %r8
cmpb $0x1, 0x1646(%rbx)
jne 0x7dbee
movq 0x20(%rsp), %rsi
callq 0x9163a
leaq 0x80(%rsp), %r8
movl 0x13e8(%rbx), %esi
decl %esi
movq %r8, %rdi
movq %r8, %r12
callq 0xbfa49
movq 0x1520(%rbx), %rcx
movq 0x1528(%rbx), %r8
movq %r12, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x22a80
movq %r13, 0x40(%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x7dc3e
movq %rdx, 0x40(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x50(%rsp)
jmp 0x7dc46
movups (%rcx), %xmm0
movups %xmm0, (%r13)
movq 0x8(%rax), %rdx
movq %rdx, 0x48(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0x40(%rsp), %rdi
leaq 0x82af3(%rip), %rsi     # 0x10075d
callq 0x233b0
movq %r15, (%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x7dc90
movq %rdx, (%rsp)
movq (%rcx), %rdx
movq %rdx, 0x10(%rsp)
jmp 0x7dc97
movups (%rcx), %xmm0
movups %xmm0, (%r15)
movq 0x8(%rax), %rdx
movq %rdx, 0x8(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq 0x40(%rsp), %rdi
cmpq %r13, %rdi
je 0x7dcc6
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x229c0
movq 0x80(%rsp), %rdi
leaq 0x90(%rsp), %rax
cmpq %rax, %rdi
je 0x7dceb
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x229c0
movl $0xc, %edx
movq %rbp, %rdi
leaq 0x81668(%rip), %rsi     # 0xff362
callq 0x22ab0
movq %r14, %r12
movl 0x13e8(%rbx), %esi
decl %esi
leaq 0x40(%rsp), %rdi
callq 0xbfa49
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
cmpq %r13, %rdi
movq %r12, %r14
je 0x7dd6a
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x229c0
leaq 0x70(%rsp), %rax
movq %rax, 0x60(%rsp)
movq (%rsp), %rsi
movq 0x8(%rsp), %rdx
addq %rsi, %rdx
leaq 0x60(%rsp), %rdi
callq 0x3213c
movq %rbx, %rdi
leaq 0x60(%rsp), %rsi
callq 0x91ae2
movq 0x60(%rsp), %rdi
leaq 0x70(%rsp), %rax
cmpq %rax, %rdi
je 0x7ddb3
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x229c0
cmpl $0x3, 0x1614(%rbx)
jb 0x7ddf8
movl $0x2d, %edx
movq %rbp, %rdi
leaq 0x8299f(%rip), %rsi     # 0x10076a
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 0x86f12
testb %al, %al
jne 0x7dec7
xorps %xmm0, %xmm0
movaps %xmm0, 0xa0(%rsp)
movq $0x0, 0xb0(%rsp)
movq %rbx, %rdi
leaq 0xa0(%rsp), %rsi
callq 0x9cc52
movq 0xa0(%rsp), %rdi
testq %rdi, %rdi
je 0x7de4c
movq 0xb0(%rsp), %rsi
subq %rdi, %rsi
callq 0x229c0
cmpl $0x3, 0x1614(%rbx)
jb 0x7de91
movl $0x26, %edx
movq %rbp, %rdi
leaq 0x82934(%rip), %rsi     # 0x100798
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 (%rsp), %rdi
cmpq %r15, %rdi
je 0x7dea7
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x229c0
movq 0x20(%rsp), %rdi
cmpq %r14, %rdi
je 0x7db30
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x229c0
jmp 0x7db30
movq (%rsp), %rdi
cmpq %r15, %rdi
je 0x7dedd
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x229c0
movq 0x20(%rsp), %rdi
cmpq %r14, %rdi
je 0x7def4
movq 0x30(%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 0x82808(%rip), %rsi     # 0x100715
movq %rsp, %rdi
leaq 0x20(%rsp), %rdx
callq 0x31944
leaq 0x83a98(%rip), %rsi     # 0x1019b9
movq %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 0x7df4f
movups (%rcx), %xmm0
movups %xmm0, (%r12)
jmp 0x7df62
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 0x784c2
movq %rax, %rbx
movq 0xf8(%rsp), %rdi
cmpq %r12, %rdi
je 0x7e0de
movq 0x108(%rsp), %rsi
incq %rsi
callq 0x229c0
jmp 0x7e0de
jmp 0x7e0db
jmp 0x7e058
movq %rax, %rbx
movq 0xd8(%rsp), %rdi
cmpq %r12, %rdi
je 0x7e0f4
movq 0xe8(%rsp), %rsi
jmp 0x7e0ec
jmp 0x7e058
movq %rax, %rbx
leaq 0x10(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
jne 0x7e04e
jmp 0x7e10b
jmp 0x7dff7
movq %rax, %rbx
movq 0xb8(%rsp), %rdi
cmpq %r15, %rdi
je 0x7e10b
movq 0xc8(%rsp), %rsi
jmp 0x7e103
jmp 0x7e058
movq %rax, %rbx
movq 0xa0(%rsp), %rdi
testq %rdi, %rdi
je 0x7e0d6
movq 0xb0(%rsp), %rsi
subq %rdi, %rsi
jmp 0x7e0d1
movq %rax, %rbx
movq (%rsp), %rdi
cmpq %r15, %rdi
je 0x7e10b
movq 0x10(%rsp), %rsi
jmp 0x7e103
movq %rax, %rbx
jmp 0x7e0f4
movq %rax, %rbx
jmp 0x7e07f
movq %rax, %rbx
movq 0x40(%rsp), %rdi
cmpq %r13, %rdi
je 0x7e07f
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x229c0
movq 0x80(%rsp), %rdi
leaq 0x90(%rsp), %rax
cmpq %rax, %rdi
je 0x7e0f4
movq 0x90(%rsp), %rsi
jmp 0x7e0ec
movq %rax, %rbx
jmp 0x7e0d6
movq %rax, %rbx
movq 0x60(%rsp), %rdi
leaq 0x70(%rsp), %rax
cmpq %rax, %rdi
je 0x7e0d6
movq 0x70(%rsp), %rsi
jmp 0x7e0ce
movq %rax, %rbx
movq 0x40(%rsp), %rdi
cmpq %r13, %rdi
je 0x7e0d6
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x229c0
movq %r12, %r14
jmp 0x7e0de
movq %rax, %rbx
movq (%rsp), %rdi
cmpq %r15, %rdi
je 0x7e0f4
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x229c0
movq 0x20(%rsp), %rdi
cmpq %r14, %rdi
je 0x7e10b
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x229c0
movq %rbx, %rdi
callq 0x23240
nop