length arrangement with probability and cost

2019-08-21 10:38发布

问题:

Consider a set of length, each associated with a probability. i.e.

X={a1=(100,1/4),a2=(500,1/4),a3=(200,1/2)}

Obviously, the sum of all the probabilities = 1.

Arrange the lengths together on a line one after the other from a starting point.

For example: {a2,a1,a3} in that order from start to finish.

Define the cost of an element a_i as its the total length from the starting line to the end of this element multiplied by its probability.

So from the previous arrangement:

cost(a2) = (500)*(1/4)
cost(a1) = (500+100)*(1/4)
cost(a3) = (500+100+200)*(1/2)

Define the total cost as the sum of all costs. e.g. cost(X) = cost(a2) + cost(a1) + cost(a3). Give an algorithm that finds an arrangement that minimizes cost(X)


My thoughts:

This looks like an greedy algorithm, since the last element in the arrangement always has the same sum multiplied by its probability, but I'm can't think of an heuristics that accomplishes this. It goes without saying that sorting by probability or length will not work.