python - Calculate cost to combine subsets to get original set -


I have a list of items

[1,2,3]

And I have some subsets of the list above with a special cost such as

  {(1): 5.0, (2): 3.0, (3): 2.5, (1,3): 6.0, (2,3): 5.0,}  

I have to find a way to get the list above with the lowest price. For example, I could get [1,2,3] by combination (1), (2), (3) at the cost of 10.5, combinations (1,3) and ( 2) with the cost of 9.0 and combination (1) and (2,3) 10.0 with the cost . With my second choice I will be able to reach the lowest price.

because I consider that the solution I present combination of a set division of the above list [1,2,3] and if any special subtitles in Arabic, but this solution is not optimal their The set of lists is a huge cost associated with generating partitions.

set partitioning algorithm

Try:

  • Cost of each object => Exclude any set of two objects with the value of each item.
  • Three words whose cost is> = the cost of some combination of size set> 3.
  • ...

greedy algorithms bit:

  • One of the sets that are randomly given the rest of the larger size select
  • once again it is left connects the largest set both
    1. covering
    2. < Em> and then , at least cost.

Above should give something better than a purely random selection.


Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -