There are 8! = 40,320 permutations of 8 set members. The only way I can see to generate them all in an AMPL script is with 8 nested loops,
for {i1 in available}
for {i2 in available diff {i1}}
for {i3 in available diff {i1,i2}}
for ...
but I think this would be very slow. Maybe another reader can think of a better approach.
Bob Fourer
--
You received this message because you are subscribed to the Google Groups "AMPL Modeling Language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ampl+uns...@googlegroups.com.
To post to this group, send email to am...@googlegroups.com.
Visit this group at http://groups.google.com/group/ampl.
For more options, visit https://groups.google.com/d/optout.
I don’t know if this will help… There is a decent Wikipedia article that discusses algorithms for generating all permutations: http://en.wikipedia.org/wiki/Permutation#Algorithms_to_generate_permutations
--
You received this message because you are subscribed to a topic in the Google Groups "AMPL Modeling Language" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ampl/qsqjdnaVLXs/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ampl+uns...@googlegroups.com.
Thanks Bob. After staring at problem for a week I realized my error looking back at me. I only needed 2 subscripts for my first variable instead of all three.
Thanks florian. If my math skills were any better I would've been able to figure out how to fix the index problem. pretty neat calculation. Is that a pretty standard way to index permutations or did you customize it based on my question. pairs 1, pairs 2...
Thanks florian. If my math skills were any better I would've been able to figure out how to fix the index problem. pretty neat calculation. Is that a pretty standard way to index permutations or did you customize it based on my question. pairs 1, pairs 2...