// File: 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
movq %rsp, %rbp
subq $0x470, %rsp            # imm = 0x470
movl $0x0, -0x4(%rbp)
movq 0xbe37(%rip), %rdi      # 0x10fd0
leaq 0x5f08(%rip), %rsi      # 0xb0a8
callq 0x2180
callq 0x5b80
leaq 0xc07f(%rip), %rdi      # 0x11230
callq 0x3e20
cmpq $0x0, %rax
je 0x5596
movb $0x0, -0x5(%rbp)
leaq -0x80(%rbp), %rdi
movq %rdi, -0x2e0(%rbp)
callq 0x25f0
movq -0x2e0(%rbp), %rsi
leaq 0xc07e(%rip), %rdi      # 0x11260
callq 0x6d80
jmp 0x51e9
jmp 0x51eb
movb -0x5(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x1, %eax
je 0x5579
movsd 0x5e14(%rip), %xmm0     # 0xb018
movsd %xmm0, -0x98(%rbp)
movl $0x0, -0xa4(%rbp)
movslq -0xa4(%rbp), %rax
movq %rax, -0x2e8(%rbp)
leaq 0xc005(%rip), %rdi      # 0x11230
callq 0x3e20
movq %rax, %rcx
movq -0x2e8(%rbp), %rax
cmpq %rcx, %rax
jae 0x53fd
movslq 0xc0c6(%rip), %rsi      # 0x11310
leaq 0xc00f(%rip), %rdi      # 0x11260
callq 0x6df0
movq %rax, -0x2f0(%rbp)
jmp 0x525f
movslq -0xa4(%rbp), %rsi
leaq 0xbfc3(%rip), %rdi      # 0x11230
callq 0x3e40
movq %rax, -0x2f8(%rbp)
jmp 0x527b
movq -0x2f0(%rbp), %rdi
movq -0x2f8(%rbp), %rax
movl (%rax), %esi
callq 0x26d0
movb %al, -0x2f9(%rbp)
jmp 0x5298
movb -0x2f9(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x1, %eax
jne 0x53e7
movslq 0xc05d(%rip), %rsi      # 0x11310
leaq 0xbfa6(%rip), %rdi      # 0x11260
callq 0x6df0
movq %rax, -0x308(%rbp)
jmp 0x52c8
movq -0x308(%rbp), %rax
movsd 0x20(%rax), %xmm0
movsd %xmm0, -0x318(%rbp)
movslq 0xc02d(%rip), %rsi      # 0x11310
leaq 0xbf76(%rip), %rdi      # 0x11260
callq 0x6df0
movq %rax, -0x310(%rbp)
jmp 0x52f8
movq -0x310(%rbp), %rax
movl 0x70(%rax), %eax
movl %eax, -0x324(%rbp)
movslq -0xa4(%rbp), %rsi
leaq 0xbf1a(%rip), %rdi      # 0x11230
callq 0x3e40
movq %rax, -0x320(%rbp)
jmp 0x5324
movl -0x324(%rbp), %edi
movq -0x320(%rbp), %rax
movl (%rax), %esi
callq 0x69e0
movsd %xmm0, -0x330(%rbp)
jmp 0x5342
movsd -0x330(%rbp), %xmm1
movsd -0x318(%rbp), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0xa0(%rbp)
movsd -0x98(%rbp), %xmm0
ucomisd -0xa0(%rbp), %xmm0
ja 0x5388
movsd -0x98(%rbp), %xmm0
movsd 0x5c98(%rip), %xmm1     # 0xb018
ucomisd %xmm1, %xmm0
jne 0x53e5
jp 0x53e5
movslq -0xa4(%rbp), %rsi
leaq 0xbe9a(%rip), %rdi      # 0x11230
callq 0x3e40
movq %rax, -0x338(%rbp)
jmp 0x53a4
movq -0x338(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x90(%rbp)
movsd -0xa0(%rbp), %xmm0
movsd %xmm0, -0x98(%rbp)
jmp 0x53e5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x6f50
jmp 0x5b74
jmp 0x53e7
jmp 0x53e9
movl -0xa4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xa4(%rbp)
jmp 0x5216
movsd -0x98(%rbp), %xmm0
movsd 0x5c0b(%rip), %xmm1     # 0xb018
ucomisd %xmm1, %xmm0
jne 0x541a
jp 0x541a
jmp 0x5539
movslq 0xbeef(%rip), %rsi      # 0x11310
leaq 0xbe38(%rip), %rdi      # 0x11260
callq 0x6df0
movq %rax, -0x340(%rbp)
jmp 0x5436
movq -0x340(%rbp), %rdi
movl -0x90(%rbp), %esi
callq 0x2cc0
jmp 0x544a
movl $0x0, -0xa8(%rbp)
movslq -0xa8(%rbp), %rax
movq %rax, -0x348(%rbp)
leaq 0xbdc7(%rip), %rdi      # 0x11230
callq 0x3e20
movq %rax, %rcx
movq -0x348(%rbp), %rax
cmpq %rcx, %rax
jae 0x5537
movslq -0xa8(%rbp), %rsi
leaq 0xbda1(%rip), %rdi      # 0x11230
callq 0x3e40
movq %rax, -0x350(%rbp)
jmp 0x549d
movq -0x350(%rbp), %rax
movl (%rax), %eax
cmpl -0x90(%rbp), %eax
jne 0x5521
leaq 0xbd7b(%rip), %rdi      # 0x11230
movq %rdi, -0x360(%rbp)
callq 0x6ea0
movq %rax, -0xc0(%rbp)
movslq -0xa8(%rbp), %rsi
leaq -0xc0(%rbp), %rdi
callq 0x6ed0
movq %rax, -0xb8(%rbp)
leaq -0xb0(%rbp), %rdi
leaq -0xb8(%rbp), %rsi
callq 0x6f10
movq -0x360(%rbp), %rdi
movq -0xb0(%rbp), %rsi
callq 0x6e30
movq %rax, -0x358(%rbp)
jmp 0x5511
movq -0x358(%rbp), %rax
movq %rax, -0xc8(%rbp)
jmp 0x5537
jmp 0x5523
movl -0xa8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xa8(%rbp)
jmp 0x5454
jmp 0x5574
movslq 0xbdd0(%rip), %rsi      # 0x11310
leaq 0xbd19(%rip), %rdi      # 0x11260
callq 0x6df0
movq %rax, -0x368(%rbp)
jmp 0x5555
movq -0x368(%rbp), %rdi
callq 0x3570
movb %al, -0x369(%rbp)
jmp 0x5569
movb -0x369(%rbp), %al
andb $0x1, %al
movb %al, -0x5(%rbp)
jmp 0x51eb
movl 0xbd91(%rip), %eax      # 0x11310
addl $0x1, %eax
movl %eax, 0xbd88(%rip)      # 0x11310
leaq -0x80(%rbp), %rdi
callq 0x6f50
jmp 0x51aa
leaq -0x2c8(%rbp), %rdi
movq %rdi, -0x378(%rbp)
callq 0x22a0
movq -0x378(%rbp), %rdi
leaq 0x5b04(%rip), %rsi      # 0xb0bb
movl $0x10, %edx
callq 0x2040
jmp 0x55c3
leaq 0x5afe(%rip), %rsi      # 0xb0c8
leaq -0x2c8(%rbp), %rdi
callq 0x2180
jmp 0x55d8
movl $0x0, -0x2cc(%rbp)
movslq -0x2cc(%rbp), %rax
movq %rax, -0x380(%rbp)
leaq 0xbc69(%rip), %rdi      # 0x11260
callq 0x6f70
movq %rax, %rcx
movq -0x380(%rbp), %rax
cmpq %rcx, %rax
jae 0x5b55
leaq 0x5b4a(%rip), %rsi      # 0xb160
leaq -0x2c8(%rbp), %rdi
callq 0x2180
movq %rax, -0x388(%rbp)
jmp 0x562b
movq -0x388(%rbp), %rdi
movl -0x2cc(%rbp), %esi
incl %esi
callq 0x22b0
movq %rax, -0x390(%rbp)
jmp 0x5648
movq -0x390(%rbp), %rdi
leaq 0x5b12(%rip), %rsi      # 0xb168
callq 0x2180
jmp 0x565d
movslq -0x2cc(%rbp), %rsi
leaq 0xbbf5(%rip), %rdi      # 0x11260
callq 0x6df0
movq %rax, -0x398(%rbp)
jmp 0x5679
movq -0x398(%rbp), %rax
movl (%rax), %esi
leaq -0x2c8(%rbp), %rdi
callq 0x22b0
movq %rax, -0x3a0(%rbp)
jmp 0x5697
movq -0x3a0(%rbp), %rdi
leaq 0x5ac3(%rip), %rsi      # 0xb168
callq 0x2180
jmp 0x56ac
movl $0x0, -0x2d0(%rbp)
movslq -0x2d0(%rbp), %rax
movq %rax, -0x3b0(%rbp)
movslq -0x2cc(%rbp), %rsi
leaq 0xbb8e(%rip), %rdi      # 0x11260
callq 0x6df0
movq %rax, -0x3a8(%rbp)
jmp 0x56e0
movq -0x3a8(%rbp), %rdi
addq $0x8, %rdi
callq 0x3aa0
movq %rax, %rcx
movq -0x3b0(%rbp), %rax
cmpq %rcx, %rax
jae 0x57f3
movslq -0x2cc(%rbp), %rsi
leaq 0xbb4f(%rip), %rdi      # 0x11260
callq 0x6df0
movq %rax, -0x3b8(%rbp)
jmp 0x571f
movq -0x3b8(%rbp), %rdi
addq $0x8, %rdi
movslq -0x2d0(%rbp), %rsi
callq 0x3a60
movq %rax, -0x3c0(%rbp)
jmp 0x573f
movq -0x3c0(%rbp), %rax
movl (%rax), %esi
leaq -0x2c8(%rbp), %rdi
callq 0x22b0
jmp 0x5756
movslq -0x2d0(%rbp), %rax
movq %rax, -0x3d0(%rbp)
movslq -0x2cc(%rbp), %rsi
leaq 0xbaee(%rip), %rdi      # 0x11260
callq 0x6df0
movq %rax, -0x3c8(%rbp)
jmp 0x5780
movq -0x3c8(%rbp), %rdi
addq $0x8, %rdi
callq 0x3aa0
movq %rax, %rcx
movq -0x3d0(%rbp), %rax
subq $0x1, %rcx
cmpq %rcx, %rax
je 0x57dd
leaq 0x59b9(%rip), %rsi      # 0xb163
leaq -0x2c8(%rbp), %rdi
callq 0x2180
jmp 0x57b8
jmp 0x57dd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
leaq -0x2c8(%rbp), %rdi
callq 0x2250
jmp 0x5b74
jmp 0x57df
movl -0x2d0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2d0(%rbp)
jmp 0x56b6
leaq 0x596e(%rip), %rsi      # 0xb168
leaq -0x2c8(%rbp), %rdi
callq 0x2180
jmp 0x5808
movslq -0x2cc(%rbp), %rsi
leaq 0xba4a(%rip), %rdi      # 0x11260
callq 0x6df0
movq %rax, -0x3d8(%rbp)
jmp 0x5824
movq -0x3d8(%rbp), %rdi
addq $0x8, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x3a60
movq %rax, -0x3e0(%rbp)
jmp 0x5841
movq -0x3e0(%rbp), %rax
movsd 0x8(%rax), %xmm0
leaq -0x2c8(%rbp), %rdi
callq 0x2310
movq %rax, -0x3e8(%rbp)
jmp 0x5862
movq -0x3e8(%rbp), %rdi
leaq 0x58f8(%rip), %rsi      # 0xb168
callq 0x2180
jmp 0x5877
movslq -0x2cc(%rbp), %rsi
leaq 0xb9db(%rip), %rdi      # 0x11260
callq 0x6df0
movq %rax, -0x3f0(%rbp)
jmp 0x5893
movq -0x3f0(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x400(%rbp)
movslq -0x2cc(%rbp), %rsi
leaq 0xb9ad(%rip), %rdi      # 0x11260
callq 0x6df0
movq %rax, -0x3f8(%rbp)
jmp 0x58c1
movq -0x3f8(%rbp), %rdi
addq $0x8, %rdi
callq 0x3aa0
movq -0x400(%rbp), %rdi
movq %rax, %rsi
decq %rsi
callq 0x3a60
movq %rax, -0x408(%rbp)
jmp 0x58ec
movq -0x408(%rbp), %rax
movsd 0x8(%rax), %xmm0
leaq -0x2c8(%rbp), %rdi
callq 0x2310
movq %rax, -0x410(%rbp)
jmp 0x590d
movq -0x410(%rbp), %rdi
leaq 0x584d(%rip), %rsi      # 0xb168
callq 0x2180
jmp 0x5922
movslq -0x2cc(%rbp), %rsi
leaq 0xb930(%rip), %rdi      # 0x11260
callq 0x6df0
movq %rax, -0x418(%rbp)
jmp 0x593e
movq -0x418(%rbp), %rax
movsd 0x50(%rax), %xmm0
leaq -0x2c8(%rbp), %rdi
callq 0x2310
movq %rax, -0x420(%rbp)
jmp 0x595f
movq -0x420(%rbp), %rdi
leaq 0x57fb(%rip), %rsi      # 0xb168
callq 0x2180
jmp 0x5974
movslq -0x2cc(%rbp), %rsi
leaq 0xb8de(%rip), %rdi      # 0x11260
callq 0x6df0
movq %rax, -0x428(%rbp)
jmp 0x5990
movq -0x428(%rbp), %rax
movsd 0x30(%rax), %xmm0
leaq -0x2c8(%rbp), %rdi
callq 0x2310
movq %rax, -0x430(%rbp)
jmp 0x59b1
movq -0x430(%rbp), %rdi
leaq 0x57a9(%rip), %rsi      # 0xb168
callq 0x2180
jmp 0x59c6
movslq -0x2cc(%rbp), %rsi
leaq 0xb88c(%rip), %rdi      # 0x11260
callq 0x6df0
movq %rax, -0x438(%rbp)
jmp 0x59e2
movq -0x438(%rbp), %rax
movsd 0x28(%rax), %xmm0
leaq -0x2c8(%rbp), %rdi
callq 0x2310
movq %rax, -0x440(%rbp)
jmp 0x5a03
movq -0x440(%rbp), %rdi
leaq 0x5757(%rip), %rsi      # 0xb168
callq 0x2180
jmp 0x5a18
movslq -0x2cc(%rbp), %rsi
leaq 0xb83a(%rip), %rdi      # 0x11260
callq 0x6df0
movq %rax, -0x448(%rbp)
jmp 0x5a34
movq -0x448(%rbp), %rax
movsd 0x38(%rax), %xmm0
leaq -0x2c8(%rbp), %rdi
callq 0x2310
movq %rax, -0x450(%rbp)
jmp 0x5a55
movq -0x450(%rbp), %rdi
leaq 0x5705(%rip), %rsi      # 0xb168
callq 0x2180
jmp 0x5a6a
leaq 0x56f4(%rip), %rsi      # 0xb165
leaq -0x2c8(%rbp), %rdi
callq 0x2180
jmp 0x5a7f
movslq -0x2cc(%rbp), %rsi
leaq 0xb7d3(%rip), %rdi      # 0x11260
callq 0x6df0
movq %rax, -0x458(%rbp)
jmp 0x5a9b
movq -0x458(%rbp), %rax
movsd 0x20(%rax), %xmm0
leaq -0x2c8(%rbp), %rdi
callq 0x2310
movq %rax, -0x460(%rbp)
jmp 0x5abc
movq -0x460(%rbp), %rdi
leaq 0x569e(%rip), %rsi      # 0xb168
callq 0x2180
jmp 0x5ad1
movslq -0x2cc(%rbp), %rsi
leaq 0xb781(%rip), %rdi      # 0x11260
callq 0x6df0
movq %rax, -0x468(%rbp)
jmp 0x5aed
movq -0x468(%rbp), %rax
movsd 0x28(%rax), %xmm0
movsd 0xb7ff(%rip), %xmm1     # 0x11300
divsd %xmm1, %xmm0
movsd %xmm0, -0x2d8(%rbp)
movsd -0x2d8(%rbp), %xmm0
leaq -0x2c8(%rbp), %rdi
callq 0x2310
movq %rax, -0x470(%rbp)
jmp 0x5b2a
movq -0x470(%rbp), %rdi
leaq 0x5626(%rip), %rsi      # 0xb15e
callq 0x2180
jmp 0x5b3f
jmp 0x5b41
movl -0x2cc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2cc(%rbp)
jmp 0x55e2
movl $0x0, -0x4(%rbp)
leaq -0x2c8(%rbp), %rdi
callq 0x2250
movl -0x4(%rbp), %eax
addq $0x470, %rsp            # imm = 0x470
popq %rbp
retq
movq -0x88(%rbp), %rdi
callq 0x22c0