当前位置:  开发笔记 > 编程语言 > 正文

long seed = 11L*13*17*19*23 + 1是什么意思; 在上面的代码?

如何解决《longseed=11L*13*17*19*23+1是什么意思;在上面的代码?》经验,为你挑选了1个好方法。

一个简单的程序,演示如何使用GridSim包.*此示例显示网格用户如何将其Gridlets或*任务提交到一个网格资源实体.

private GridletList createGridlet(int userID)
{
    // Creates a container to store Gridlets
    GridletList list = new GridletList();

    // We create three Gridlets or jobs/tasks manually without the help
    // of GridSimRandom
    int id = 0;
    double length = 3500.0;
    long file_size = 300;
    long output_size = 300;
    Gridlet gridlet1 = new Gridlet(id, length, file_size, output_size);
    id++;
    Gridlet gridlet2 = new Gridlet(id, 5000, 500, 500);
    id++;
    Gridlet gridlet3 = new Gridlet(id, 9000, 900, 900);

    // setting the owner of these Gridlets
    gridlet1.setUserID(userID);
    gridlet2.setUserID(userID);
    gridlet3.setUserID(userID);

    // Store the Gridlets into a list
    list.add(gridlet1);
    list.add(gridlet2);
    list.add(gridlet3);

    // We create 5 Gridlets with the help of GridSimRandom and
    // GriSimStandardPE class
    long seed = 11L*13*17*19*23+1;
    Random random = new Random(seed);

    // sets the PE MIPS Rating
    GridSimStandardPE.setRating(100);

    // creates 5 Gridlets
    int count = 5;
    for (int i = 1; i < count+1; i++)
    {
        // the Gridlet length determines from random values and the
        // current MIPS Rating for a PE
        length = GridSimStandardPE.toMIs(random.nextDouble()*50);

        // determines the Gridlet file size that varies within the range
        // 100 + (10% to 40%)
        file_size = (long) GridSimRandom.real(100, 0.10, 0.40,
                                random.nextDouble());

        // determines the Gridlet output size that varies within the range
        // 250 + (10% to 50%)
        output_size = (long) GridSimRandom.real(250, 0.10, 0.50,
                                random.nextDouble());

        // creates a new Gridlet object
        Gridlet gridlet = new Gridlet(id + i, length, file_size,
                                output_size);

        gridlet.setUserID(userID);

        // add the Gridlet into a list
        list.add(gridlet);
    }

    return list;
}

Erik A. Bran.. 5

如果向a添加种子Random,则每次运行代码时都会得到相同的结果.如果没有提供种子,java会自己选择种子(基于当前时间).这是伪随机数生成的一个特征.有关详细说明,请参阅使用种子的Java随机数.



1> Erik A. Bran..:

如果向a添加种子Random,则每次运行代码时都会得到相同的结果.如果没有提供种子,java会自己选择种子(基于当前时间).这是伪随机数生成的一个特征.有关详细说明,请参阅使用种子的Java随机数.

推荐阅读
Gbom2402851125
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有