Skip to Content.
Sympa Menu

cgal-discuss - Re: [cgal-discuss] random number seed in Triangulation_hierarchy_3

Subject: CGAL users discussion list

List archive

Re: [cgal-discuss] random number seed in Triangulation_hierarchy_3


Chronological Thread 
  • From: Edoardo Milotti <>
  • To:
  • Subject: Re: [cgal-discuss] random number seed in Triangulation_hierarchy_3
  • Date: Mon, 25 Jan 2010 15:01:19 +0100

Dear Sylvain,

I have patched Triangulation_3.h as you suggested and now I get exactly the
same output, so I guess that this fixes the problem. Maybe in future versions
of CGAL you could add a function that lets the user set the seed of the
random number generator, this is important in Monte Carlo simulations such as
mine.
Thank you very much.

Best wishes,

Edoardo Milotti


On 25/gen/2010, at 12.54, Sylvain Pion wrote:

> Dear Edoardo,
>
> Can you please try what I suggested and report on the results ?
>
> Le 25/01/10 09:00, Edoardo Milotti a écrit :
>> Dear Sylvain , thank very much you for you answer, however I have one
>> further question.
>>
>> I insert points in the triangulation as follows (to maintain the
>> original order I use a sequential insertion)
>>
>> for(vector<Point>::iterator it=v.begin(); it!=v.end(); it++)
>> T.insert(*it);
>>
>> I add vertex info
>>
>> for (Finite_vertices_iterator vit = T.finite_vertices_begin(); vit !=
>> T.finite_vertices_end(); ++vit)
>> {
>> vit->info() = k;
>> k++;
>> }
>>
>> then I use the named vertices in a further loop
>>
>> for (Finite_vertices_iterator vit = T.finite_vertices_begin(); vit !=
>> T.finite_vertices_end(); ++vit)
>> {
>>
>> T.incident_vertices(vit, back_inserter(vn)); // list of named neighbors ...
>>
>> ... etc ...
>>
>> The order of the list of finite incident vertices in the last loop turns
>> out different at some point, like this
>>
>> first run
>>
>> - 8 1.93693532e-11 9.08382265e-06 2.132290991e-06
>> - 5 3.478538238e-11 8.274341753e-06 4.204006e-06
>> - 10 1.273731276e-11 9.54219939e-06 1.334840348e-06
>> - 6 1.795678855e-11 9.23188419e-06 1.945083818e-06
>> - 9 2.62181266e-11 8.721762172e-06 3.006058419e-06
>> - 1 4.740207202e-12 1.002035364e-05 4.730578752e-07
>> - 0 7.036177754e-11 3.051055408e-06 2.306145518e-05
>>
>> second run
>>
>> - 8 1.93693532e-11 9.08382265e-06 2.132290991e-06
>> - 10 1.273731276e-11 9.54219939e-06 1.334840348e-06
>> - 5 3.478538238e-11 8.274341753e-06 4.204006e-06
>> - 6 1.795678855e-11 9.23188419e-06 1.945083818e-06
>> - 9 2.62181266e-11 8.721762172e-06 3.006058419e-06
>> - 0 7.036177754e-11 3.051055408e-06 2.306145518e-05
>> - 1 4.740207202e-12 1.002035364e-05 4.730578752e-07
>>
>> here the first column is the vertex name, while the other three columns
>> contain geometric information, and in particular the second one is the
>> distance between the finite vertex under consideration and on of its
>> finite incident vertices. The distances are the same, only the order
>> appears to be shuffled. I guessed that this is due to the internal
>> random number generator, however I am no longer so sure now. I use long
>> double's to represent point coordinates (16 bytes): could it be some
>> type conversion and precision problem inside CGAL that determines a
>> different output order?
>>
>> Thank you very much,
>>
>> Edoardo Milotti
>>
>>
>> On 23/gen/2010, at 15.02, Sylvain Pion wrote:
>>
>>> Le 23/01/10 10:03, Edoardo Milotti a écrit :
>>>> I use Triangulation_hierarchy_3, and I insert vertices one by one in a
>>>> fixed order: I noticed that the triangulation output is shuffled and the
>>>> order is different every time I run my program. Can anybody please tell
>>>> me how to set the seed of the internal random number generator in order
>>>> to obtain a reproducible output? Thanks.
>>>
>>> By "output order", you meant the Cell_iterator order, not
>>> the Vertex_iterator order, right ?
>>>
>>> Does the following patch solve your problem ?
>>>
>>> --- Triangulation_3.h (revision 52267)
>>> +++ Triangulation_3.h (working copy)
>>> @@ -207,7 +207,6 @@
>>> Tds _tds;
>>> GT _gt;
>>> Vertex_handle infinite; //infinite vertex
>>> - mutable Random rng;
>>> Comparison_result
>>> compare_xyz(const Point &p, const Point &q) const
>>> @@ -1501,6 +1500,8 @@
>>> start = start->neighbor(ind_inf);
>>> }
>>> + Random rng (0L);
>>> +
>>> switch (dimension()) {
>>> case 3:
>>> {
>>>
>>> --
>>> Sylvain Pion
>>> INRIA Sophia Antipolis
>>> Geometrica Project-Team
>>> CGAL, http://cgal.org/
>>>
>>> --
>>> You are currently subscribed to cgal-discuss.
>>> To unsubscribe or access the archives, go to
>>> https://lists-sop.inria.fr/wws/info/cgal-discuss
>>>
>>
>
>
> --
> Sylvain Pion
> INRIA Sophia Antipolis
> Geometrica Project-Team
> CGAL, http://cgal.org/
>
> --
> You are currently subscribed to cgal-discuss.
> To unsubscribe or access the archives, go to
> https://lists-sop.inria.fr/wws/info/cgal-discuss
>




Archive powered by MHonArc 2.6.16.

Top of Page