[metslib] Problem with random_shuffle

Shahin Gelareh shahin.gelareh at gmail.com
Tue Nov 9 02:01:05 EST 2010


Hi everybody,

It seems like there have been a lot of changes from 4.3 to 5. Thanks for the
efforts.
The code I had in 4.3 does not work anymore with 5, it is of course
migratable but now the main concern is regarding the suffleing algorithm of
STL.
The results in windows and using MSVC (MSVS2010)compiler is not what one
expects. This is for example the case for qap example.
I personally cannot run it. It reports exception and exits.

One only needs to trace the code until:
 template<typename random_generator>
  void random_shuffle(permutation_problem& p, random_generator& rng)
  {
#if defined (METSLIB_HAVE_UNORDERED_MAP) && !defined
(METSLIB_TR1_MIXED_NAMESPACE)
    std::uniform_int<> unigen(0, p.pi_m.size());
    std::variate_generator<random_generator,
      std::uniform_int<> >gen(rng, unigen);
#else
    std::tr1::uniform_int<> unigen(0, p.pi_m.size());
    std::tr1::variate_generator<random_generator,
      std::tr1::uniform_int<> >gen(rng, unigen);
#endif
    std::random_shuffle(p.pi_m.begin(), p.pi_m.end(), gen);
    p.update_cost();
  }


The output of this "std::random_shuffle(p.pi_m.begin(), p.pi_m.end(), gen);"
is the original permutation where some of the cells are swapped BUT there
are some strange numbers among the numbers. large positive values
specifically. I searched a lot with no success about how to overcome.

I was wondering if anyone has any idea?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://list.coin-or.org/pipermail/metslib/attachments/20101109/088fae54/attachment.html 


More information about the metslib mailing list