# can anyone Help improving this algorithm I made

 Thomas Connachan · November 10, 2014 Hey, So I Made this algorithm to solve a VRP which at the moment is very bad algorithm but I am not sure how to improve it, Does anyone have any ideas on how I could improve it.If I am honest I am not entirely sure it does what I want it to at the moment eitherIt should make a route eg route A: and fill it with customers untill its at capacity, Then make a route eg Route B when A it full and add customers until route B is full and so onthanks for any help``// Create a route for a customer and add a new customer untill the route is // at capacity then do the same for a new route untill all customers// are in a route public void testAlgo() { this.soln = new ArrayList>(); int max = this.prob.depot.c; // set max capacity to vans max int current = 0; // set current capacity to 0 ArrayList route = null; // set route to null for(Customer c:prob.customers){ // for each customer in the problem int req = c.c; //set the required amount for delivery  if(current + req <= max){ //if current capacity plus req capacity is less than the max route = new ArrayList(); // make a route soln.add(route); // add the route to soln current = current + req; // add the req to the current to get the new current } route.add(c); // add customer to route } }``

## Replies

Nothing to see here.

## Java / Android Development

131,159 followers