hello,

While trying to solve a route optimization problem for the Kaggle Competition:

santa’s stolen sleigh,I chanced upon the following code in the Kaggle forum.

```
base_weight <- 10
max_capacity <- 1000
positions <- lapply(c(1:nrow(gifts)), function(x) with(gifts[x,], c(Longitude, Latitude)))
single_trip <- function(current_gifts_ids){
n <- length(current_gifts_ids)
current_positions <- positions[current_gifts_ids]
weights <- gifts[current_gifts_ids, Weight]
csw <- c(rev(cumsum(rev(weights))), 0) + base_weight
a <- append(current_positions, list(c(0, 90)), 0)
b <- append(current_positions, list(c(0, 90)), n + 1)
distances <- mapply(distHaversine, a, b)
current_wrw <- sum(csw*distances)
return(current_wrw)
}
```

However I am unable to understand it:

1.How are the base_weight and max_capacity initialized?

2.What is the positions capturing?

3.What is the single_trip function doing.

I understand that Haversine distance is being used here as the distance is spherical and originates at North Pole but beyond that my grey cells aren’t quite working.

Can someone please help me with this??