Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Generating a very high number of Combinations in R [closed]

I have around 700 elements and want to create combinations of 20. The total number of combinations possible are [700 C 20] ~ 2.5e+38 combinations. This large dataset belongs to the specifications of a graph. This is a graph optimization problem, so, I would even like to apply the constraints to this set of combinations.

I'm using R! for this purpose due to it's rich range of packages and large dataset handling capabilities. I'm using the 'combinat' package. The problem though, is, when I try to compute this, I'm getting the following error:

combn(theDataSet,20,myFunction)
Error in matrix(r, nrow = len.r, ncol = count) : 
  invalid 'ncol' value (too large or NA)
In addition: Warning message:
In combn(theDataSet, 20, myFunction) : NAs introduced by coercion

Any solutions, alternate packages or algorithms to this problem is appreciated. Perhaps any method of handling the result?

And since this is graph optimization problem, any packages or algorithms related to this is very much appreciated too.

Or if any other tools that are available for solving such a problem, please tell me.

I'm an electronics major, so I don't know much of the advanced algorithms for graph optimizations and I had to take the combinatorial approach. If there are more intelligent approaches to this problem, I would love to know.

Help, please.

EDIT:

Since some of you have been asking for the actual problem, I'll just give an abstract of it, since posting my actual homework problems on the internet for line-to-line answers is not honourable.

ABSTRACT:

There are about 700 nodes, each of which have to recharged everyday by robots. The robots (which are placed inside a dome) carry a source which has about 5000 units of energy and the each node requires different energy levels (Average requirement of all the nodes is around 250, but it ranges from 120 units to 500 units for some of the nodes). The distance from the nodes to the dome and the distance from a node to every other is given (in a matrix form of dimension 701x701).There are constraints for how much each robot can travel in a day. Design an algorithm and write a program (in any commercially available specifications or packages) to efficiently calculate the number of robots required and the total distance travelled by all the robots.

like image 353
d34df3tu5 Avatar asked Dec 17 '25 22:12

d34df3tu5


1 Answers

You cannot generate all those combinations. That does not necessarily mean your overall problem is unsolvable. There are several approaches:

  1. Replace programming with theoretical analysis. Maybe you do not need to run the job at all.
  2. Look at what you want to do with the result of the combinations, Can you use its characteristics to limit the set of combinations you need, and only generate the useful ones?
  3. If you can stop your next stage of processing when you find something, try to write an algorithm that can process a stream of data, and stop when it gets a hit. Feed combinations to it as they are generated.

Anything more specific would depend on knowing what you intend to do with the results of the combinations process.

like image 73
Patricia Shanahan Avatar answered Dec 19 '25 14:12

Patricia Shanahan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!