gridsimrandom.java
来自「一个非常著名的网格模拟器,能够运行网格调度算法!」· Java 代码 · 共 555 行 · 第 1/2 页
JAVA
555 行
* @pre factor >= 0.0 * @post $none */ public static void set_less_factor_e(double factor) { setLessFactorExec(factor); } /** * Sets the less factor of Execution * @param factor the initial factor * @throws IllegalArgumentException factor is not zero or positive * @pre factor >= 0.0 * @post $none */ public static void setLessFactorExec(double factor) throws IllegalArgumentException { if (factor < MIN_VALUE) { throw new IllegalArgumentException( "GridSimRandom.setLessFactorExec() : Error - factor must" + " be zero or positive value."); } lessFactorExec_ = factor; } /** * Sets the more factor of Execution * @param factor the initial factor * @throws IllegalArgumentException factor is not zero or positive * @deprecated As of GridSim 2.1, replaced by * {@link #setMoreFactorExec(double)} * @pre factor >= 0.0 * @post $none */ public static void set_more_factor_e(double factor) { setMoreFactorExec(factor); } /** * Sets the more factor of Execution * @param factor the initial factor * @throws IllegalArgumentException factor is not zero or positive * @pre factor >= 0.0 * @post $none */ public static void setMoreFactorExec(double factor) throws IllegalArgumentException { if (factor < MIN_VALUE) { throw new IllegalArgumentException( "GridSimRandom.setMoreFactorExec() : Error - factor must" + " be zero or positive value."); } moreFactorExec_ = factor; } /** * Gets the average factor of Network I/O * @return factor of Network I/O * @deprecated As of GridSim 2.1, replaced by {@link #getFactorIO()} * @pre $none * @post $result >= 0.0 */ public static double get_factor_io() { return getFactorIO(); } /** * Gets the average factor of Network I/O * @return factor of Network I/O * @pre $none * @post $result >= 0.0 */ public static double getFactorIO() { return (moreFactorIO_ - lessFactorIO_) / 2; } /** * Gets the average factor of Execution * @return factor of Execution * @deprecated As of GridSim 2.1, replaced by {@link #getFactorExec()} * @pre $none * @post $result >= 0.0 */ public static double get_factor_e() { return getFactorExec(); } /** * Gets the average factor of Execution * @return factor of Execution * @pre $none * @post $result >= 0.0 */ public static double getFactorExec() { return (moreFactorExec_ - lessFactorExec_) / 2; } /** * Maps the predicted or estimated <tt>value</tt> to a random real-world * number between <tt>(1 - lessFactor) * value</tt> and * <tt>(1 + moreFactor) * value</tt>. * <p> * <b>The formula used is:</b> * <br> * <tt>value * (1 - lessFactor + (lessFactor + moreFactor) * * randDouble)</tt> * <br> * where 0.0 <= lessFactor and moreFactor <= 1.0 * @param value the estimated value * @param lessFactor less factor for a value * @param moreFactor more factor for a value (the range is between 0.0 * and 1.0) * @param randDouble an uniformly distributed <tt>double</tt> value * between 0.0 and 1.0 * @return the real number in <tt>double</tt> * @throws IllegalArgumentException <tt>value</tt>, <tt>lessFactor</tt>, * <tt>moreFactor</tt> and <tt>randDouble</tt> are not zero * or positive. In addition, the max. number for * <tt>moreFactor</tt> and <tt>randDouble</tt> is 1.0 * @pre value >= 0.0 * @pre lessFactor >= 0.0 * @pre moreFactor >= 0.0 && moreFactor <= 1.0 * @pre randDouble >= 0.0 && randDouble <= 1.0 * @post $none */ public static double real(double value, double lessFactor, double moreFactor, double randDouble) throws IllegalArgumentException { String errorMsg = "GridSimRandom.real(): Error - "; if (value < MIN_VALUE) { throw new IllegalArgumentException(errorMsg + "value must be zero or positive value."); } if (lessFactor < MIN_VALUE) { throw new IllegalArgumentException(errorMsg + "lessFactor must be zero or positive value."); } if (moreFactor < MIN_VALUE || moreFactor > MAX_VALUE) { throw new IllegalArgumentException(errorMsg + "moreFactor must be within [0.0, 1.0]."); } if (randDouble < MIN_VALUE || randDouble > MAX_VALUE) { throw new IllegalArgumentException(errorMsg + "randDouble must be within [0.0, 1.0]."); } double result = value * (MAX_VALUE - lessFactor + (lessFactor + moreFactor) * randDouble); return result; } /** * Gets the real number from the factors of Network I/O * @param value the estimated value * @return the real number in <tt>double</tt> * @throws IllegalArgumentException value is not zero or positive * @deprecated As of GridSim 2.1, replaced by {@link #realIO(double)} * @pre value >= 0.0 * @post $none */ public static double real_io(double value) throws IllegalArgumentException { return realIO(value); } /** * Gets the real number from the factors of Network I/O * @param value the estimated value * @return the real number in <tt>double</tt> * @throws IllegalArgumentException value is not zero or positive * @pre value >= 0.0 * @post $none */ public static double realIO(double value) throws IllegalArgumentException { return real( value, lessFactorIO_, moreFactorIO_, doubleSample() ); } /** * Gets the real number from the factors of Execution * @param value the estimated value * @return the real number in <tt>double</tt> * @throws IllegalArgumentException factor is not zero or positive * @deprecated As of GridSim 2.1, replaced by {@link #realExec(double)} * @pre value >= 0.0 * @post $none */ public static double real_e(double value) throws IllegalArgumentException { return realExec(value); } /** * Gets the real number from the factors of Execution * @param value the estimated value * @return the real number in <tt>double</tt> * @throws IllegalArgumentException factor is not zero or positive * @pre value >= 0.0 * @post $none */ public static double realExec(double value) throws IllegalArgumentException { return real( value, lessFactorExec_, moreFactorExec_, doubleSample() ); } /** * Gets the expected factor of Network I/O * @param value the estimated value * @return the expected number in <tt>double</tt> * @throws IllegalArgumentException factor is not zero or positive * @deprecated As of GridSim 2.1, replaced by {@link #expectedIO(double)} * @pre value >= 0.0 * @post $none */ public static double expected_io(double value) throws IllegalArgumentException { return expectedIO(value); } /** * Gets the expected factor of Network I/O * @param value the estimated value * @return the expected number in <tt>double</tt> * @throws IllegalArgumentException factor is not zero or positive * @pre value >= 0.0 * @post $none */ public static double expectedIO(double value) throws IllegalArgumentException { return value * ( MAX_VALUE + getFactorIO() ); } /** * Gets the expected factor of Execution * @param value the estimated value * @return the expected number in <tt>double</tt> * @throws IllegalArgumentException factor is not zero or positive * @deprecated As of GridSim 2.1, replaced by {@link #expectedExec(double)} * @pre value >= 0.0 * @post $none */ public static double expected_e(double value) throws IllegalArgumentException { return expectedExec(value); } /** * Gets the expected factor of Execution * @param value the estimated value * @return the expected number in <tt>double</tt> * @throws IllegalArgumentException factor is not zero or positive * @pre value >= 0.0 * @post $none */ public static double expectedExec(double value) throws IllegalArgumentException { return value * ( MAX_VALUE + getFactorExec() ); }} // end class
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?