private static GridResource createGridResource(String name, double baud_rate,
                        double delay, int MTU, int totalPE, int totalMachine,
                        int rating, String sched_alg)
    {
        // Here are the steps needed to create a Grid resource:
        // 1. We need to create an object of MachineList to store one or more
        //    Machines
        MachineList mList = new MachineList();
        for (int i = 0; i < totalMachine; i++)
        {
            // 2. Create one Machine with its id and list of PEs or CPUs
            mList.add(new Machine(i, totalPE, rating));
        }

        // 3. Create a ResourceCharacteristics object that stores the
        //    properties of a Grid resource: architecture, OS, list of
        //    Machines, allocation policy: time- or space-shared, time zone
        //    and its price (G$/PE time unit).
        String arch = "Sun Ultra"; // system architecture
        String os = "Solaris"; // operating system
        double time_zone = 9.0; // time zone this resource located
        double cost = 3.0; // the cost of using this resource
        int scheduling_alg = 0; // space_shared or time_shared

        if (sched_alg.equals("SPACE"))
        {
            scheduling_alg = ResourceCharacteristics.SPACE_SHARED;
        }
        else if (sched_alg.equals("TIME"))
        {
            scheduling_alg = ResourceCharacteristics.TIME_SHARED;
        }

        ResourceCharacteristics resConfig = new ResourceCharacteristics(arch, os,
                mList, scheduling_alg, time_zone, cost);


        // 4. Finally, we need to create a GridResource object.
        long seed = 11L * 13 * 17 * 19 * 23 + 1;
        double peakLoad = 0.0; // the resource load during peak hour
        double offPeakLoad = 0.0; // the resource load during off-peak hr
        double holidayLoad = 0.0; // the resource load during holiday

        // incorporates weekends so the grid resource is on 7 days a week
        LinkedList Weekends = new LinkedList();
        Weekends.add(new Integer(Calendar.SATURDAY));
        Weekends.add(new Integer(Calendar.SUNDAY));

        // incorporates holidays. However, no holidays are set in this example
        LinkedList Holidays = new LinkedList();
        GridResource gridRes = null;
        try
        {
            // creates a GridResource with a link
            gridRes = new GridResource(name,
                new SimpleLink(name + "_link", baud_rate, delay, MTU),
                seed, resConfig, peakLoad, offPeakLoad, holidayLoad, Weekends, Holidays);
        }
        catch (Exception e)
        {
            e.printStackTrace();
        }

        return gridRes;
    }