1

Here's something which has been bugging me for the past two days. I need to populate an initial configuration(/state)-space for a fixpoint algorithm.

In this statespace, each transition weight has a vector of weights, and different bounds may apply to each of the weights in this vector.

This is currently defined as an example transition weight being for example (5,-1,-1)

The bounds for each weight correspond to the index of the weight vector itself, for example the upper bounds for these weights, assuming the lower bound is 0 for all is given by (5,3,3)

Now, to set up the initial configuration space, i need to have every combination of weights available in the beginning. (0,0,0) (0,0,1) (0,1,0) (1,0,0)... and so on, each of them going to their max bounds.

Now, if i was dealing with a 3-weighted system this would be trivial, but i need to support n-dimensional vectors in my code.

So, any ideas as to how i would accomplish populating this configuration space? (I'm using C# currently)

MrPyro
  • 13
  • 3
  • See [generating all possible combinations?](http://stackoverflow.com/questions/3093622/generating-all-possible-combinations). Your version is simpler since you don't care about the letters. – Raymond Chen Nov 12 '13 at 14:13

1 Answers1

0

Here's the code for generating all ntuples implemented in Javascript. It's self-explanatory, but if you need further explanation, I'd be glad to help (I actually tried to write the algorithm in pseudocode but what I wrote ended up looking like the comments)

Nikola Dimitroff
  • 6,127
  • 2
  • 25
  • 31
  • Thanks, i'll give it a look! A quick question though - segments.length is referenced in the code, but segments is never declared? – MrPyro Nov 12 '13 at 14:27
  • I copied the code above from a project of mine and there `boundingVector` was named `segments`. I wanted to rename it to make things clearer but guess I missed that part. I'll edit it right away. – Nikola Dimitroff Nov 12 '13 at 14:33
  • After a quick C# implementation, i am just getting 96 identical tuples. Will investigate further later. – MrPyro Nov 12 '13 at 15:02
  • Nevermind, in my haste i fudged my print method! This looks promising, i will have to study it a bit more to have a firm grasp of what's going on! Thanks so much! – MrPyro Nov 12 '13 at 18:13
  • Just run in it in your browser's console to see how it works :) – Nikola Dimitroff Nov 12 '13 at 19:04