From: <mar...@us...> - 2008-02-05 00:28:26
|
Revision: 86 http://gridsim.svn.sourceforge.net/gridsim/?rev=86&view=rev Author: marcos_dias Date: 2008-02-04 16:28:29 -0800 (Mon, 04 Feb 2008) Log Message: ----------- Small changes in the Lublin99 workload model and the availability info send by resource providers. Modified Paths: -------------- branches/gridsim4.0-branch3/examples/examples/workload/parallel/LublinWorkloadExample01.java branches/gridsim4.0-branch3/source/gridsim/turbo/ARParallelSpaceShared.java branches/gridsim4.0-branch3/source/gridsim/turbo/AvailabilityInfo.java branches/gridsim4.0-branch3/source/gridsim/turbo/Lublin99Workload.java Modified: branches/gridsim4.0-branch3/examples/examples/workload/parallel/LublinWorkloadExample01.java =================================================================== --- branches/gridsim4.0-branch3/examples/examples/workload/parallel/LublinWorkloadExample01.java 2008-02-04 04:32:43 UTC (rev 85) +++ branches/gridsim4.0-branch3/examples/examples/workload/parallel/LublinWorkloadExample01.java 2008-02-05 00:28:29 UTC (rev 86) @@ -83,9 +83,9 @@ double uHi = Math.log(totalPE * totalMachine) / Math.log(2d); double uMed = uHi-2.5; - workload.setParallelJobProbabilities(Lublin99Workload.BATCH, - Lublin99Workload.ULOW_BATCH, uMed, uHi, - Lublin99Workload.UPROB_BATCH); + workload.setParallelJobProbabilities(Lublin99Workload.BATCH_JOBS, + workload.getParallelJobULow(Lublin99Workload.BATCH_JOBS), uMed, uHi, + workload.getParallelJobUProb(Lublin99Workload.BATCH_JOBS)); // sets the workload to create 1000 jobs workload.setNumJobs(1000); @@ -120,8 +120,7 @@ * @param totalPE total number of PEs for each Machine */ private static GridResource createGridResource(String name, int peRating, - int totalMachine, int totalPE) - { + int totalMachine, int totalPE) { ////////////////////////////////////////// // Here are the steps needed to create a Grid resource: Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/ARParallelSpaceShared.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/ARParallelSpaceShared.java 2008-02-04 04:32:43 UTC (rev 85) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/ARParallelSpaceShared.java 2008-02-05 00:28:29 UTC (rev 86) @@ -9,7 +9,6 @@ import eduni.simjava.Sim_event; import eduni.simjava.Sim_system; -import gridsim.GridResource; import gridsim.GridSim; import gridsim.GridSimTags; import gridsim.Gridlet; Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/AvailabilityInfo.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/AvailabilityInfo.java 2008-02-04 04:32:43 UTC (rev 85) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/AvailabilityInfo.java 2008-02-05 00:28:29 UTC (rev 86) @@ -212,6 +212,28 @@ } /** + * Returns the entry whose time is closest to the <tt>time</tt> given but + * smaller, or whose time is equals to <tt>time</tt> + * @param time the time to be used to search for the entry + * @return the entry whose time is closest to the <tt>time</tt> given but + * smaller, or whose time is equals to <tt>time</tt> + */ + private AvailabilityInfoEntry getPrecedingEntry(double time) { + Iterator<AvailabilityInfoEntry> it = list_.iterator(); + AvailabilityInfoEntry preceding = null; + + while(it.hasNext()) { + AvailabilityInfoEntry entry = it.next(); + if(entry.getTime() > time) + break; + + preceding = entry; + } + + return preceding; + } + + /** * Scans the entries in a list and returns the first time frame over * which a request with the characteristics provided can be scheduled * @param duration the duration of the request @@ -219,7 +241,28 @@ * @return the start time or <tt>-1</tt> if not found */ public double getPotentialStartTime(int duration, int reqPE) { + return getPotentialStartTime(0, duration, reqPE); + } + + /** + * Scans the entries in the availability info object returns the start + * time of the first time frame over which a request with the characteristics + * provided can be scheduled. + * @param readyTime the method will consider potential start times + * further in time than the value given by <tt>readyTime</tt>. + * @param duration the duration of the request + * @param reqPE the number of PEs required + * @return the start time or <tt>-1</tt> if not found. + */ + public double getPotentialStartTime(double readyTime, + int duration, int reqPE) { + if(readyTime < startTime_) + readyTime = startTime_; + + if(readyTime > finishTime_) + return UNKNOWN; + // the anchor index, the entry in the profile where // the request would be placed OR the closest entry to the // point where the anchor of the request would be placed @@ -228,27 +271,28 @@ // a pointer to the anchor entry (described above) AvailabilityInfoEntry anchorEntry = null; - // the list of selected ranges - PERangeList intersectList = null; - double potStartTime = -1; // keep the potential start time of the request double potFinishTime = -1; // store the gridlet's expected finish time - - intersectList = null; int length = list_.size(); - - Iterator<AvailabilityInfoEntry> iterProfile = list_.iterator(); - while(iterProfile.hasNext()) { + + anchorEntry = getPrecedingEntry(readyTime); + int firstAnchorIndex = list_.indexOf(anchorEntry); + if(firstAnchorIndex == -1) + firstAnchorIndex = 0; + + for(int j=firstAnchorIndex; j<length; j++) { + AvailabilityInfoEntry entry = list_.get(j); + anchorIndex = list_.indexOf(entry); - AvailabilityInfoEntry entry = iterProfile.next(); - anchorEntry = entry; - anchorIndex = list_.indexOf(anchorEntry); - // sets the start time as the time of the entry - potStartTime = entry.getTime(); - // calculates when the finish time will be if + if(entry.getTime() < readyTime) + potStartTime = readyTime; + else + potStartTime = entry.getTime(); + + // calculates when the finish time will be if // the gridlet is put at this position - potFinishTime = potStartTime + duration; + potFinishTime = potStartTime + duration; // scan the profile until an entry with enough PEs is found if(entry.getNumPE() < reqPE) { @@ -259,7 +303,7 @@ // from that point onwards analysing the intersection of // the ranges available in the entries until the // request expected completion time - intersectList = entry.getAvailRanges().clone(); + PERangeList intersectList = entry.getAvailRanges().clone(); // Look for the intersection of available ranges from // the anchor until the end of the profile or until @@ -274,7 +318,8 @@ // is no need to check the intersection if(nextEntry.getTime() < potFinishTime) { intersectList = PERangeList.intersection(intersectList, - nextEntry.getAvailRanges()); + nextEntry.getAvailRanges()); + if(intersectList == null || intersectList.getNumPE() < reqPE) { break; } Modified: branches/gridsim4.0-branch3/source/gridsim/turbo/Lublin99Workload.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/turbo/Lublin99Workload.java 2008-02-04 04:32:43 UTC (rev 85) +++ branches/gridsim4.0-branch3/source/gridsim/turbo/Lublin99Workload.java 2008-02-05 00:28:29 UTC (rev 86) @@ -70,13 +70,11 @@ // Log PI for lgamma method private static final double LOGPI = 1.14472988584940017414; - protected final int INTERVAL = 10; // number of intervals + private final int INTERVAL = 10; // number of intervals + private static final int UNKNOWN = -1; // ------------ CONSTANTS USED BY THE WORKLOAD MODEL -------------- - // number of jobs generated by this entity - private static final int SIZE = 1000; - // no more than two days =exp(12) for runtime private static final int TOO_MUCH_TIME = 12; @@ -103,10 +101,10 @@ private static final double EPS = 1E-10; /** Represents interactive jobs */ - public static final int INTERACTIVE = 0; + public static final int INTERACTIVE_JOBS = 0; /** Represents batch jobs */ - public static final int BATCH = 1; + public static final int BATCH_JOBS = 1; // ------------------- MODEL DEFAULT PARAMETERS ----------------------- @@ -121,19 +119,19 @@ * UMed should be in [UHi-1.5 , UHi-3.5] * Uprob should be in [0.7 - 0.95] */ - public static final double SERIAL_PROB_BATCH = 0.2927; - public static final double POW2_PROB_BATCH = 0.6686; - public static final double ULOW_BATCH = 1.2f; // smallest parallel batch job has 2 nodes - public static final double UMED_BATCH = 5; - public static final double UHI_BATCH = 7; // biggest batch job has 128 nodes - public static final double UPROB_BATCH = 0.875; + private static final double SERIAL_PROB_BATCH = 0.2927; + private static final double POW2_PROB_BATCH = 0.6686; + private static final double ULOW_BATCH = 1.2f; // smallest parallel batch job has 2 nodes + private static final double UMED_BATCH = 5; + private static final double UHI_BATCH = 7; // biggest batch job has 128 nodes + private static final double UPROB_BATCH = 0.875; - public static final double SERIAL_PROB_ACTIVE = 0.1541; - public static final double POW2_PROB_ACTIVE = 0.625; - public static final double ULOW_ACTIVE = 1; // smallest interactive parallel job has 2 nodes - public static final double UMED_ACTIVE = 3; - public static final double UHI_ACTIVE = 5.5f; // biggest interactive job has 45 nodes - public static final double UPROB_ACTIVE = 0.705; + private static final double SERIAL_PROB_ACTIVE = 0.1541; + private static final double POW2_PROB_ACTIVE = 0.625; + private static final double ULOW_ACTIVE = 1; // smallest interactive parallel job has 2 nodes + private static final double UMED_ACTIVE = 3; + private static final double UHI_ACTIVE = 5.5f; // biggest interactive job has 45 nodes + private static final double UPROB_ACTIVE = 0.705; /* The parameters for the running time * The running time is computed using hyper-gamma distribution. @@ -143,19 +141,19 @@ * 'nodes' will be calculated in the program, here we defined the 'pa','pb' * parameters. */ - public static final double A1_BATCH = 6.57; - public static final double B1_BATCH = 0.823; - public static final double A2_BATCH = 639.1; - public static final double B2_BATCH = 0.0156; - public static final double PA_BATCH = -0.003; - public static final double PB_BATCH = 0.6986; + private static final double A1_BATCH = 6.57; + private static final double B1_BATCH = 0.823; + private static final double A2_BATCH = 639.1; + private static final double B2_BATCH = 0.0156; + private static final double PA_BATCH = -0.003; + private static final double PB_BATCH = 0.6986; - public static final double A1_ACTIVE = 3.8351; - public static final double B1_ACTIVE = 0.6605; - public static final double A2_ACTIVE = 7.073; - public static final double B2_ACTIVE = 0.6856; - public static final double PA_ACTIVE = -0.0118; - public static final double PB_ACTIVE = 0.9156; + private static final double A1_ACTIVE = 3.8351; + private static final double B1_ACTIVE = 0.6605; + private static final double A2_ACTIVE = 7.073; + private static final double B2_ACTIVE = 0.6856; + private static final double PA_ACTIVE = -0.0118; + private static final double PB_ACTIVE = 0.9156; /* The parameters for the inter-arrival time @@ -169,41 +167,41 @@ * a constant ,ARAR (Arrive-Rush-All-Ratio), to set the alpha parameter (the new * aarr) so it will represent the arrive-time at all hours of the day. */ - public static final double AARR_BATCH = 6.0415; - public static final double BARR_BATCH = 0.8531; - public static final double ANUM_BATCH = 6.1271; - public static final double BNUM_BATCH = 5.2740; - public static final double ARAR_BATCH = 1.0519; + private static final double AARR_BATCH = 6.0415; + private static final double BARR_BATCH = 0.8531; + private static final double ANUM_BATCH = 6.1271; + private static final double BNUM_BATCH = 5.2740; + private static final double ARAR_BATCH = 1.0519; - public static final double AARR_ACTIVE = 6.5510; - public static final double BARR_ACTIVE = 0.6621; - public static final double ANUM_ACTIVE = 8.9186; - public static final double BNUM_ACTIVE = 3.6680; - public static final double ARAR_ACTIVE = 0.9797; + private static final double AARR_ACTIVE = 6.5510; + private static final double BARR_ACTIVE = 0.6621; + private static final double ANUM_ACTIVE = 8.9186; + private static final double BNUM_ACTIVE = 3.6680; + private static final double ARAR_ACTIVE = 0.9797; /* * Here are the model's parameters for typeless data (no batch nor interactive) * We use those parameters when INCLUDE_JOBS_TYPE is off (0) */ - public static final double SERIAL_PROB = 0.244; - public static final double POW2_PROB = 0.576; - public static final double ULOW = 0.8f; // The smallest parallel job is 2 nodes - public static final double UMED = 4.5f; - public static final double UHI = 7f; // SYSTEM SIZE is 2^UHI == 128 - public static final double UPROB = 0.86; + private static final double SERIAL_PROB = 0.244; + private static final double POW2_PROB = 0.576; + private static final double ULOW = 0.8f; // The smallest parallel job is 2 nodes + private static final double UMED = 4.5f; + private static final double UHI = 7f; // SYSTEM SIZE is 2^UHI == 128 + private static final double UPROB = 0.86; - public static final double A1 = 4.2; - public static final double B1 = 0.94; - public static final double A2 = 312; - public static final double B2 = 0.03; - public static final double PA = -0.0054; - public static final double PB = 0.78; + private static final double A1 = 4.2; + private static final double B1 = 0.94; + private static final double A2 = 312; + private static final double B2 = 0.03; + private static final double PA = -0.0054; + private static final double PB = 0.78; - public static final double AARR = 10.2303; - public static final double BARR = 0.4871; - public static final double ANUM = 8.1737; - public static final double BNUM = 3.9631; - public static final double ARAR = 1.0225; + private static final double AARR = 10.2303; + private static final double BARR = 0.4871; + private static final double ANUM = 8.1737; + private static final double BNUM = 3.9631; + private static final double ARAR = 1.0225; // start the simulation at midnight (hour 0) private static final int START = 0; @@ -217,6 +215,9 @@ private double workloadDuration_; private int numJobs_; + // hour of the day when the simulation starts + private int start_; + private double[] a1, b1, a2, b2, pa, pb; private double[] aarr, barr, anum, bnum; private double[] serialProb, pow2Prob, uLow, uMed, uHi, uProb; @@ -443,6 +444,7 @@ random_ = new Random(seed); workloadDuration_ = Double.MAX_VALUE; numJobs_ = 1000; + start_ = START; a1 = new double[2]; b1 = new double[2]; a2 = new double[2]; b2 = new double[2]; @@ -457,60 +459,60 @@ // separate batch from interactive if (useJobType_) { - serialProb[BATCH] = SERIAL_PROB_BATCH; - pow2Prob[BATCH] = POW2_PROB_BATCH; - uLow[BATCH] = ULOW_BATCH; - uMed[BATCH] = UMED_BATCH; - uHi[BATCH] = UHI_BATCH; - uProb[BATCH] = UPROB_BATCH; + serialProb[BATCH_JOBS] = SERIAL_PROB_BATCH; + pow2Prob[BATCH_JOBS] = POW2_PROB_BATCH; + uLow[BATCH_JOBS] = ULOW_BATCH; + uMed[BATCH_JOBS] = UMED_BATCH; + uHi[BATCH_JOBS] = UHI_BATCH; + uProb[BATCH_JOBS] = UPROB_BATCH; - serialProb[INTERACTIVE] = SERIAL_PROB_ACTIVE; - pow2Prob[INTERACTIVE] = POW2_PROB_ACTIVE; - uLow[INTERACTIVE] = ULOW_ACTIVE; - uMed[INTERACTIVE] = UMED_ACTIVE; - uHi[INTERACTIVE] = UHI_ACTIVE; - uProb[INTERACTIVE] = UPROB_ACTIVE; + serialProb[INTERACTIVE_JOBS] = SERIAL_PROB_ACTIVE; + pow2Prob[INTERACTIVE_JOBS] = POW2_PROB_ACTIVE; + uLow[INTERACTIVE_JOBS] = ULOW_ACTIVE; + uMed[INTERACTIVE_JOBS] = UMED_ACTIVE; + uHi[INTERACTIVE_JOBS] = UHI_ACTIVE; + uProb[INTERACTIVE_JOBS] = UPROB_ACTIVE; - a1[BATCH] = A1_BATCH; b1[BATCH] = B1_BATCH; - a2[BATCH] = A2_BATCH; b2[BATCH] = B2_BATCH; - pa[BATCH] = PA_BATCH; pb[BATCH] = PB_BATCH; + a1[BATCH_JOBS] = A1_BATCH; b1[BATCH_JOBS] = B1_BATCH; + a2[BATCH_JOBS] = A2_BATCH; b2[BATCH_JOBS] = B2_BATCH; + pa[BATCH_JOBS] = PA_BATCH; pb[BATCH_JOBS] = PB_BATCH; - a1[INTERACTIVE] = A1_ACTIVE; b1[INTERACTIVE] = B1_ACTIVE; - a2[INTERACTIVE] = A2_ACTIVE; b2[INTERACTIVE] = B2_ACTIVE; - pa[INTERACTIVE] = PA_ACTIVE; pb[INTERACTIVE] = PB_ACTIVE; + a1[INTERACTIVE_JOBS] = A1_ACTIVE; b1[INTERACTIVE_JOBS] = B1_ACTIVE; + a2[INTERACTIVE_JOBS] = A2_ACTIVE; b2[INTERACTIVE_JOBS] = B2_ACTIVE; + pa[INTERACTIVE_JOBS] = PA_ACTIVE; pb[INTERACTIVE_JOBS] = PB_ACTIVE; - aarr[BATCH] = AARR_BATCH*ARAR_BATCH; barr[BATCH] = BARR_BATCH; - anum[BATCH] = ANUM_BATCH; bnum[BATCH] = BNUM_BATCH; + aarr[BATCH_JOBS] = AARR_BATCH*ARAR_BATCH; barr[BATCH_JOBS] = BARR_BATCH; + anum[BATCH_JOBS] = ANUM_BATCH; bnum[BATCH_JOBS] = BNUM_BATCH; - aarr[INTERACTIVE] = AARR_ACTIVE*ARAR_ACTIVE; - barr[INTERACTIVE] = BARR_ACTIVE; - anum[INTERACTIVE] = ANUM_ACTIVE; - bnum[INTERACTIVE] = BNUM_ACTIVE; + aarr[INTERACTIVE_JOBS] = AARR_ACTIVE*ARAR_ACTIVE; + barr[INTERACTIVE_JOBS] = BARR_ACTIVE; + anum[INTERACTIVE_JOBS] = ANUM_ACTIVE; + bnum[INTERACTIVE_JOBS] = BNUM_ACTIVE; } else { // whole sample -- make all batch jobs - serialProb[BATCH] = serialProb[INTERACTIVE] = SERIAL_PROB; - pow2Prob[BATCH] = pow2Prob[INTERACTIVE] = POW2_PROB; - uLow[BATCH] = uLow[INTERACTIVE] = ULOW ; - uMed[BATCH] = uMed[INTERACTIVE] = UMED ; - uHi[BATCH] = uHi[INTERACTIVE] = UHI ; - uProb[BATCH] = uProb[INTERACTIVE] = UPROB ; + serialProb[BATCH_JOBS] = serialProb[INTERACTIVE_JOBS] = SERIAL_PROB; + pow2Prob[BATCH_JOBS] = pow2Prob[INTERACTIVE_JOBS] = POW2_PROB; + uLow[BATCH_JOBS] = uLow[INTERACTIVE_JOBS] = ULOW ; + uMed[BATCH_JOBS] = uMed[INTERACTIVE_JOBS] = UMED ; + uHi[BATCH_JOBS] = uHi[INTERACTIVE_JOBS] = UHI ; + uProb[BATCH_JOBS] = uProb[INTERACTIVE_JOBS] = UPROB ; - a1[BATCH] = a1[INTERACTIVE] = A1; - b1[BATCH] = b1[INTERACTIVE] = B1; - a2[BATCH] = a2[INTERACTIVE] = A2; - b2[BATCH] = b2[INTERACTIVE] = B2; - pa[BATCH] = pa[INTERACTIVE] = PA; - pb[BATCH] = pb[INTERACTIVE] = PB; + a1[BATCH_JOBS] = a1[INTERACTIVE_JOBS] = A1; + b1[BATCH_JOBS] = b1[INTERACTIVE_JOBS] = B1; + a2[BATCH_JOBS] = a2[INTERACTIVE_JOBS] = A2; + b2[BATCH_JOBS] = b2[INTERACTIVE_JOBS] = B2; + pa[BATCH_JOBS] = pa[INTERACTIVE_JOBS] = PA; + pb[BATCH_JOBS] = pb[INTERACTIVE_JOBS] = PB; - aarr[BATCH] = aarr[INTERACTIVE] = AARR * ARAR; - barr[BATCH] = barr[INTERACTIVE] = BARR; - anum[BATCH] = anum[INTERACTIVE] = ANUM; - bnum[BATCH] = bnum[INTERACTIVE] = BNUM; + aarr[BATCH_JOBS] = aarr[INTERACTIVE_JOBS] = AARR * ARAR; + barr[BATCH_JOBS] = barr[INTERACTIVE_JOBS] = BARR; + anum[BATCH_JOBS] = anum[INTERACTIVE_JOBS] = ANUM; + bnum[BATCH_JOBS] = bnum[INTERACTIVE_JOBS] = BNUM; } if ( ! useJobType_ ) // make all jobs batch - timeFromBegin_[INTERACTIVE] = Long.MAX_VALUE; + timeFromBegin_[INTERACTIVE_JOBS] = Long.MAX_VALUE; } /** @@ -519,20 +521,34 @@ * @param prob the probability * @return <tt>true</tt> if the probability has been set, or * <tt>false</tt> otherwise. - * @see #INTERACTIVE - * @see #BATCH + * @see #INTERACTIVE_JOBS + * @see #BATCH_JOBS */ public boolean setSerialProbability(int jobType, double prob) { - if(jobType > BATCH || jobType < INTERACTIVE) + if(jobType > BATCH_JOBS || jobType < INTERACTIVE_JOBS) return false; if(useJobType_) serialProb[jobType] = prob; else - serialProb[INTERACTIVE] = serialProb[BATCH] = prob; + serialProb[INTERACTIVE_JOBS] = serialProb[BATCH_JOBS] = prob; return true; } + + /** + * Gets the probability for serial jobs + * @param jobType the type of jobs + * @returns prob the probability; <tt>-1</tt> if an error occurs. + * @see #INTERACTIVE_JOBS + * @see #BATCH_JOBS + */ + public double getSerialProbability(int jobType) { + if(jobType > BATCH_JOBS || jobType < INTERACTIVE_JOBS) + return UNKNOWN; + + return serialProb[jobType]; + } /** * Sets the probability for power of two jobs @@ -540,20 +556,34 @@ * @param prob the probability * @return <tt>true</tt> if the probability has been set, or * <tt>false</tt> otherwise. - * @see #INTERACTIVE - * @see #BATCH + * @see #INTERACTIVE_JOBS + * @see #BATCH_JOBS */ public boolean setPower2Probability(int jobType, double prob) { - if(jobType > BATCH || jobType < INTERACTIVE) + if(jobType > BATCH_JOBS || jobType < INTERACTIVE_JOBS) return false; if(useJobType_) pow2Prob[jobType] = prob; else - pow2Prob[INTERACTIVE] = pow2Prob[BATCH] = prob; + pow2Prob[INTERACTIVE_JOBS] = pow2Prob[BATCH_JOBS] = prob; return true; } + + /** + * Gets the probability for power of two jobs + * @param jobType the type of jobs + * @returns prob the probability; <tt>-1</tt> if an error occurs. + * @see #INTERACTIVE_JOBS + * @see #BATCH_JOBS + */ + public double getPower2Probability(int jobType) { + if(jobType > BATCH_JOBS || jobType < INTERACTIVE_JOBS) + return UNKNOWN; + + return pow2Prob[jobType]; + } /** * Sets the parameters for the two-stage-uniform @@ -565,13 +595,13 @@ * @param uHi is the log2 of the maximal size of a job in the system (system's size) * @param uProb should be in [0.7 - 0.95] * @return <tt>true</tt> if the probabilities have been set, or - * <tt>false</tt> otherwise.b2 - * @see #INTERACTIVE - * @see #BATCH + * <tt>false</tt> otherwise. + * @see #INTERACTIVE_JOBS + * @see #BATCH_JOBS */ public boolean setParallelJobProbabilities(int jobType, double uLow, double uMed, double uHi, double uProb) { - if(jobType > BATCH || jobType < INTERACTIVE) + if(jobType > BATCH_JOBS || jobType < INTERACTIVE_JOBS) return false; else if (uLow > uHi) return false; @@ -587,16 +617,74 @@ this.uProb[jobType] = uProb; } else { - this.uLow[INTERACTIVE] = this.uLow[BATCH] = uLow; - this.uMed[INTERACTIVE] = this.uMed[BATCH] = uMed; - this.uHi[INTERACTIVE] = this.uHi[BATCH] = uHi; - this.uProb[INTERACTIVE] = this.uProb[BATCH] = uProb; + this.uLow[INTERACTIVE_JOBS] = this.uLow[BATCH_JOBS] = uLow; + this.uMed[INTERACTIVE_JOBS] = this.uMed[BATCH_JOBS] = uMed; + this.uHi[INTERACTIVE_JOBS] = this.uHi[BATCH_JOBS] = uHi; + this.uProb[INTERACTIVE_JOBS] = this.uProb[BATCH_JOBS] = uProb; } return true; } - /** Sets the parameters for the running time + /** + * Gets the probability of the job being a parallel job + * @return the value of uProb; <tt>-1</tt> if an error occurs. + * @see #INTERACTIVE_JOBS + * @see #BATCH_JOBS + */ + public double getParallelJobUProb(int jobType) { + if(jobType > BATCH_JOBS || jobType < INTERACTIVE_JOBS) + return UNKNOWN; + + return uProb[jobType]; + } + + /** + * Gets the log2 of the maximal size of a job in the system (system's size) + * @param jobType the type of jobs + * @return the value of uHi; <tt>-1</tt> if an error occurs. + * @see #INTERACTIVE_JOBS + * @see #BATCH_JOBS + */ + public double getParallelJobUHi(int jobType) { + if(jobType > BATCH_JOBS || jobType < INTERACTIVE_JOBS) + return UNKNOWN; + + return uHi[jobType]; + } + + /** + * Gets the medium size of parallel jobs in the system. It is log2 of + * the size. + * @param jobType the type of jobs + * @return the value of uMed; <tt>-1</tt> if an error occurs. + * @see #INTERACTIVE_JOBS + * @see #BATCH_JOBS + */ + public double getParallelJobUMed(int jobType) { + if(jobType > BATCH_JOBS || jobType < INTERACTIVE_JOBS) + return UNKNOWN; + + return uMed[jobType]; + } + + /** + * Gets the the log2 of the minimal size of job in the system (you can add or + * subtract 0.2 to give less/more probability to the minimal size). + * @param jobType the type of jobs + * @return the value of uLow; <tt>-1</tt> if an error occurs. + * @see #INTERACTIVE_JOBS + * @see #BATCH_JOBS + */ + public double getParallelJobULow(int jobType) { + if(jobType > BATCH_JOBS || jobType < INTERACTIVE_JOBS) + return UNKNOWN; + + return uLow[jobType]; + } + + /** + * Sets the parameters for the running time * The running time is computed using hyper-gamma distribution. * The parameters a1,b1,a2,b2 are the parameters of the two gamma distributions * The p parameter of the hyper-gamma distribution is calculated as a straight @@ -615,7 +703,7 @@ public boolean setRunTimeParameters(int jobType, double a1, double a2, double b1, double b2, double pa, double pb) { - if(jobType > BATCH || jobType < INTERACTIVE) + if(jobType > BATCH_JOBS || jobType < INTERACTIVE_JOBS) return false; if(useJobType_) { @@ -624,17 +712,40 @@ this.pa[jobType] = pa; this.pb[jobType] = pb; } else { - this.a1[INTERACTIVE] = this.a1[BATCH] = a1; - this.b1[INTERACTIVE] = this.a1[BATCH] = b1; - this.a2[INTERACTIVE] = this.a1[BATCH] = a2; - this.b2[INTERACTIVE] = this.a1[BATCH] = b2; - this.pa[INTERACTIVE] = this.a1[BATCH] = pa; - this.pb[INTERACTIVE] = this.a1[BATCH] = pb; + this.a1[INTERACTIVE_JOBS] = this.a1[BATCH_JOBS] = a1; + this.b1[INTERACTIVE_JOBS] = this.a1[BATCH_JOBS] = b1; + this.a2[INTERACTIVE_JOBS] = this.a1[BATCH_JOBS] = a2; + this.b2[INTERACTIVE_JOBS] = this.a1[BATCH_JOBS] = b2; + this.pa[INTERACTIVE_JOBS] = this.a1[BATCH_JOBS] = pa; + this.pb[INTERACTIVE_JOBS] = this.a1[BATCH_JOBS] = pb; } return true; } + /** + * Gets the runtime parameters. That is, it returns the parameters + * used for the hyper-gamma distribution. For more detail on the + * parameters, please check the paper that describes the model. + * @param jobType the type of jobs + * @return an array where: <br> + * array[0] = a1 - hyper-gamma distribution parameter. <br> + * array[1] = a2 - hyper-gamma distribution parameter. <br> + * array[2] = b1 - hyper-gamma distribution parameter. <br> + * array[3] = b2 - hyper-gamma distribution parameter. <br> + * array[4] = pa - hyper-gamma distribution parameter. <br> + * array[5] = pb - hyper-gamma distribution parameter. <br> + * The method will return <tt>null</tt> if an error occurs. + */ + public double[] getRunTimeParameters(int jobType) { + if(jobType > BATCH_JOBS || jobType < INTERACTIVE_JOBS) + return null; + + return new double[] { this.a1[jobType], this.a2[jobType], + this.b1[jobType], this.b2[jobType], + this.pa[jobType], this.pb[jobType]}; + } + /** * Sets the parameters for the inter-arrival time * The inter-arriving time is calculated using two gamma distributions. @@ -644,12 +755,12 @@ * arrived at each time interval (bucket). * The inter-arrival time is calculated using both gammas * Since gamma(aarr,barr) represents the arrive-time at the rush time , we use - * a constant ,ARAR (Arrive-Rush-All-Ratio), to set the alpha parameter (the new + * a constant, ARAR (Arrive-Rush-All-Ratio), to set the alpha parameter (the new * aarr) so it will represent the arrive-time at all hours of the day. */ public boolean setInterArrivalTimeParameters(int jobType, double aarr, double barr, double anum, double bnum, double arar) { - if(jobType > BATCH || jobType < INTERACTIVE) + if(jobType > BATCH_JOBS || jobType < INTERACTIVE_JOBS) return false; if(useJobType_) { @@ -659,16 +770,44 @@ this.bnum[jobType] = bnum; } else { - this.aarr[INTERACTIVE] = this.aarr[BATCH] = aarr * arar; - this.barr[INTERACTIVE] = this.barr[BATCH] = barr; - this.anum[INTERACTIVE] = this.barr[BATCH] = anum; - this.bnum[INTERACTIVE] = this.barr[BATCH] = bnum; + this.aarr[INTERACTIVE_JOBS] = this.aarr[BATCH_JOBS] = aarr * arar; + this.barr[INTERACTIVE_JOBS] = this.barr[BATCH_JOBS] = barr; + this.anum[INTERACTIVE_JOBS] = this.barr[BATCH_JOBS] = anum; + this.bnum[INTERACTIVE_JOBS] = this.barr[BATCH_JOBS] = bnum; } return true; } /** + * Returns the parameters for the inter-arrival time + * The inter-arriving time is calculated using two gamma distributions. + * gamma(aarr,barr) represents the inter_arrival time for the rush hours. It is + * independent on the hour the job arrived at. + * The cdf of gamma(bnum,anum) represents the proportion of number of jobs which + * arrived at each time interval (bucket). + * The inter-arrival time is calculated using both gammas + * Since gamma(aarr,barr) represents the arrive-time at the rush time , we use + * a constant, ARAR (Arrive-Rush-All-Ratio), to set the alpha parameter (the new + * aarr) so it will represent the arrive-time at all hours of the day. + * @param jobType the type of jobs + * @return an array where: <br> + * array[0] = aarr - gamma distribution parameter. <br> + * array[1] = barr - gamma distribution parameter. <br> + * array[2] = anum - gamma distribution parameter. <br> + * array[3] = bnum - gamma distribution parameter. <br> + * The method will return <tt>null</tt> if an error occurs. + */ + public double[] getInterArrivalTimeParameters(int jobType) { + + if(jobType > BATCH_JOBS || jobType < INTERACTIVE_JOBS) + return null; + + return new double[] { this.aarr[jobType], this.barr[jobType], + this.anum[jobType], this.bnum[jobType]}; + } + + /** * Sets the maximum number of jobs to be generated by this workload model * @param numJobs the number of jobs * @returns <tt>true</tt> if the number of jobs has been set; @@ -699,6 +838,27 @@ } /** + * Gets the hour of the day when the simulation should start + * @return the start hour (between 0 and 23) + */ + public int getStartHour() { + return start_; + } + + /** + * Sets the hour of the day when the simulation should start + * @param start the start hour to set (between 0 and 23) + * @return <tt>true</tt> if set; <tt>false</tt> otherwise. + */ + public boolean setStartHour(int start) { + if(start < 0 || start > 23) + return false; + + start_ = start; + return false; + } + + /** * Sets a Gridlet file size (in byte) for sending to/from a resource. * @param size a Gridlet file size (in byte) * @return <tt>true</tt> if it is successful, <tt>false</tt> otherwise @@ -883,13 +1043,13 @@ */ private boolean createGridlets() { - int type = INTERACTIVE; + int type = INTERACTIVE_JOBS; int nodes; long arrTime; int runTime; arrivalInit(aarr, barr, anum, bnum, START, weights); for (int i=0; i<numJobs_; i++) { - long[] info = arrive(type, weights, aarr, barr); + long[] info = getNextArrival(type, weights, aarr, barr); type = (int)info[0]; arrTime = (long)info[1]; @@ -909,9 +1069,6 @@ return true; } - /*----------------------------------------------------------------------------*/ - /* CALC_NUMBER_OF_NODES (NUMBER OF NODES) */ - /* -------------------------------------------------------------------------- */ /* * we distinguish between serial jobs , power2 jobs and other. * for serial job (with probability SerialProb) the number of nodes is 1 @@ -936,12 +1093,8 @@ return (int)(Math.pow(2, par) + 0.5); // return round(2^par) } - /*----------------------------------------------------------------------------*/ - /* TIMES_FROM_NODES (RUNTIME) */ - /* -------------------------------------------------------------------------- */ - /* - * time_from_nodes returns a value of a random number from hyper_gamma - * distribution. + /* + * timeFromNodes returns a value of a random number from hyperGamma distribution. * The a1,b1,a2,b2 are the parameters of both gammas. * The 'p' parameter is calculated from the 'nodes' 'pa' and 'pb' arguments * using the formula: p = pa * nodes + pb. @@ -966,9 +1119,9 @@ return (long)Math.exp(hg); } - /* The arrive process. - * 'arrive' returns arrival time (from the beginning of the simulation) of - * the current job. + /* Initialises the variables for the arrival process. + * 'getNextArrival' returns arrival time (from the beginning of + * the simulation) of the current job. * The (gamma distribution) parameters 'aarr' and 'barr' represent the * inter-arrival time at rush hours. * The (gamma distribution) parameters 'anum' and 'bnum' represent the number @@ -980,7 +1133,7 @@ * TOO_MUCH_ARRIVE_TIME) then another value is chosen. * * The algorithm (briefly): - * A. Preparations (calculated only once in 'arrive_init()': + * A. Preparations (calculated only once in 'arrivalInit()': * 1. foreach time interval (bucket) calculate its proportion of the number * of arriving jobs (using 'anum' and 'bnum'). This value will be the * bucket's points. @@ -988,12 +1141,12 @@ * 3. divide the points in each bucket by the points mean ("normalize" the * points in all buckets) * B. randomly choosing a new arrival time for a job: - * 1. get a random value from distribution gamma(aarr , barr). + * 1. get a random value from distribution gamma(aarr, barr). * 2. calculate the points we have. * 3. accumulate inter-arrival time by passing buckets (while paying them * points for that) until we do not have enough points. * 4. handle reminders - add the new reminder and subtract the old reminder. - * 5. update the time variables ('current' and 'time_from_begin') + * 5. update the time variables ('current_' and 'timeFromBegin_') */ private void arrivalInit(double[] aarr, double[] barr, double[] anum, double[] bnum, int start_hour, double weights[][]) { @@ -1005,7 +1158,7 @@ for(int j=0; j<weights[i].length; j++) weights[i][j] = 0; - current_[BATCH] = current_[INTERACTIVE] = start_hour * BUCKETS / HOURS_IN_DAY; + current_[BATCH_JOBS] = current_[INTERACTIVE_JOBS] = start_hour * BUCKETS / HOURS_IN_DAY; /* * for both batch and interactive calculate the propotion of each bucket , @@ -1025,12 +1178,12 @@ for (int i=0 ; i<BUCKETS ; i++) weights[j][i] /= mean[j]; - calcNextArrival(BATCH ,weights,aarr,barr); - calcNextArrival(INTERACTIVE,weights,aarr,barr); + calcNextArrival(BATCH_JOBS ,weights,aarr,barr); + calcNextArrival(INTERACTIVE_JOBS,weights,aarr,barr); } /* - * 'calcNextArrival' calculates the next inter-arrival time according + * calcNextArrival calculates the next inter-arrival time according * to the current time of the day. * 'type' is the type of the next job -- interactive or batch * alpha and barr are the parameters of the gamma distribution of the @@ -1068,20 +1221,22 @@ current_[type] = bucket; } - /*----------------------------------------------------------------------------*/ - /* ARRIVE (ARRIVAL TIME AND TYPE) */ - /*----------------------------------------------------------------------------*/ - /* - * return the time for next job to arrive the system. - * returns also the type of the next job , which is the type that its - * next arrive time (time_from_begin) is closer to the start (smaller). - * notice that since calc_next_arrive changes time_from_begin[] we must save - * the time_from_begin in 'res' so we would be able to return it. - */ - private long[] arrive(int type, double[][] weights, double[] aarr, double[] barr) { + /* + * Return the time for next job to arrive the system. + * returns also the type of the next job , which is the type that its + * next arrive time (time_from_begin) is closer to the start (smaller). + * notice that since calc_next_arrive changes time_from_begin[] we must save + * the time_from_begin in 'res' so we would be able to return it. + * @returns an array where array[0] = type of the job, array[1] = arrival time + */ + private long[] getNextArrival(int type, double[][] weights, + double[] aarr, double[] barr) { + long res; - type = (timeFromBegin_[BATCH] < timeFromBegin_[INTERACTIVE]) ? BATCH : INTERACTIVE; + type = (timeFromBegin_[BATCH_JOBS] < timeFromBegin_[INTERACTIVE_JOBS]) ? + BATCH_JOBS : INTERACTIVE_JOBS; + res = timeFromBegin_[type]; // save the job's arrival time // randomly choose the next job's (of the same type) arrival time @@ -1102,11 +1257,12 @@ * @pre numProc > 0 * @post $none */ - protected void submitGridlet(int id, long submitTime, int runTime, int numProc) - { + protected void submitGridlet(int id, long submitTime, + int runTime, int numProc) { // create the gridlet int len = runTime * rating_; // calculate a job length for each PE - Gridlet gl = new Gridlet(id, len, size_, size_, GridSim.isTraceEnabled()); + Gridlet gl = new Gridlet(id, len, size_, + size_, GridSim.isTraceEnabled()); gl.setUserID( super.get_id() ); // set the owner ID gl.setNumPE(numProc); // set the requested num of proc @@ -1131,26 +1287,29 @@ // --- Methods required by the distributions used by the workload model --- + // --- Most of these methods were ported from C to Java, but the logic --- + // --- remains the same as in Lublin's workload model in C --- /* - * hyper_gamma returns a value of a random variable of mixture of two + * hyperGamma returns a value of a random variable of mixture of two * gammas. its parameters are those of the two gammas: a1,b1,a2,b2 and the * relation between the gammas (p = the probability of the first gamma). we * first randomly decide which gamma will be active ((a1,b1) or (a2,b2)). * then we randomly choose a number from the chosen gamma distribution. */ - double hyperGamma(double a1, double b1, double a2, double b2, double p) { + private double hyperGamma(double a1, double b1, double a2, + double b2, double p) { double a, b, hg, u = random_.nextDouble(); - if (u <= p) { /* gamma(a1,b1) */ + if (u <= p) { // gamma(a1,b1) a = a1; b = b1; - } else { /* gamma(a2,b2) */ + } else { // gamma(a2,b2) a = a2; b = b2; } - /* generate a value of a random variable from distribution gamma(a,b) */ + // generates a value of a random variable from distribution gamma(a,b) hg = gamrnd(a, b); return hg; } @@ -1177,7 +1336,7 @@ } /* - * gamrnd_int_alpha returns a value of a random variable of gamma(n,beta) + * gamrndIntAlpha returns a value of a random variable of gamma(n,beta) * distribution where n is integer(unsigned long actually). gamma(n,beta) == * beta*gamma(n,1) == beta* sum(1..n){gamma(1,1)} == beta* sum(1..n){exp(1)} == * beta* sum(1..n){-ln(uniform(0,1))} @@ -1185,28 +1344,27 @@ private double gamrndIntAlpha(long n, double beta) { double acc = 0; for (int i = 0; i < n; i++) - acc += Math.log(random_.nextDouble()); /* sum the exponential - * random variables - */ + acc += Math.log(random_.nextDouble()); // sum the exponential + // random variables return (-acc * beta); } /* - * gamrnd_alpha_smaller_1 returns a value of a random variable of + * gamrndAlphaSmaller1 returns a value of a random variable of * gamma(alpha,beta) where alpha is smaller than 1. This is done using the * Beta distribution. (alpha<1) ==> (1-alpha<1) ==> we can use * beta_less_1(alpha,1-alpha) gamma(alpha,beta) = exponential(beta) * * Beta(alpha,1-alpha) */ private double gamrndAlphaSmaller1(double alpha, double beta) { - double x = betarndLess1(alpha, 1 - alpha); /* beta random variable */ - double y = -Math.log(random_.nextDouble()); /* exponential random - * variable */ + double x = betarndLess1(alpha, 1 - alpha); // beta random variable + double y = -Math.log(random_.nextDouble()); // exponential random + // variable return (beta * x * y); } /* - * betarnd_less_1 returns a value of a random variable of beta(alpha,beta) + * betarndLess1 returns a value of a random variable of beta(alpha,beta) * distribution where both alpha and beta are smaller than 1 (and larger * than 0) */ @@ -1237,13 +1395,14 @@ return gser(x, alpha); } - /* x >= a+1 */ + // x >= a+1 return 1 - gcf(x, alpha); } - /*----------------------------------------------------------------------------*/ - /* GSER */ - /*----------------------------------------------------------------------------*/ + + /* + * Gser + */ private double gser(double x, double a) { int i; double sum, monom, aa = a; @@ -1255,14 +1414,15 @@ monom *= (x / aa); sum += monom; if (monom < sum * EPS) - return (sum * Math.exp(-x + a * Math.log(x) - lgamma(a))); + return (sum * Math.exp(-x + a * Math.log(x) - logGamma(a))); } - return -1; /* error did not converged */ + return -1; // error, did not converged } - /*----------------------------------------------------------------------------*/ - /* GCF */ - /*----------------------------------------------------------------------------*/ + + /* + * Returns the GCF + */ private double gcf(double x, double a) { int i; double gold = 0, g, a0 = 1, a1 = x, b0 = 0, b1 = 1, fac = 1, anf, ana; @@ -1278,11 +1438,11 @@ fac = 1 / a1; g = b1 * fac; if (Math.abs((g - gold) / g) < EPS) - return (g * Math.exp(-x + a * Math.log(x) - lgamma(a))); + return (g * Math.exp(-x + a * Math.log(x) - logGamma(a))); gold = g; } } - return 2; /* gamcdf will return -1 */ + return 2; // gamcdf will return -1 } /* @@ -1296,15 +1456,15 @@ double hi, double prob) { double a, b, tsu, u = random_.nextDouble(); - if (u <= prob) { /* uniform(low , med) */ + if (u <= prob) { // uniform(low , med) a = low; b = med; - } else { /* uniform(med , hi) */ + } else { // uniform(med , hi) a = med; b = hi; } - /* generate a value of a random variable from distribution uniform(a,b) */ + // generate a value of a random variable from distribution uniform(a,b) tsu = (random_.nextDouble() * (b - a)) + a; return tsu; } @@ -1316,7 +1476,7 @@ * Direct inquiries to 30 Frost Street, Cambridge, MA 02140 */ - static private double lgamma(double x) + static private double logGamma(double x) throws ArithmeticException { double p, q, w, z; @@ -1344,7 +1504,7 @@ if (x < -34.0) { q = -x; - w = lgamma(q); + w = logGamma(q); p = Math.floor(q); if (p == q) throw new ArithmeticException("lgamma: Overflow"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |