// File: /workspace/github_cpp_makefile_star2_O3/DivyanshuSaxena[P]green-vrp/Main.cpp
// Function: main
int main() {
	cout << "Starting execution";
	fillGlobalVariables();
	while(customerPool.size()!=0){
		bool stoppingcondition=false;

		Vehicle v;//new object of type:vehicle
		//intialize the members of object "v" of type Vehicle

		vehicles.push_back(v);
		// vehicles.get(currentvehicle).addNode(depot);
		while(stoppingcondition!=true) {
			int mincustomer;
			double minCost=-1;
			double checkcost;

			for(int counter=0;counter<customerPool.size();counter++){
				if(vehicles.at(currentvehicle).feasible(customerPool.at(counter) )==true){
					checkcost=vehicles.at(currentvehicle).totalCost + checknewCustomerCost(vehicles.at(currentvehicle).currentNodeId, customerPool.at(counter)) ;
					//checknewCustomerCost should give travellingCost+waitingCost here.
					if(minCost>checkcost || minCost==-1){
						mincustomer= customerPool.at(counter);
						minCost=checkcost;
					}
				}
			}

			if(minCost!=-1){
				vehicles.at(currentvehicle).addCustomer(mincustomer);
				for(int p=0; p < customerPool.size(); p++){
					if(customerPool.at(p)==mincustomer) {
						customerPool.erase(customerPool.begin()+p);
						break;
						}
				}

			}
			else{
				//NO customer is feasible for adding
				stoppingcondition= vehicles.at(currentvehicle).addChargingStationOrDepot();
			}	
		}
	currentvehicle++;
	}
	// All customers are served until this line.

	//output in csv file
	ofstream outFile;
	outFile.open("solution.csv");
	outFile<<"trans_code,vehicle_type,dist_seq,distribute_lea_tm,distribute_arr_tm,distance,trans_cost,charge_cost,weight_cost,fixed_use_cost,total_cost,charge_cnt,\n";
	for ( int i=0;i<vehicles.size();i++)
	{
		outFile<<"DP"<<i+1<<",";
		outFile<<vehicles.at(i).type<<",";
		for(auto j = 0; j < vehicles.at(i).route.size();j++ )
		{
			outFile<<vehicles.at(i).route.at(j).id;
			if(j!=vehicles.at(i).route.size()-1)
				outFile<<";";
		}
		outFile<<",";
		outFile<<vehicles.at(i).route.at(0).arrival_time<<",";
		outFile<<vehicles.at(i).route.at(vehicles.at(i).route.size()-1).arrival_time<<",";
		outFile<<vehicles.at(i).distanceTravelled<<",";
		outFile<<vehicles.at(i).travellingCost<<",";
		outFile<<vehicles.at(i).chargingCost<<",";
		outFile<<vehicles.at(i).waitingCost<<",";
		outFile<<"200,";
		outFile<<vehicles.at(i).totalCost<<",";
		double countCharging=vehicles.at(i).chargingCost/chargingCostStation;
		outFile<<countCharging<<"\n";
	}

	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x218, %rsp            # imm = 0x218
movq 0x573c(%rip), %rdi      # 0x8fd0
leaq 0x2835(%rip), %rsi      # 0x60d0
movl $0x12, %edx
callq 0x2180
callq 0x4072
movq 0x5937(%rip), %rax      # 0x91e8
movabsq $-0x1111111111111111, %r14 # imm = 0xEEEEEEEEEEEEEEEF
cmpq 0x591e(%rip), %rax      # 0x91e0
je 0x3b46
leaq 0x18(%rsp), %rbx
leaq 0x593c(%rip), %r12      # 0x9210
movq %rbx, %rdi
callq 0x254c
movq %r12, %rdi
movq %rbx, %rsi
callq 0x565a
xorl %r15d, %r15d
movq 0x58ef(%rip), %rax      # 0x91e0
cmpq %rax, 0x58f0(%rip)      # 0x91e8
je 0x3aaf
xorl %r13d, %r13d
movsd 0x271f(%rip), %xmm0     # 0x6028
movslq 0x59b0(%rip), %rsi      # 0x92c0
movq 0x5901(%rip), %rdx      # 0x9218
movq 0x58f2(%rip), %rdi      # 0x9210
subq %rdi, %rdx
sarq $0x3, %rdx
imulq %r14, %rdx
cmpq %rsi, %rdx
jbe 0x3fd5
movsd %xmm0, 0x8(%rsp)
imulq $0x78, %rsi, %rcx
addq %rcx, %rdi
movl (%rax,%r13,4), %esi
callq 0x2604
testb %al, %al
je 0x3a04
movslq 0x5969(%rip), %rsi      # 0x92c0
movq 0x58ba(%rip), %rdx      # 0x9218
movq 0x58ab(%rip), %rax      # 0x9210
subq %rax, %rdx
sarq $0x3, %rdx
imulq %r14, %rdx
cmpq %rsi, %rdx
jbe 0x3fd5
movq 0x5868(%rip), %rdx      # 0x91e8
movq 0x5859(%rip), %rcx      # 0x91e0
subq %rcx, %rdx
sarq $0x2, %rdx
cmpq %r13, %rdx
jbe 0x3fd2
imulq $0x78, %rsi, %rdx
leaq (%rax,%rdx), %rsi
movsd 0x20(%rax,%rdx), %xmm0
movsd %xmm0, 0x10(%rsp)
movl 0x70(%rsi), %edi
movl (%rcx,%r13,4), %esi
callq 0x5421
movsd 0x10(%rsp), %xmm1
addsd %xmm0, %xmm1
movsd 0x8(%rsp), %xmm0
ucomisd 0x2659(%rip), %xmm0     # 0x6028
movq 0x5812(%rip), %rcx      # 0x91e8
movq 0x5803(%rip), %rax      # 0x91e0
jne 0x39e1
jnp 0x39e7
ucomisd %xmm1, %xmm0
jbe 0x3a18
movq %rcx, %rdx
subq %rax, %rdx
sarq $0x2, %rdx
cmpq %r13, %rdx
jbe 0x3fd2
movl (%rax,%r13,4), %ebp
movapd %xmm1, %xmm0
jmp 0x3a18
movq 0x57dd(%rip), %rcx      # 0x91e8
movq 0x57ce(%rip), %rax      # 0x91e0
movsd 0x8(%rsp), %xmm0
incq %r13
subq %rax, %rcx
sarq $0x2, %rcx
cmpq %r13, %rcx
ja 0x3909
ucomisd 0x25f5(%rip), %xmm0     # 0x6028
jne 0x3a37
jnp 0x3aaf
movslq 0x5882(%rip), %rsi      # 0x92c0
movq 0x57d3(%rip), %rdx      # 0x9218
movq 0x57c4(%rip), %rdi      # 0x9210
subq %rdi, %rdx
sarq $0x3, %rdx
imulq %r14, %rdx
cmpq %rsi, %rdx
jbe 0x3ff4
imulq $0x78, %rsi, %rax
addq %rax, %rdi
movl %ebp, %esi
callq 0x2a76
movq 0x5773(%rip), %rax      # 0x91e8
movq 0x5764(%rip), %rsi      # 0x91e0
movq %rax, %rdx
subq %rsi, %rdx
je 0x3ae7
movq %rdx, %rcx
sarq $0x2, %rcx
cmpq $0x1, %rcx
adcq $0x0, %rcx
addq $0x4, %rsi
addq $-0x4, %rdx
cmpl %ebp, -0x4(%rsi)
je 0x3af3
addq $0x4, %rsi
addq $-0x4, %rdx
decq %rcx
jne 0x3a9b
jmp 0x3ae7
movslq 0x580a(%rip), %rsi      # 0x92c0
movq 0x575b(%rip), %rdx      # 0x9218
movq 0x574c(%rip), %rdi      # 0x9210
subq %rdi, %rdx
sarq $0x3, %rdx
imulq %r14, %rdx
cmpq %rsi, %rdx
jbe 0x3ff4
imulq $0x78, %rsi, %rax
addq %rax, %rdi
callq 0x3228
movl %eax, %r15d
testb $0x1, %r15b
je 0x38ea
jmp 0x3b15
cmpq %rax, %rsi
je 0x3b08
leaq -0x4(%rsi), %rdi
callq 0x2210
movq 0x56e0(%rip), %rax      # 0x91e8
addq $-0x4, %rax
movq %rax, 0x56d5(%rip)      # 0x91e8
jmp 0x3ae7
incl 0x57a5(%rip)            # 0x92c0
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x3b32
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x2160
movq 0x56af(%rip), %rax      # 0x91e8
cmpq 0x56a0(%rip), %rax      # 0x91e0
jne 0x38d4
leaq 0x18(%rsp), %rbx
movq %rbx, %rdi
callq 0x2230
leaq 0x2589(%rip), %rsi      # 0x60e3
movq %rbx, %rdi
movl $0x10, %edx
callq 0x2040
leaq 0x2582(%rip), %rsi      # 0x60f0
leaq 0x18(%rsp), %rdi
movl $0x97, %edx
callq 0x2180
leaq 0x260c(%rip), %r15      # 0x6190
movabsq $-0x5555555555555555, %r12 # imm = 0xAAAAAAAAAAAAAAAB
xorl %ebx, %ebx
movq 0x5681(%rip), %rax      # 0x9218
subq 0x5672(%rip), %rax      # 0x9210
sarq $0x3, %rax
imulq %r14, %rax
cmpq %rbx, %rax
jbe 0x3f8c
movl $0x2, %edx
leaq 0x18(%rsp), %rdi
leaq 0x25c8(%rip), %rsi      # 0x6188
callq 0x2180
leaq 0x1(%rbx), %rsi
leaq 0x18(%rsp), %rdi
movq %rsi, 0x8(%rsp)
callq 0x2240
movl $0x1, %edx
movq %rax, %rdi
movq %r15, %rsi
callq 0x2180
movq 0x5629(%rip), %rdx      # 0x9218
movq 0x561a(%rip), %rax      # 0x9210
subq %rax, %rdx
sarq $0x3, %rdx
imulq %r14, %rdx
cmpq %rbx, %rdx
jbe 0x400b
imulq $0x78, %rbx, %rbp
movl (%rax,%rbp), %esi
leaq 0x18(%rsp), %rdi
callq 0x2240
movl $0x1, %edx
movq %rax, %rdi
movq %r15, %rsi
callq 0x2180
movq 0x55e6(%rip), %rdx      # 0x9218
movq 0x55d7(%rip), %rax      # 0x9210
subq %rax, %rdx
sarq $0x3, %rdx
imulq %r14, %rdx
cmpq %rbx, %rdx
jbe 0x3fe3
xorl %r13d, %r13d
xorl %r15d, %r15d
movq 0x8(%rax,%rbp), %rcx
movq 0x10(%rax,%rbp), %rax
subq %rcx, %rax
sarq $0x3, %rax
imulq %r12, %rax
cmpq %r15, %rax
jbe 0x3cff
movl (%rcx,%r13), %esi
leaq 0x18(%rsp), %rdi
callq 0x2240
movq 0x5592(%rip), %rdx      # 0x9218
movq 0x5583(%rip), %rax      # 0x9210
subq %rax, %rdx
sarq $0x3, %rdx
imulq %r14, %rdx
cmpq %rbx, %rdx
jbe 0x3fe3
movq 0x10(%rax,%rbp), %rcx
subq 0x8(%rax,%rbp), %rcx
sarq $0x3, %rcx
imulq %r12, %rcx
decq %rcx
cmpq %rcx, %r15
je 0x3cea
movl $0x1, %edx
leaq 0x18(%rsp), %rdi
leaq 0x24bf(%rip), %rsi      # 0x618b
callq 0x2180
movq 0x5540(%rip), %rdx      # 0x9218
movq 0x5531(%rip), %rax      # 0x9210
subq %rax, %rdx
sarq $0x3, %rdx
imulq %r14, %rdx
incq %r15
addq $0x18, %r13
cmpq %rbx, %rdx
ja 0x3c53
jmp 0x3fe3
movl $0x1, %edx
leaq 0x18(%rsp), %rdi
leaq 0x2480(%rip), %r15      # 0x6190
movq %r15, %rsi
callq 0x2180
movq 0x54f9(%rip), %rdx      # 0x9218
movq 0x54ea(%rip), %rax      # 0x9210
subq %rax, %rdx
sarq $0x3, %rdx
imulq %r14, %rdx
cmpq %rbx, %rdx
jbe 0x400b
movq 0x8(%rax,%rbp), %rcx
cmpq %rcx, 0x10(%rax,%rbp)
je 0x4007
movsd 0x8(%rcx), %xmm0
leaq 0x18(%rsp), %rdi
callq 0x2200
movl $0x1, %edx
movq %rax, %rdi
movq %r15, %rsi
callq 0x2180
movq 0x54a8(%rip), %rdx      # 0x9218
movq 0x5499(%rip), %rcx      # 0x9210
subq %rcx, %rdx
sarq $0x3, %rdx
imulq %r14, %rdx
cmpq %rbx, %rdx
jbe 0x400b
movq 0x8(%rcx,%rbp), %rax
movq 0x10(%rcx,%rbp), %rsi
movq %rsi, %rdx
subq %rax, %rdx
sarq $0x3, %rdx
imulq %r12, %rdx
leaq -0x1(%rdx), %rcx
cmpq %rax, %rsi
je 0x4002
leaq (%rcx,%rcx,2), %rcx
movsd 0x8(%rax,%rcx,8), %xmm0
leaq 0x18(%rsp), %rdi
callq 0x2200
movl $0x1, %edx
movq %rax, %rdi
movq %r15, %rsi
callq 0x2180
movq 0x543d(%rip), %rdx      # 0x9218
movq 0x542e(%rip), %rax      # 0x9210
subq %rax, %rdx
sarq $0x3, %rdx
imulq %r14, %rdx
cmpq %rbx, %rdx
jbe 0x400b
movsd 0x50(%rax,%rbp), %xmm0
leaq 0x18(%rsp), %rdi
callq 0x2200
movl $0x1, %edx
movq %rax, %rdi
movq %r15, %rsi
callq 0x2180
movq 0x53fb(%rip), %rdx      # 0x9218
movq 0x53ec(%rip), %rax      # 0x9210
subq %rax, %rdx
sarq $0x3, %rdx
imulq %r14, %rdx
cmpq %rbx, %rdx
jbe 0x400b
movsd 0x30(%rax,%rbp), %xmm0
leaq 0x18(%rsp), %rdi
callq 0x2200
movl $0x1, %edx
movq %rax, %rdi
movq %r15, %rsi
callq 0x2180
movq 0x53b9(%rip), %rdx      # 0x9218
movq 0x53aa(%rip), %rax      # 0x9210
subq %rax, %rdx
sarq $0x3, %rdx
imulq %r14, %rdx
cmpq %rbx, %rdx
jbe 0x400b
movsd 0x28(%rax,%rbp), %xmm0
leaq 0x18(%rsp), %rdi
callq 0x2200
movl $0x1, %edx
movq %rax, %rdi
movq %r15, %rsi
callq 0x2180
movq 0x5377(%rip), %rdx      # 0x9218
movq 0x5368(%rip), %rax      # 0x9210
subq %rax, %rdx
sarq $0x3, %rdx
imulq %r14, %rdx
cmpq %rbx, %rdx
jbe 0x400b
movsd 0x38(%rax,%rbp), %xmm0
leaq 0x18(%rsp), %rdi
callq 0x2200
movl $0x1, %edx
movq %rax, %rdi
movq %r15, %rsi
callq 0x2180
movl $0x4, %edx
leaq 0x18(%rsp), %rdi
leaq 0x22a0(%rip), %rsi      # 0x618d
callq 0x2180
movq 0x531f(%rip), %rdx      # 0x9218
movq 0x5310(%rip), %rax      # 0x9210
subq %rax, %rdx
sarq $0x3, %rdx
imulq %r14, %rdx
cmpq %rbx, %rdx
jbe 0x400b
movsd 0x20(%rax,%rbp), %xmm0
leaq 0x18(%rsp), %rdi
callq 0x2200
movl $0x1, %edx
movq %rax, %rdi
movq %r15, %rsi
callq 0x2180
movq 0x52dd(%rip), %rdx      # 0x9218
movq 0x52ce(%rip), %rax      # 0x9210
subq %rax, %rdx
sarq $0x3, %rdx
imulq %r14, %rdx
cmpq %rbx, %rdx
jbe 0x401c
movsd 0x28(%rax,%rbp), %xmm0
divsd 0x534c(%rip), %xmm0     # 0x92b0
leaq 0x18(%rsp), %rdi
callq 0x2200
movl $0x1, %edx
movq %rax, %rdi
leaq 0x2209(%rip), %rsi      # 0x6186
callq 0x2180
movq 0x8(%rsp), %rbx
jmp 0x3b90
movq 0x5035(%rip), %rax      # 0x8fc8
movq (%rax), %rcx
movq 0x18(%rax), %rax
leaq 0x20(%rsp), %rdi
movq %rcx, -0x8(%rdi)
movq -0x18(%rcx), %rcx
movq %rax, 0x18(%rsp,%rcx)
callq 0x2110
leaq 0x110(%rsp), %rdi
callq 0x2070
xorl %eax, %eax
addq $0x218, %rsp            # imm = 0x218
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r13, %rsi
leaq 0x2068(%rip), %rdi      # 0x6044
xorl %eax, %eax
callq 0x21e0
leaq 0x205a(%rip), %rdi      # 0x6044
movq %rbx, %rsi
xorl %eax, %eax
callq 0x21e0
leaq 0x2049(%rip), %rdi      # 0x6044
xorl %eax, %eax
callq 0x21e0
movq %rcx, %rbx
jmp 0x400b
xorl %ebx, %ebx
xorl %edx, %edx
leaq 0x2032(%rip), %rdi      # 0x6044
movq %rbx, %rsi
xorl %eax, %eax
callq 0x21e0
leaq 0x2021(%rip), %rdi      # 0x6044
movq %rbx, %rsi
xorl %eax, %eax
callq 0x21e0
jmp 0x403f
jmp 0x4050
jmp 0x403f
jmp 0x403f
jmp 0x403f
jmp 0x4050
jmp 0x4050
jmp 0x403f
jmp 0x403f
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x21d0
jmp 0x406a
jmp 0x4050
movq %rax, %rbx
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x406a
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x2160
movq %rbx, %rdi
callq 0x2250