📄 modelchecker.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.common.controller;
import jmt.gui.common.CommonConstants;
import jmt.gui.common.definitions.ClassDefinition;
import jmt.gui.common.definitions.SimulationDefinition;
import jmt.gui.common.definitions.StationDefinition;
import jmt.gui.common.definitions.BlockingRegionDefinition;
import jmt.gui.common.definitions.parametric.ParametricAnalysisChecker;
import jmt.gui.common.definitions.parametric.ParametricAnalysisDefinition;
import jmt.gui.common.distributions.Distribution;
import jmt.gui.common.routingStrategies.ProbabilityRouting;
import jmt.gui.common.routingStrategies.RandomRouting;
import jmt.gui.common.routingStrategies.RoutingStrategy;
import jmt.gui.common.serviceStrategies.LDStrategy;
import java.util.HashMap;
import java.util.Vector;
import java.util.Iterator;
import java.util.Set;
/**
* <p>Title: ModelChecker</p>
* <p>Description: Checks the model correctness</p>
*
* @author Francesco D'Aquino
* Date: 6-ott-2005
* Time: 16.12.50
*
* @author Bertoli Marco
* (new errors)
*/
public class ModelChecker implements CommonConstants {
private ClassDefinition class_def;
private StationDefinition station_def;
private SimulationDefinition simulation_def;
private BlockingRegionDefinition blocking_def;
//sets the behavior of the checker
private boolean isToJMVAChecker;
//Variable that contains information about problems
private boolean[] errors;
//Variable that contains information about warnings
private boolean[] warnings;
//Vector containing the keys of the classes without a reference station
private Vector classesWithoutRefStation;
//Vector containing only the keys of the open classes without a reference station
private Vector openClassesWithoutRefStation;
//Vector containing the keys of the sources without a class associated to
private Vector sourceWithoutClasses;
//Vector containing the keys of stations with link problems
private Vector stationsWithLinkErrors;
// HashMap containing the vector of keys of the stations where
// routing problems for this close class occour. The key of the
// Hash Map is the key of the closed class considered
private HashMap routingErrors;
// HashMap containing the vector of keys of the stations reacheable by a close class
// The key of the Hash Map is the key of the closed class considered
private HashMap allForwardStationsAreSinkErrors;
//Vector containing the keys of measures defined more than once
private Vector redundantMeasure;
//Vector containing the inconsistent performance indexes
private Vector inconsistentMeasures;
//Vector containing the keys of servers with per class different
//queue startegies
private Vector BCMPserversWithDifferentQueueStrategy;
//Vector containing the keys of servers with FCFS queueing strategy
//but mixed types of service
private Vector BCMPserversWithDifferentServiceTypes;
//Vector containing the keys of servers with FCFS queue strategy
// but a non exponential distribution
private Vector BCMPserversFCFSWithoutExponential;
//Vector containing the keys of servers with FCFS, the same
//type of service for each class, but with different mean service
//times
private Vector BCMPFcfsServersWithDifferentServiceTimes;
//Vector containing the keys of delays with at least a service time
//distribution with a non rational Laplace transform
private Vector BCMPdelaysWithNonRationalServiceDistribution;
//Vector containing the keys of the stations where a non random routing is used.
//Used only in JMVA conversion
private Vector BCMPnonStateIndependentRoutingStations;
//Vector containing the stations (not Sinks or Sources) not backward connected. Used for
// warnings
private Vector stationWithoutBackwardLinks;
/** Empty blocking regions */
private Vector emptyBlockingRegions;
//Vector containing the keys of the stations with a queue strategy different from FCFS.
//Used only in JMVA conversion
//private Vector nonFCFSStations;
//constant used to define an error
public static int ERROR_PROBLEM = 0;
//constant used to define a warning
public static int WARNING_PROBLEM = 1;
//it occours when no classes have been defined
public static int NO_CLASSES_ERROR = 0;
//it occours when no station have been defined
public static int NO_STATION_ERROR = 1;
//it occours when no measure have been defined
public static int SIMULATION_ERROR = 2;
//it occours when there is a sink but no open classes have been defined
public static int SINK_BUT_NO_OPEN_CLASSES_ERROR = 3;
//it occours when there is an open class but no sources have been defined
public static int OPEN_CLASS_BUT_NO_SOURCE_ERROR = 4;
//it occours when no open classes have been associated to a source
public static int SOURCE_WITH_NO_OPEN_CLASSES_ERROR = 5;
//it occours when a class hasn't a reference station
public static int REFERENCE_STATION_ERROR = 6;
//it occours when there is an open class but no sinks have been defined
public static int NO_SINK_WITH_OPEN_CLASSES_ERROR = 7;
//it occours when a station is not properly linked
public static int STATION_LINK_ERROR = 8;
//it occours when a close class is routed with probability 1 into a sink
public static int ROUTING_ERROR = 9;
//it occours when a close class is routed into a station whose forward stations are all sinks
public static int ALL_FORWARD_STATION_ARE_SINK_ERROR = 10;
//it occours if the same measure is defined more than once
public static final int DUPLICATE_MEASURE_ERROR = 11;
//it occours if one or performance index has one or more null field
public static final int INCONSISTENT_MEASURE_ERROR = 12;
//It occours only when trying to switch from JSim or JModel to JMVA, if there is at least
//one open class without a reference station
//public static final int OPEN_CLASS_REFERENCE_STATION_ERROR = 13;
//it occours when there is at least one join but not a fork;
public static final int JOIN_WITHOUT_FORK_ERROR = 13;
//All jobs splitted by a fork must be routed to the same sink, or
//to the same join
public static final int FORK_JOIN_ROUTING_ERROR = 14;
/** Empty blocking region */
public static final int EMPTY_BLOCKING_REGION = 15;
/** Preloaded station in a blocking region */
public static final int PRELOADING_WITH_BLOCKING = 16;
//it occours when more than one sink have been defined
public static int MORE_THAN_ONE_SINK_WARNING = 0;
//it occours when a station (not sink or source) is not backward linked
public static int NO_BACKWARD_LINK_WARNING = 1;
//it occours if there is a fork but not a join
public static int FORK_WITHOUT_JOIN_WARNING = 2;
//It occours if the parametric analysis model has become inconsistent
//with the model definition. This warning advices user to recheck the
//parametric model definition, since it had been modified to make it
//consistent back again.
public static int PARAMETRIC_ANALYSIS_MODEL_MODIFIED_WARNING = 3;
//It occours if a no PA are avaible, but a PA model was previously defined
public static int PARAMETRIC_ANALYSIS_NO_MORE_AVAIBLE_WARNING = 4;
//It occours if the station has diffrent per class queueing
// strategy. (only when trying to convert to JMVA)
public static int BCMP_DIFFERENT_QUEUEING_STRATEGIES_WARNING = 5;
//It occours if the service policy inside a station with FCFS
//queueing strategy, differs from class to class. In fact,
//according to the BCMP theorem hypothesis, the service times
//in an FCFS station must be all load independent or independent,
//mixtures are not allowed
public static int BCMP_FCFS_DIFFERENT_SERVICE_TYPES_WARNING = 6;
//It occours if the station has a FCFS queueing strategy, but
//the service time distribution is not exponential
public static int BCMP_FCFS_EXPONENTIAL_WARNING = 7;
//It occours if the station has a FCFS queueing strategy, but
//the per class mean values of service time differ
// (only when trying to convert to JMVA)
public static int BCMP_FCFS_DIFFERENT_SERVICE_TIMES_WARNING = 8;
//It occours if the station has a Processor Sharing service strategy
//but it is not possible to define a Laplace rational transform
//for the service time distribution
// (only when trying to convert to JMVA)
public static int BCMP_PROCESSOR_SHARING_WARNING = 9;
//It occours if the station has a delay behavior but it is not
//possible to define a Laplace rational transform for a
//service time distribution
// (only when trying to convert to JMVA)
public static int BCMP_DELAY_WARNING = 10;
//It occours if the station has a LCFS - Preemptive Resume
//queueing strategy but it is not possible to define a
//Laplace rational transform for the service time distribution
// (only when trying to convert to JMVA)
public static int BCMP_LCFS_PR_WARNING = 11;
//It occours if the routing strategy is state dependent
// (only when trying to convert to JMVA)
public static int BCMP_NON_STATE_INDEPENDENT_ROUTING_WARNING = 12;
/*
//It occours only when trying to switch from JSim or JModel to JMVA, if there is at least
//one non exponential distribution
public static int NO_EXP_FOUND_WARNING = 2;
//it occours only when trying to convert to JMVA
public static int DIFFERENT_SERVICE_TIME_WARNING = 3;
//it occours only when trying to convert to JMVA
public static int NON_FCFS_WARNING = 4;
//it it occours only when trying to convert to JMVA
public static int NON_STATE_INDEPENDENT_ROUTING_WARNING = 5;
*/
private int NUMBER_OF_ERROR_TYPES = 17;
private int NUMBER_OF_NORMAL_ERROR_TYPES = 17;
private int NUMBER_OF_WARNING_TYPES = 13;
private int NUMBER_OF_NORMAL_WARNING_TYPES = 5;
/**
* Creates a new modelchecker
* @param class_def reference to class definition data structure
* @param station_def reference to station definition data structure
* @param simulation_def reference to simulation definition data structure
* @param bd reference to blocking region definition data structure
* @param isToJMVA true if model must be converted to jmva, false otherwise
*/
public ModelChecker(ClassDefinition class_def,
StationDefinition station_def, SimulationDefinition simulation_def,
BlockingRegionDefinition bd, boolean isToJMVA){
this.class_def = class_def;
this.station_def = station_def;
this.simulation_def = simulation_def;
this.blocking_def = bd;
errors = new boolean[NUMBER_OF_ERROR_TYPES];
warnings = new boolean[NUMBER_OF_WARNING_TYPES];
classesWithoutRefStation = new Vector(0,1);
openClassesWithoutRefStation = new Vector(0,1);
sourceWithoutClasses = new Vector(0,1);
stationsWithLinkErrors = new Vector(0,1);
routingErrors = new HashMap(0,1);
allForwardStationsAreSinkErrors = new HashMap(0,1);
stationWithoutBackwardLinks = new Vector(0,1);
redundantMeasure = new Vector(0,1);
inconsistentMeasures = new Vector(0,1);
BCMPserversWithDifferentQueueStrategy = new Vector(0,1);
BCMPserversWithDifferentServiceTypes = new Vector (0,1);
BCMPserversFCFSWithoutExponential = new Vector(0,1);
BCMPFcfsServersWithDifferentServiceTimes = new Vector(0,1);
BCMPdelaysWithNonRationalServiceDistribution = new Vector(0,1);
//nonFCFSStations = new Vector(0,1);
BCMPnonStateIndependentRoutingStations = new Vector(0,1);
emptyBlockingRegions = new Vector(0,1);
isToJMVAChecker = isToJMVA;
checkModel();
}
//resets all the variables of the model checker
private void reset() {
openClassesWithoutRefStation.removeAllElements();
classesWithoutRefStation.removeAllElements();
sourceWithoutClasses.removeAllElements();
stationsWithLinkErrors.removeAllElements();
routingErrors.clear();
allForwardStationsAreSinkErrors.clear();
stationWithoutBackwardLinks.removeAllElements();
redundantMeasure.removeAllElements();
inconsistentMeasures.removeAllElements();
//nonFCFSStations.removeAllElements();
BCMPserversWithDifferentQueueStrategy.removeAllElements();
BCMPserversWithDifferentServiceTypes.removeAllElements();
BCMPserversFCFSWithoutExponential.removeAllElements();
BCMPFcfsServersWithDifferentServiceTimes.removeAllElements();
BCMPdelaysWithNonRationalServiceDistribution.removeAllElements();
BCMPnonStateIndependentRoutingStations.removeAllElements();
emptyBlockingRegions.removeAllElements();
for (int i=0; i<NUMBER_OF_ERROR_TYPES;i++) {
errors[i]=false;
if (i<NUMBER_OF_WARNING_TYPES) warnings[i] = false;
}
}
//checks for problems of the model
public void checkModel() {
reset();
if (isToJMVAChecker) {
checkForNoClassError();
checkForNoStationError();
checkForOpenClassButNoSourceError();
checkForRefStationError();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -