// File: /workspace/github_cpp_makefile_star2_O1/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 0x56a8(%rip), %rdi      # 0x8fd0
leaq 0x2781(%rip), %rsi      # 0x60b0
movl $0x12, %edx
callq 0x2180
callq 0x40f3
movq 0x58a3(%rip), %rax      # 0x91e8
movabsq $-0x1111111111111111, %r14 # imm = 0xEEEEEEEEEEEEEEEF
cmpq 0x588a(%rip), %rax      # 0x91e0
je 0x3bbe
leaq 0x18(%rsp), %rbx
leaq 0x58a8(%rip), %r12      # 0x9210
movq %rbx, %rdi
callq 0x254c
movq %r12, %rdi
movq %rbx, %rsi
callq 0x56e4
xorl %r15d, %r15d
movq 0x585b(%rip), %rax      # 0x91e0
cmpq %rax, 0x585c(%rip)      # 0x91e8
je 0x3ad5
xorl %r13d, %r13d
movsd 0x2673(%rip), %xmm0     # 0x6010
movsd %xmm0, 0x8(%rsp)
movslq 0x5916(%rip), %rsi      # 0x92c0
movq 0x5867(%rip), %rdx      # 0x9218
movq 0x5858(%rip), %rdi      # 0x9210
subq %rdi, %rdx
sarq $0x3, %rdx
imulq %r14, %rdx
cmpq %rsi, %rdx
jbe 0x4050
imulq $0x78, %rsi, %rcx
addq %rcx, %rdi
movl (%rax,%r13,4), %esi
callq 0x2630
testb %al, %al
je 0x3a9b
movslq 0x58d5(%rip), %rsi      # 0x92c0
movq 0x5826(%rip), %rdx      # 0x9218
movq 0x5817(%rip), %rax      # 0x9210
subq %rax, %rdx
sarq $0x3, %rdx
imulq %r14, %rdx
cmpq %rsi, %rdx
jbe 0x4050
movq 0x57d4(%rip), %rdx      # 0x91e8
movq 0x57c5(%rip), %rcx      # 0x91e0
subq %rcx, %rdx
sarq $0x2, %rdx
cmpq %r13, %rdx
jbe 0x404d
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 0x54b8
movsd 0x10(%rsp), %xmm1
addsd %xmm0, %xmm1
movsd 0x8(%rsp), %xmm0
ucomisd 0x25ad(%rip), %xmm0     # 0x6010
jne 0x3a67
jnp 0x3a73
movsd 0x8(%rsp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x3a9b
movq 0x576e(%rip), %rdx      # 0x91e8
movq 0x575f(%rip), %rax      # 0x91e0
subq %rax, %rdx
sarq $0x2, %rdx
cmpq %r13, %rdx
jbe 0x404d
movl (%rax,%r13,4), %ebp
movsd %xmm1, 0x8(%rsp)
incq %r13
movq 0x5743(%rip), %rcx      # 0x91e8
movq 0x5734(%rip), %rax      # 0x91e0
subq %rax, %rcx
sarq $0x2, %rcx
cmpq %r13, %rcx
ja 0x39a3
movsd 0x8(%rsp), %xmm0
cmpneqsd 0x2545(%rip), %xmm0     # 0x6010
movq %xmm0, %rax
andl $0x1, %eax
jmp 0x3ad7
xorl %eax, %eax
movslq 0x57e2(%rip), %rsi      # 0x92c0
movq 0x5733(%rip), %rdx      # 0x9218
movq 0x5724(%rip), %rdi      # 0x9210
subq %rdi, %rdx
sarq $0x3, %rdx
imulq %r14, %rdx
testb %al, %al
je 0x3b53
cmpq %rsi, %rdx
jbe 0x406f
imulq $0x78, %rsi, %rax
addq %rax, %rdi
movl %ebp, %esi
callq 0x2aa2
movq 0x56cf(%rip), %rax      # 0x91e8
movq 0x56c0(%rip), %rsi      # 0x91e0
movq %rax, %rdx
subq %rsi, %rdx
je 0x3b83
movq %rdx, %rcx
sarq $0x2, %rcx
cmpq $0x1, %rcx
adcq $0x0, %rcx
addq $0x4, %rsi
addq $-0x4, %rdx
cmpl %ebp, -0x4(%rsi)
je 0x3b6d
addq $0x4, %rsi
addq $-0x4, %rdx
decq %rcx
jne 0x3b3f
jmp 0x3b83
cmpq %rsi, %rdx
jbe 0x406f
imulq $0x78, %rsi, %rax
addq %rax, %rdi
callq 0x32b0
movl %eax, %r15d
jmp 0x3b83
cmpq %rax, %rsi
je 0x3b7b
leaq -0x4(%rsi), %rdi
callq 0x2210
addq $-0x4, 0x5665(%rip)     # 0x91e8
testb $0x1, %r15b
je 0x397e
incl 0x572d(%rip)            # 0x92c0
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x3baa
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x2160
movq 0x5637(%rip), %rax      # 0x91e8
cmpq 0x5628(%rip), %rax      # 0x91e0
jne 0x3968
leaq 0x18(%rsp), %rbx
movq %rbx, %rdi
callq 0x2230
leaq 0x24f1(%rip), %rsi      # 0x60c3
movq %rbx, %rdi
movl $0x10, %edx
callq 0x2040
leaq 0x24ea(%rip), %rsi      # 0x60d0
leaq 0x18(%rsp), %rdi
movl $0x97, %edx
callq 0x2180
xorl %ebx, %ebx
leaq 0x2572(%rip), %r15      # 0x6170
movabsq $-0x5555555555555555, %r12 # imm = 0xAAAAAAAAAAAAAAAB
movq 0x5609(%rip), %rax      # 0x9218
subq 0x55fa(%rip), %rax      # 0x9210
sarq $0x3, %rax
imulq %r14, %rax
cmpq %rbx, %rax
jbe 0x4007
movl $0x2, %edx
leaq 0x18(%rsp), %rdi
leaq 0x2530(%rip), %rsi      # 0x6168
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 0x55b1(%rip), %rdx      # 0x9218
movq 0x55a2(%rip), %rax      # 0x9210
subq %rax, %rdx
sarq $0x3, %rdx
imulq %r14, %rdx
cmpq %rbx, %rdx
jbe 0x408c
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 0x556e(%rip), %rdx      # 0x9218
movq 0x555f(%rip), %rax      # 0x9210
subq %rax, %rdx
sarq $0x3, %rdx
imulq %r14, %rdx
cmpq %rbx, %rdx
jbe 0x405e
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 0x3d77
movl (%rcx,%r13), %esi
leaq 0x18(%rsp), %rdi
callq 0x2240
movq 0x551a(%rip), %rdx      # 0x9218
movq 0x550b(%rip), %rax      # 0x9210
subq %rax, %rdx
sarq $0x3, %rdx
imulq %r14, %rdx
cmpq %rbx, %rdx
jbe 0x405e
movq 0x10(%rax,%rbp), %rcx
subq 0x8(%rax,%rbp), %rcx
sarq $0x3, %rcx
imulq %r12, %rcx
decq %rcx
cmpq %rcx, %r15
je 0x3d49
movl $0x1, %edx
leaq 0x18(%rsp), %rdi
leaq 0x2427(%rip), %rsi      # 0x616b
callq 0x2180
incq %r15
movq 0x54c5(%rip), %rdx      # 0x9218
movq 0x54b6(%rip), %rax      # 0x9210
subq %rax, %rdx
sarq $0x3, %rdx
imulq %r14, %rdx
addq $0x18, %r13
cmpq %rbx, %rdx
ja 0x3ccb
jmp 0x405e
movl $0x1, %edx
leaq 0x18(%rsp), %rdi
leaq 0x23e8(%rip), %r15      # 0x6170
movq %r15, %rsi
callq 0x2180
movq 0x5481(%rip), %rdx      # 0x9218
movq 0x5472(%rip), %rax      # 0x9210
subq %rax, %rdx
sarq $0x3, %rdx
imulq %r14, %rdx
cmpq %rbx, %rdx
jbe 0x408c
movq 0x8(%rax,%rbp), %rcx
movq 0x10(%rax,%rbp), %rdx
subq %rcx, %rdx
je 0x4082
movsd 0x8(%rcx), %xmm0
leaq 0x18(%rsp), %rdi
callq 0x2200
movl $0x1, %edx
movq %rax, %rdi
movq %r15, %rsi
callq 0x2180
movq 0x542d(%rip), %rdx      # 0x9218
movq 0x541e(%rip), %rcx      # 0x9210
subq %rcx, %rdx
sarq $0x3, %rdx
imulq %r14, %rdx
cmpq %rbx, %rdx
jbe 0x408c
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 0x407d
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 0x53c2(%rip), %rdx      # 0x9218
movq 0x53b3(%rip), %rax      # 0x9210
subq %rax, %rdx
sarq $0x3, %rdx
imulq %r14, %rdx
cmpq %rbx, %rdx
jbe 0x408c
movsd 0x50(%rax,%rbp), %xmm0
leaq 0x18(%rsp), %rdi
callq 0x2200
movl $0x1, %edx
movq %rax, %rdi
movq %r15, %rsi
callq 0x2180
movq 0x5380(%rip), %rdx      # 0x9218
movq 0x5371(%rip), %rax      # 0x9210
subq %rax, %rdx
sarq $0x3, %rdx
imulq %r14, %rdx
cmpq %rbx, %rdx
jbe 0x408c
movsd 0x30(%rax,%rbp), %xmm0
leaq 0x18(%rsp), %rdi
callq 0x2200
movl $0x1, %edx
movq %rax, %rdi
movq %r15, %rsi
callq 0x2180
movq 0x533e(%rip), %rdx      # 0x9218
movq 0x532f(%rip), %rax      # 0x9210
subq %rax, %rdx
sarq $0x3, %rdx
imulq %r14, %rdx
cmpq %rbx, %rdx
jbe 0x408c
movsd 0x28(%rax,%rbp), %xmm0
leaq 0x18(%rsp), %rdi
callq 0x2200
movl $0x1, %edx
movq %rax, %rdi
movq %r15, %rsi
callq 0x2180
movq 0x52fc(%rip), %rdx      # 0x9218
movq 0x52ed(%rip), %rax      # 0x9210
subq %rax, %rdx
sarq $0x3, %rdx
imulq %r14, %rdx
cmpq %rbx, %rdx
jbe 0x408c
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 0x2205(%rip), %rsi      # 0x616d
callq 0x2180
movq 0x52a4(%rip), %rdx      # 0x9218
movq 0x5295(%rip), %rax      # 0x9210
subq %rax, %rdx
sarq $0x3, %rdx
imulq %r14, %rdx
cmpq %rbx, %rdx
jbe 0x408c
movsd 0x20(%rax,%rbp), %xmm0
leaq 0x18(%rsp), %rdi
callq 0x2200
movl $0x1, %edx
movq %rax, %rdi
movq %r15, %rsi
callq 0x2180
movq 0x5262(%rip), %rdx      # 0x9218
movq 0x5253(%rip), %rax      # 0x9210
subq %rax, %rdx
sarq $0x3, %rdx
imulq %r14, %rdx
cmpq %rbx, %rdx
jbe 0x409d
movsd 0x28(%rax,%rbp), %xmm0
divsd 0x52d1(%rip), %xmm0     # 0x92b0
leaq 0x18(%rsp), %rdi
callq 0x2200
movl $0x1, %edx
movq %rax, %rdi
leaq 0x216e(%rip), %rsi      # 0x6166
callq 0x2180
movq 0x8(%rsp), %rbx
jmp 0x3c08
movq 0x4fba(%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 0x1fd5(%rip), %rdi      # 0x602c
xorl %eax, %eax
callq 0x21e0
leaq 0x1fc7(%rip), %rdi      # 0x602c
movq %rbx, %rsi
xorl %eax, %eax
callq 0x21e0
leaq 0x1fb6(%rip), %rdi      # 0x602c
xorl %eax, %eax
callq 0x21e0
movq %rcx, %rbx
jmp 0x408c
sarq $0x3, %rdx
imulq %r12, %rdx
xorl %ebx, %ebx
leaq 0x1f99(%rip), %rdi      # 0x602c
movq %rbx, %rsi
xorl %eax, %eax
callq 0x21e0
leaq 0x1f88(%rip), %rdi      # 0x602c
movq %rbx, %rsi
xorl %eax, %eax
callq 0x21e0
jmp 0x40c0
jmp 0x40d1
jmp 0x40c0
jmp 0x40c0
jmp 0x40c0
jmp 0x40d1
jmp 0x40d1
jmp 0x40c0
jmp 0x40c0
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x21d0
jmp 0x40eb
jmp 0x40d1
movq %rax, %rbx
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x40eb
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x2160
movq %rbx, %rdi
callq 0x2250