⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 solvermultiopen.java

📁 一个用于排队系统仿真的开源软件,有非常形象的图象仿真过程!
💻 JAVA
字号:
/**    
  * Copyright (C) 2006, Laboratorio di Valutazione delle Prestazioni - Politecnico di Milano

  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or
  * (at your option) any later version.

  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.

  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
  
package jmt.analytical;

/**
 * Solves a multiclass open model (LD stations are not allowed).
 * @author Federico Granata, Stefano Omini
 */
public class SolverMultiOpen extends SolverMulti {

	private double[] lambda;

	/**
     * Creates a SolverMultiOpen
     * @param classes number of classes
     * @param stations number of stations
     * @param lambda array of arrival rates
     */
    public SolverMultiOpen(int classes, int stations, double[] lambda) {
		super(classes, stations);
		this.lambda = lambda;
	}


   	/**
	 * Solves the model, using an appropriate technique (LI or LD model).
	 */
	public void solve() {
		//tests if all the resources, stations, are load independent
		boolean loadIndep = true;
		for (int i = 0; i < stations && loadIndep; i++) {
			if (type[i] == LD)
				loadIndep = false;
		}

		if (loadIndep) {
			solveLI();
		} else {
			solveLD();
		}
	}



    /**
     * Solves a model with only delay or load independent stations.
	 */
    private void solveLI() {

        //NEW
        //@author Stefano Omini

        //initializes array of aggregate values
        for (int j = 0; j < stations; j++) {
            scUtilization[j] = 0;
        }
        //end NEW


		for (int i = 0; i < classes; i++) {
			//throughput of class i
            clsThroughput[i] = lambda[i];
			for (int j = 0; j < stations; j++) {
                //throughput of class i for station j
				throughput[j][i] = lambda[i] * visits[j][i];
				//utilization of class i for station j
                utilization[j][i] = lambda[i] * visits[j][i] * servTime[j][i][0];
                //aggregate utilization for station j
				scUtilization[j] += utilization[j][i];

			}

		}

		for (int i = 0; i < classes; i++) {

            for (int j = 0; j < stations; j++) {
				if (type[j] == Solver.DELAY)
					//delay stations
                    //residence time of class i in station j
                    residenceTime[j][i] = visits[j][i] * servTime[j][i][0];
				else
                    //queueing stations
                    //residence time of class i in station j
					residenceTime[j][i] = visits[j][i] * servTime[j][i][0]
					        / (1 - scUtilization[j]);
				//queue length of class i for station j
                queueLen[j][i] = residenceTime[j][i] * lambda[i];
				//aggregate response time for class i
                clsRespTime[i] += residenceTime[j][i];

			}
		}

        //NEW
        //@author Stefano Omini

        for (int j = 0; j < stations; j++) {
            //initializes array of aggregate values
            scThroughput[j] = 0;
            scQueueLen[j] = 0;
            scResidTime[j] = 0;
        }

        //end NEW


        for (int j = 0; j < stations; j++) {

			for (int i = 0; i < classes; i++) {
				//aggregate throughput for station j
                scThroughput[j] += throughput[j][i];
                //aggregate queue length for station j
				scQueueLen[j] += queueLen[j][i];

                //aggregate residence time for station j

                //NEW
                //@author Stefano Omini

                //TODO visits[j][1] 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -