// File: /workspace/github_cpp_makefile_star2_O2/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 %rbx
subq $0x118, %rsp            # imm = 0x118
movq %rdi, %rbx
cmpl $0x3, 0x1614(%rdi)
jb 0x6dea8
movq 0xf8104(%rip), %rdi     # 0x165f98
leaq 0x70a43(%rip), %rsi     # 0xde8de
callq 0x289f0
movq %rax, %rdi
callq 0x284a0
leaq 0x1520(%rbx), %r14
leaq 0x724f5(%rip), %rdx     # 0xe03ab
leaq 0xf8(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0x334ed
movq %r15, %rdi
callq 0x9ec28
movl %eax, %ebp
leaq 0xf8(%rsp), %rdi
callq 0x295a0
testl %ebp, %ebp
jne 0x6e040
leaq 0x67fa8(%rip), %rsi     # 0xd5e97
movq %rsp, %r15
movq %r15, %rdi
movq %r14, %rdx
callq 0x3338b
leaq 0x724a7(%rip), %rdx     # 0xe03ab
leaq 0x20(%rsp), %rdi
movq %r15, %rsi
callq 0x3336c
movq %rsp, %rdi
callq 0x295a0
leaq 0xb8(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x28dd0
leaq 0xb8(%rsp), %rdi
callq 0x9f543
movl %eax, %ebp
leaq 0xb8(%rsp), %rdi
callq 0x295a0
testl %ebp, %ebp
je 0x6e036
leaq 0x709a8(%rip), %rsi     # 0xde8fe
movq %rsp, %rdi
leaq 0x20(%rsp), %rdx
callq 0x3338b
leaq 0x71c38(%rip), %rdx     # 0xdfba2
leaq 0xd8(%rsp), %rdi
movq %rsp, %rsi
callq 0x3336c
leaq 0xd8(%rsp), %rsi
movq %rbx, %rdi
callq 0x6aed2
movq %rax, %rbx
leaq 0xd8(%rsp), %rdi
jmp 0x6dfbf
jmp 0x6e1ef
jmp 0x6dfd1
movq %rax, %rbx
leaq 0xb8(%rsp), %rdi
jmp 0x6e1f5
jmp 0x6dfd1
jmp 0x6dfc9
movq %rax, %rbx
leaq 0xf8(%rsp), %rdi
jmp 0x6dfd9
callq 0x295a0
jmp 0x6e1f2
movq %rax, %rbx
movq %rsp, %rdi
jmp 0x6dfd9
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x295a0
movq %rbx, %rdi
callq 0x292f0
jmp 0x6dfc9
jmp 0x6dfd1
jmp 0x6dfd1
movq %rax, %rbx
jmp 0x6dffe
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0x295a0
leaq 0x98(%rsp), %rdi
jmp 0x6e1f5
jmp 0x6e1ef
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
jmp 0x6dfbf
movq %rax, %rbx
leaq 0x78(%rsp), %rdi
jmp 0x6dfbf
movq %rax, %rbx
leaq 0x60(%rsp), %rdi
callq 0x5b268
jmp 0x6e1f2
leaq 0x20(%rsp), %rdi
callq 0x295a0
movq %rbx, %rdi
callq 0x76bce
movq %rbx, %rdi
callq 0x7ec70
movl 0x13e8(%rbx), %esi
movq %rsp, %r15
movq %r15, %rdi
callq 0x9f56b
leaq 0x20(%rsp), %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x5a115
movq %rsp, %rdi
callq 0x295a0
cmpb $0x1, 0x1646(%rbx)
jne 0x6e08c
movq 0x20(%rsp), %rsi
callq 0x791e0
movl 0x13e8(%rbx), %esi
decl %esi
leaq 0x98(%rsp), %rdi
callq 0x9f56b
leaq 0x40(%rsp), %rdi
leaq 0x98(%rsp), %rdx
movq %r14, %rsi
callq 0x5a115
leaq 0x70889(%rip), %rdx     # 0xde946
movq %rsp, %rdi
leaq 0x40(%rsp), %rsi
callq 0x3336c
leaq 0x40(%rsp), %rdi
callq 0x295a0
leaq 0x98(%rsp), %rdi
callq 0x295a0
movq 0xf7eb0(%rip), %rdi     # 0x165f98
leaq 0x6f3d3(%rip), %rsi     # 0xdd4c2
callq 0x289f0
movq %rax, %r15
movl 0x13e8(%rbx), %esi
decl %esi
leaq 0x40(%rsp), %rdi
callq 0x9f56b
leaq 0x40(%rsp), %rsi
movq %r15, %rdi
callq 0x28910
movq %rax, %rdi
callq 0x284a0
leaq 0x40(%rsp), %rdi
callq 0x295a0
leaq 0x78(%rsp), %rdi
movq %rsp, %rsi
callq 0x28dd0
leaq 0x78(%rsp), %rsi
movq %rbx, %rdi
callq 0x7942a
leaq 0x78(%rsp), %rdi
callq 0x295a0
cmpl $0x3, 0x1614(%rbx)
jb 0x6e170
movq 0xf7e3c(%rip), %rdi     # 0x165f98
leaq 0x707f0(%rip), %rsi     # 0xde953
callq 0x289f0
movq %rax, %rdi
callq 0x284a0
movq %rbx, %rdi
callq 0x72f2a
testb %al, %al
jne 0x6e1cf
xorps %xmm0, %xmm0
leaq 0x60(%rsp), %rsi
movaps %xmm0, (%rsi)
andq $0x0, 0x10(%rsi)
movq %rbx, %rdi
callq 0x7f610
leaq 0x60(%rsp), %rdi
callq 0x5b268
cmpl $0x3, 0x1614(%rbx)
jb 0x6e1c2
movq 0xf7dea(%rip), %rdi     # 0x165f98
leaq 0x707cc(%rip), %rsi     # 0xde981
callq 0x289f0
movq %rax, %rdi
callq 0x284a0
movq %rsp, %rdi
callq 0x295a0
jmp 0x6e036
movq %rsp, %rdi
callq 0x295a0
leaq 0x20(%rsp), %rdi
callq 0x295a0
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq %rsp, %rdi
callq 0x295a0
jmp 0x6dfd4
nop