|
From: <sul...@us...> - 2008-10-12 11:23:08
|
Revision: 257
http://gridsim.svn.sourceforge.net/gridsim/?rev=257&view=rev
Author: sulistio
Date: 2008-10-12 10:58:04 +0000 (Sun, 12 Oct 2008)
Log Message:
-----------
minor changes to the constructor
Modified Paths:
--------------
trunk/source/gridsim/ResourceCalendar.java
Modified: trunk/source/gridsim/ResourceCalendar.java
===================================================================
--- trunk/source/gridsim/ResourceCalendar.java 2008-10-12 06:38:06 UTC (rev 256)
+++ trunk/source/gridsim/ResourceCalendar.java 2008-10-12 10:58:04 UTC (rev 257)
@@ -36,11 +36,11 @@
// LinkedList weekend is a list of 0 = Sunday, 1 = Monday, 2 = Tuesday,
// 3 = Wednesday, 4 = Thursday, 5 = Friday, 6 = Saturday
/**
- * Allocates a new ResourceCalendar object
+ * Allocates a new ResourceCalendar object with a default daily regular load.
* @param timeZone time zone
* @param peakLoad the load during peak time, with range: [0 ... 1]
* @param offPeakLoad the load during off peak time, with range: [0 ... 1]
- * @param relativeHolidayLoad the load during holidays,
+ * @param relativeHolidayLoad the load during holidays,
* with range: [0 ... 1]
* @param weekendList a list of Integer numbers for weekends
* @param holidayList a list of Integer numbers for holidays
@@ -53,9 +53,70 @@
double offPeakLoad, double relativeHolidayLoad,
LinkedList weekendList, LinkedList holidayList, long seed)
{
- random_ = new Random(seed);
+ // initialised as per common observation of relative local
+ // usage behavior of resource per hour in a day
+ // NOTE: This is similar to background load of a resource
+ double[] regularLoad = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, // 0 - 6 am
+ 0.0, 0.1, 0.2, 0.4, 0.8, 1.0, // 7 - 11 am
+ 1.0, 0.6, 0.6, 0.9, 1.0, 1.0, // 12 - 5 pm
+ 0.5, 0.2, 0.1, 0.0, 0.0, 0.0 }; // 6 - 11.59pm
+
this.timeZone_ = timeZone;
+ init(regularLoad, peakLoad, offPeakLoad, relativeHolidayLoad, weekendList,
+ holidayList, seed);
+ }
+
+ /**
+ * Allocates a new ResourceCalendar object with a pre-defined daily regular load
+ * @param regularLoad the daily regular load, with range: [0 ... 1].
+ * Note that regularLoad[0] represents time 00:00 (hh:mm),
+ * and regularLoad[23] represents time 23:00.
+ * @param timeZone time zone
+ * @param peakLoad the load during peak time, with range: [0 ... 1]
+ * @param offPeakLoad the load during off peak time, with range: [0 ... 1]
+ * @param relativeHolidayLoad the load during holidays,
+ * with range: [0 ... 1]
+ * @param weekendList a list of Integer numbers for weekends
+ * @param holidayList a list of Integer numbers for holidays
+ * @param seed the initial seed
+ * @pre timeZone >= 0.0
+ * @pre seed > 0
+ * @post $none
+ */
+ public ResourceCalendar(double[] regularLoad, double timeZone, double peakLoad,
+ double offPeakLoad, double relativeHolidayLoad,
+ LinkedList weekendList, LinkedList holidayList, long seed)
+ {
+ this.timeZone_ = timeZone;
+ init(regularLoad, peakLoad, offPeakLoad, relativeHolidayLoad, weekendList,
+ holidayList, seed);
+ }
+
+ /**
+ * Allocates a new ResourceCalendar object with a pre-defined daily regular load
+ * @param regularLoad the daily regular load, with range: [0 ... 1].
+ * Note that regularLoad[0] represents time 00:00, and
+ * regularLoad[23] represents time 23:00.
+ * @param peakLoad the load during peak time, with range: [0 ... 1]
+ * @param offPeakLoad the load during off peak time, with range: [0 ... 1]
+ * @param relativeHolidayLoad the load during holidays,
+ * with range: [0 ... 1]
+ * @param weekendList a list of Integer numbers for weekends
+ * @param holidayList a list of Integer numbers for holidays
+ * @param seed the initial seed
+ * @pre timeZone >= 0.0
+ * @pre seed > 0
+ * @post $none
+ */
+ private void init(double[] regularLoad, double peakLoad,
+ double offPeakLoad, double relativeHolidayLoad,
+ LinkedList weekendList, LinkedList holidayList, long seed)
+ {
+ this.weekendList_ = weekendList;
+ this.holidayList_ = holidayList;
+ random_ = new Random(seed);
+
// load must be within [0 .. 1] range
int FULL = 1;
if (peakLoad > FULL) {
@@ -70,23 +131,17 @@
relativeHolidayLoad = FULL;
}
- // initialised as per common observation of relative local
- // usage behavior of resource per hour in a day
- // NOTE: This is similar to background load of a resource
- double[] regularLoad = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, // 0 - 6 am
- 0.0, 0.1, 0.2, 0.4, 0.8, 1.0, // 7 - 11 am
- 1.0, 0.6, 0.6, 0.9, 1.0, 1.0, // 12 - 5 pm
- 0.5, 0.2, 0.1, 0.0, 0.0, 0.0 }; // 6 - 11.59pm
-
+ /////////////////
double val = 0.0;
double FACTOR = 0.1;
+ int SIZE = regularLoad.length;
int HOUR = 24;
weekdayLoad_ = new double[HOUR]; // background load during weekdays
holidayLoad_ = new double[HOUR]; // background load during holidays
// for each hour in a day, determine the load during the weekday and
// holiday
- for (int i = 0; i < HOUR; i++)
+ for (int i = 0; i < regularLoad.length; i++)
{
val = regularLoad[i] * (peakLoad - offPeakLoad) + offPeakLoad;
@@ -95,10 +150,10 @@
random_.nextDouble() );
// background load during the holiday
- holidayLoad_[i] = GridSimRandom.real( relativeHolidayLoad * val,
+ holidayLoad_[i] = GridSimRandom.real( relativeHolidayLoad * val,
FACTOR, FACTOR, random_.nextDouble() );
- // if the load is full, it means that a resource can't process
+ // if the load is full, it means that a resource can't process
// any jobs. Hence, need to lower the load
if (weekdayLoad_[i] >= FULL) {
weekdayLoad_[i] = 0.95;
@@ -109,8 +164,19 @@
}
}
- this.weekendList_ = weekendList;
- this.holidayList_ = holidayList;
+ if (regularLoad.length < HOUR)
+ {
+ System.out.println("ResourceCalendar(): Warning regularLoad[] must" +
+ " be for 24 hours.\nThe loads in the remaining hours will set to zeros.");
+
+ // then set remaining loads to zero
+ for (int i = regularLoad.length; i < HOUR; i++)
+ {
+ weekdayLoad_[i] = 0;
+ holidayLoad_[i] = 0;
+
+ }
+ } // end if
}
/**
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|