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

📄 jabamodel.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.gui.jaba;

import jmt.gui.exact.utils.ArrayUtils;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import java.util.Arrays;
import java.util.Vector;

/**
 * An object grouping all the data describing a system.
 * <br><br>
 * WARNING:
 * ACCESS TO THIS OBJECT MUST BE IMPLEMENTED IN A TRANSACTION-LIKE SYNCHRONIZED WAY!
 *
 * @author alyf (Andrea Conti), Stefano Omini, Bertoli Marco
 */
public class JabaModel implements JabaConstants {

    //true if the model is closed
    private boolean closed;
    //true if the model is open
    private boolean open;
    //true if the model contains load dependent stations
    private boolean ld;

    //true if visits are set (otherwise they will be all unitary)
    private boolean unitaryVisits;

    //true if the model has been modified
    private boolean changed;
    //true if results are available
    private boolean hasResults;
    //true if the results are valid (no modify has been made in the model after results computation)
    private boolean resultsOK;
    //description of the model
    private String description;

    /***********************STATIONS AND CLASSES******************************/

    //number of service centers
    private int stations;
    //number of classes
    private int classes;
    //total population (computed as the sum of all closed class populations)
    private int maxpop;

    //class data is class population for closed classes, class arrival rate for open classes
    //dim: classData[classes]
    private double[] classData;
    //station names
    //dim: stationNames[stations]
    private String[] stationNames;
    //station types
    //dim: stationTypes[stations]
    private int[] stationTypes;
    //class names
    //dim: classNames[classes]
    private String[] classNames;
    //class types
    //dim: classTypes[classes]
    private int[] classTypes;

    /***********************SERVICE PARAMETERS**************************/

    /**
     * visits to the service centers
     * dim: visits[stations][classes]
     */
    private double[][] visits;
    /**
     * service times of the service centers
     * dim: serviceTimes[stations][classes][p]
     * p=maxpop     if stationTypes[s]==STATION_LD
     * p=1          otherwise
     */
    private double[][][] serviceTimes;

    /***********************RESULTS******************************/

    /**
     * queue lengths
     * dim: queueLen[stations][classes+1]
     */
    private double[][] queueLen;

    /**
     * throughput
     * dim: throughput[stations+1][classes+1]
     */
    private double[][] throughput;

    /**
     * residence times
     * dim: resTime[stations+1][classes+1]
     */
    private double[][] resTimes;

    /**
     * utilization
     * dim: util[stations][classes+1]
     */
    private double[][] util;

    private Vector res;


    /*****************************************************************/
    //parameters for randomization
    private static final double MAXRAND=100;
    //todo controllare che MAXRANGE=1 sia ok
    private static final double MAXRANGE=1;

    /*****************************************************************/


    /**
     * make an object with default values
     */
    public JabaModel() {
        setDefaults();
    }

    /**
     * copy constructor
     */
    public JabaModel(JabaModel e) {
        closed = e.closed;
        open = e.open;
        hasResults = e.hasResults;
        resultsOK = e.resultsOK;
        changed = e.changed;

        stations = e.stations;
        classes = e.classes;
        maxpop = e.maxpop;

        description = e.description;
        unitaryVisits = e.unitaryVisits;

        stationNames = ArrayUtils.copy(e.stationNames);
        stationTypes = ArrayUtils.copy(e.stationTypes);

        classNames = ArrayUtils.copy(e.classNames);
        classTypes = ArrayUtils.copy(e.classTypes);
        classData = ArrayUtils.copy(e.classData);

        visits = ArrayUtils.copy2(e.visits);

        serviceTimes = ArrayUtils.copy3(e.serviceTimes);

        if (hasResults) {
            // Zanzottera
            res=e.res;
        }
    }

    /**
     * Clears all the results
     */
    public void discardResults() {
        hasResults = false;
        resultsOK = false;
        queueLen = null;
        throughput = null;
        resTimes = null;
        util = null;
        changed = true;
        // Zanzottera
        res=null;
    }

    /**
     * sets all the result data for this model.
     */
    public void setResults(Vector res)
    {
        this.res = res;
        hasResults = true;
        resultsOK = true;
        changed = true;
    }

    public Vector getResults()
    {
        return res;
    }

    /**
     * Initialize the object with defaults:
     * 1 closed class, 1 LI station, 0 customers, all visits to one, all service times to zero, no results
     */
    public void setDefaults() {
        closed = true;
        hasResults = false;
        resultsOK = false;
        stations = 1;
        // NEW minimum classes = 2
        classes = 2;

        //TODO: perch

⌨️ 快捷键说明

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