📄 solvermultimixed.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 model, with both open and closed classes.
* @author Federico Granata, Stefano Omini
*/
public class SolverMultiMixed extends SolverMulti {
//TODO aggiungere controllo su processing capacity (guardare solo le classi aperte)
//TODO: aggiungere calcolo del response time di ogni stazione
/** array with class types */
int[] classType;
/** matrix with service demands */
double[][] demands;
/** array describing the classes: each element can be either an
* arrival rate (for open classes) or a population (for closed ones),
* according to the class type */
double[] popPar;
/**
* Constructor
* @param classes number of classes
* @param stations number of stations
*/
public SolverMultiMixed(int classes, int stations) {
super(classes, stations);
demands = new double[stations][classes];
}
/** initializes the Multi class solver with the system parameters.
* @param n array of names of service centers.
* @param t array of the types (LD or LI) of service centers.
* @param s matrix of service time of the service centers.
* @param v matrix of visits to the service centers.
* @param popPar array describing the classes: each element can be either an
* arrival rate (for open classes) or a population (for closed ones),
* according to the class type
* @param classType array of class types (open or closed)
* @return true if the operation has been completed with success
*/
public boolean input(String[] n, int[] t, double[][][] s, double[][] v,
double[] popPar, int[] classType) {
if (super.input(n, t, s, v)) {
this.popPar = popPar;
this.classType = classType;
return true;
}
return false;
}
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();
//System.out.println(this);
} else {
System.out.println("Load dependent solver is not available for MultiMixed");
}
}
/**
* Solves the system.
* <br><br>
* See:
* <br>
* <em>
* E.D. Lazowska, J. Zahorjan, G.S. Graham, K. Sevcik<br>
* Quantitative System Performance,<br>
* Prentice Hall, 1984<br>
* </em>
*/
public void solveLI() {
//TODO: ci sono problemi nel caso di stazioni delay???!!!
//class parameters: population (for closed classes), arrival rate (for open classes)
int[] closedClasses;
double[] openClasses;
//take in consideraton the presence of the open classes only.
//we solve easily the problem as an open system.
//the new utilization will reduce the power of the system
//considering the effect of the open classes.
//then we solve the close system
for (int i = 0; i < stations; i++){
//NEW
//@author Stefano Omini
//initializes service center solution values
scUtilization[i] = 0;
scQueueLen[i] = 0;
scResidTime[i] = 0;
scThroughput[i] = 0;
//end NEW
for (int j = 0; j < classes; j++) {
demands[i][j] = visits[i][j] * servTime[i][j][0];
if (classType[j] == OPEN_CLASS) {
utilization[i][j] = demands[i][j] * popPar[j];
scUtilization[i] += utilization[i][j];
}
}
}
//counts open classes
int oCounter = 0;
for (int j = 0; j < classes; j++){
if (classType[j] == OPEN_CLASS){
oCounter++;
}
}
//counts closed classes
int cCounter = classes - oCounter;
//allocates an array with the appropriate size for each kind of class
openClasses = new double[oCounter];
closedClasses = new int[cCounter];
//fills the arrays containing only open parameters (i.e. lambda)
//and only closed parameters (i.e. population)
oCounter = 0;
cCounter = 0;
//TODO: non crea strutture analoghe anche per open,perch
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -