Question

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)

Était-ce utile?

La solution

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)

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top