Free cookie consent management tool by TermsFeed Policy Generator

Changeset 17036


Ignore:
Timestamp:
06/26/19 11:22:58 (5 years ago)
Author:
mkommend
Message:

#2435: Changed rng in ALGLIB to have a separate instance per thread.

Location:
branches/2435-alglib_3_15/HeuristicLab.ExtLibs/HeuristicLab.ALGLIB
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • branches/2435-alglib_3_15/HeuristicLab.ExtLibs/HeuristicLab.ALGLIB/3.15.0/ALGLIB-3.15.0/ap.cs

    r16684 r17036  
    762762    public class math
    763763    {
    764         //public static System.Random RndObject = new System.Random(System.DateTime.Now.Millisecond);
    765         public static System.Random rndobject = new System.Random(System.DateTime.Now.Millisecond + 1000*System.DateTime.Now.Second + 60*1000*System.DateTime.Now.Minute);
     764    //public static System.Random RndObject = new System.Random(System.DateTime.Now.Millisecond);
     765    [ThreadStatic] //mkommend: added thread static attribute to RNG to have a separate instance per thread and allow modification of the seed
     766    public static System.Random rndobject = new System.Random(System.DateTime.Now.Millisecond + 1000*System.DateTime.Now.Second + 60*1000*System.DateTime.Now.Minute);
    766767
    767768        public const double machineepsilon = 5E-16;
     
    777778        {
    778779            double r = 0;
     780            if (rndobject == null) rndobject = new System.Random(System.DateTime.Now.Millisecond + 1000 * System.DateTime.Now.Second + 60 * 1000 * System.DateTime.Now.Minute);
    779781            lock(rndobject){ r = rndobject.NextDouble(); }
    780782            return r;
     
    783785        {
    784786            int r = 0;
     787            if (rndobject == null) rndobject = new System.Random(System.DateTime.Now.Millisecond + 1000 * System.DateTime.Now.Second + 60 * 1000 * System.DateTime.Now.Minute);
    785788            lock(rndobject){ r = rndobject.Next(N); }
    786789            return r;
  • branches/2435-alglib_3_15/HeuristicLab.ExtLibs/HeuristicLab.ALGLIB/3.15.0/HeuristicLab.ALGLIB-3.15.0/HeuristicLab.ALGLIB-3.15.0.csproj

    r16684 r17036  
    8383  </ItemGroup>
    8484  <ItemGroup>
     85    <Content Include="ALGLIB changes by HEAL.txt" />
    8586    <Content Include="ALGLIB License-3.15.0.txt">
    8687      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
  • branches/2435-alglib_3_15/HeuristicLab.ExtLibs/HeuristicLab.ALGLIB/3.7.0/HeuristicLab.ALGLIB-3.7.0/HeuristicLab.ALGLIB-3.7.0.csproj

    r16565 r17036  
    127127  </ItemGroup>
    128128  <ItemGroup>
     129    <Content Include="ALGLIB changes by HEAL.txt" />
    129130    <Content Include="ALGLIB License-3.7.0.txt">
    130131      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
Note: See TracChangeset for help on using the changeset viewer.