Пример #1
0
    public static void randomx(vector x, vector a, vector b, Random RND, lattice RNDL, halton RNDH, bool print_points, bool Lattice = false, bool Halton = false)
    {
        int dim = a.size;

        if (Lattice)
        {
            vector y = x.copy();
            RNDL.next(y);
            for (int i = 0; i < dim; i++)
            {
                x[i] = a[i] + y[i] * (b[i] - a[i]);
            }
        }
        if (Halton)
        {
            vector y = x.copy();
            RNDH.next(y);
            for (int i = 0; i < dim; i++)
            {
                x[i] = a[i] + y[i] * (b[i] - a[i]);
            }
        }
        if (!Lattice && !Halton)
        {
            for (int i = 0; i < dim; i++)
            {
                x[i] = a[i] + RND.NextDouble() * (b[i] - a[i]);
            }
        }

        if (print_points)
        {
            StreamWriter pointWriter = new StreamWriter("sample_points.txt", true);
            for (int i = 0; i < x.size; i++)
            {
                pointWriter.Write($"{x[i]} ");
            }
            pointWriter.Write("\n");
            pointWriter.Close();
        }
    }