📄 modelchecker.java
字号:
Vector alreadyVisited = new Vector(0,1);
//get the class at i
Object thisClassKey = closedClassKeys.get(i);
//checks for each possible starting point if there are preloaded jobs for the class i.
//In that case put it into the startingPoints vector
for (int j=0; j<noSourceSink.size(); j++) {
Object thisElementKey = noSourceSink.get(j);
int preloadedJobs = simulation_def.getPreloadedJobs(thisElementKey,thisClassKey).intValue();
if (preloadedJobs > 0) startingPoints.add(thisElementKey);
}
//start the explore algorithm for each of the station containing some preloaded jobs for class i
for (int j=0; j<startingPoints.size(); j++) {
//get the element at j
Object thisStartingPoint = startingPoints.get(j);
//if this possible starting point has not been visited yet
if (!alreadyVisited.contains(thisStartingPoint)) {
alreadyVisited.add(thisStartingPoint);
Vector problemsForThisStartingPoint = this.exploreForAllForwardStationAreSink(thisClassKey,thisStartingPoint,alreadyVisited);
for (int k=0;k<problemsForThisStartingPoint.size();k++) {
problemsPerClass.add(problemsForThisStartingPoint.get(k));
}
}
}
if (!problemsPerClass.isEmpty()) {
allForwardStationsAreSinkErrors.put(thisClassKey,problemsPerClass.clone());
errors[ALL_FORWARD_STATION_ARE_SINK_ERROR] = true;
}
}
}
/**
* Checks for NO_EXP_FOUND_ERROR
*/
/*private void checkForNoExpFoundWarning() {
Vector classes = class_def.getClassKeys();
//first search for open classes with non exponential arrival time distribution
for (int i=0; i<classes.size();i++) {
Object thisKey = classes.get(i);
if (class_def.getClassType(thisKey) == CLASS_TYPE_OPEN) {
Object distribution = class_def.getClassDistribution(thisKey);
if ((distribution != null)&&(!(distribution instanceof Exponential))) {
warnings[NO_EXP_FOUND_WARNING] = true;
return;
}
}
}
//than search for non exponential service time distribution
Vector stations = station_def.getStationKeys();
for (int i=0; i<stations.size();i++) {
Object thisStation = stations.get(i);
for (int j=0; j<classes.size();j++) {
Object thisClass = classes.get(j);
Object temp = station_def.getServiceTimeDistribution(thisStation,thisClass);
if (temp instanceof Distribution) {
Distribution distribution = (Distribution) temp;
if (!(distribution instanceof Exponential)) {
warnings[NO_EXP_FOUND_WARNING] = true;
return;
}
}
}
}
}
*/
/**
* checks for delays inside the model
*/
/*public void checkForDelaysFoundError() {
//get the vector of delays and servers
Vector stations = station_def.getStationKeysNoSourceSink();
//for each station...
for (int i=0;i<stations.size();i++) {
//get the type of the station
String stationType = station_def.getStationType(stations.get(i));
//if it is a delay there is an error
if (stationType.equals(STATION_TYPE_DELAY)) {
errors[DELAYS_FOUND_ERROR] = true;
return;
}
}
}
*/
/**
* Checks that there is at least one measure defined. If a problem is found it raises
* to "true" the corresponding position inside the problems array.
*/
private void checkForSimulationError() {
Vector measures = simulation_def.getMeasureKeys();
if (measures.size() == 0) errors[SIMULATION_ERROR] = true;
}
/**
* Checks that each measure is defined only one time
* <br> Fixed by Bertoli Marco to support global measures
*/
private void checkForMeasureError() {
Vector measures = simulation_def.getMeasureKeys();
Vector measuresAlreadyChecked = new Vector(0,1);
for (int i = 0; i<measures.size();i++) {
Object thisMeasure = measures.get(i);
String thisMeasureType = simulation_def.getMeasureType(thisMeasure);
String thisMeasureClass;
if (simulation_def.getMeasureClass(thisMeasure) == null)
thisMeasureClass = "ALL";
else
thisMeasureClass = class_def.getClassName(simulation_def.getMeasureClass(thisMeasure));
String thisMeasureStation;
if (simulation_def.getMeasureStation(thisMeasure) == null)
thisMeasureStation = "ALL";
else
thisMeasureStation = station_def.getStationName(simulation_def.getMeasureStation(thisMeasure));
String thisMeasureDescription = thisMeasureType + thisMeasureClass + thisMeasureStation;
if (!measuresAlreadyChecked.contains(thisMeasureDescription)) {
measuresAlreadyChecked.add(thisMeasureDescription);
}
else{
errors[DUPLICATE_MEASURE_ERROR] = true;
redundantMeasure.add(thisMeasure);
}
}
}
/**
* Checks that each performance index is consistent, i.e. it has no
* 'null' field in reference station.
* <br> Fixed by Bertoli Marco to support global measures
*/
private void checkForInconsistentMeasureError() {
Vector measures = simulation_def.getMeasureKeys();
//Vector measuresAlreadyChecked = new Vector(0,1);
for (int i = 0; i<measures.size();i++) {
Object thisMeasure = measures.get(i);
String thisMeasureType = simulation_def.getMeasureType(thisMeasure);
Object thisMeasureStationKey = simulation_def.getMeasureStation(thisMeasure);
if ((thisMeasureType == null) || (thisMeasureStationKey == null && !simulation_def.isGlobalMeasure(thisMeasure))) {
inconsistentMeasures.add(thisMeasure);
errors[INCONSISTENT_MEASURE_ERROR] = true;
}
}
}
/**
* This method is the same of checkForReferenceStationError but it checks only open classes
*/
/*private void checkForOpenClassReferenceStationError() {
// get the vector of the keys of the classes
Vector classKeys = class_def.getClassKeys();
for (int i=0; i<classKeys.size();i++) {
//get the key at i
Object thisKey = classKeys.get(i);
if (class_def.getClassType(thisKey) == CommonConstants.CLASS_TYPE_OPEN) {
//get the Reference Station of the class
Object thisRefStation = class_def.getClassRefStation(thisKey);
//if the class has no reference station there is a class problem
if (thisRefStation == null) {
errors[OPEN_CLASS_REFERENCE_STATION_ERROR] = true;
openClassesWithoutRefStation.add(thisKey);
}
}
}
}*/
/**
* Checks if the queue strategy for each class is FCFS. Used only in toJMVA Conversion
*/
/*private void checkForNonFCFSWarning() {
Vector stations = station_def.getStationKeysNoSourceSink();
Vector classes = class_def.getClassKeys();
for (int i=0;i<stations.size();i++) {
Object thisStation = stations.get(i);
for (int j=0;j<classes.size();j++) {
Object thisClass = classes.get(j);
String qStrategy = station_def.getQueueStrategy(thisStation,thisClass);
if (qStrategy != null) {
if (!qStrategy.equals(JSIMConstants.QUEUE_STRATEGY_FCFS)) {
nonFCFSStations.add(thisStation);
warnings[NON_FCFS_WARNING] = true;
break;
}
}
}
}
}
*/
/**
* Checks if a non random routing is used inside a station
*/
private void checkForBCMPNonStateIndependentRoutingWarning() {
Vector stations = station_def.getStationKeysNoSourceSink();
Vector classes = class_def.getClassKeys();
for (int i=0;i<stations.size();i++) {
Object thisStation = stations.get(i);
for (int j=0;j<classes.size();j++) {
Object thisClass = classes.get(j);
RoutingStrategy thisRoutingStrategy = (RoutingStrategy)station_def.getRoutingStrategy(thisStation,thisClass);
if (thisRoutingStrategy != null) {
if (thisRoutingStrategy.isModelStateDependent()) {
BCMPnonStateIndependentRoutingStations.add(thisStation);
warnings[BCMP_NON_STATE_INDEPENDENT_ROUTING_WARNING] = true;
break;
}
}
}
}
}
/**
* Explores the model, searching for routing problems for the specified close class
* @param classKey the key of the class to be analyzed
* @param startingStationKey the key of the station where we start analyzing the routing
* @param alreadyVisited vector containing the keys of the already visited stations
* @return the Vector containing the keys of the stations where the routing problem occours
*/
private Vector exploreForRoutingProblems(Object classKey, Object startingStationKey, Vector alreadyVisited) {
//Vector containing the keys to be returned
Vector toBeReturned = new Vector(0,1);
//Vector containing the keys of the forward stations
Vector forwardStations = station_def.getForwardConnections(startingStationKey);
/*//if there is one only forward station ...
if (forwardStations.size() == 1) {
//... get the only forward station ...
Object uniqueForwardElement = forwardStations.get(0);
//... if it has not been explored yet ...
if (!alreadyVisited.contains(uniqueForwardElement)) {
//... add the element to the alreadyVisited vector ...
alreadyVisited.add(uniqueForwardElement);
// ... if the forward station is a Sink there is a problem, add the
// startingStationKey to the toBeReturned vector ...
if (station_def.getStationType(uniqueForwardElement).equals(STATION_TYPE_SINK)) toBeReturned.add(startingStationKey);
//... else ...
else {
// ... explore starting from uniqueForwardElement and collect the
// results into the temp vector ...
Vector temp = exploreForRoutingProblems(classKey,uniqueForwardElement,alreadyVisited);
// ... put the elements of the temp vector into the toBeReturned Vector ...
for (int i=0; i<temp.size(); i++) {
toBeReturned.add(temp.get(i));
}
}
}
}
// if there is more than one forward station ...*/
//else {
for (int i=0; i<forwardStations.size(); i++) {
// ... get the forward station at i ...
Object thisForwardStation = forwardStations.get(i);
//... if it has not been explored yet ...
if (!alreadyVisited.contains(thisForwardStation)) {
//... add the element to the alreadyVisited vector ...
alreadyVisited.add(thisForwardStation);
// ... get the routing strategy for the class in the starting station ...
RoutingStrategy strategy = (RoutingStrategy)station_def.getRoutingStrategy(startingStationKey,classKey);
// ... if thisForwardStation is a Sink ...
if (station_def.getStationType(thisForwardStation).equals(STATION_TYPE_SINK)) {
// ... if the routing strategy is the Probability Routing ...
if (strategy instanceof ProbabilityRouting) {
HashMap probabilities = strategy.getValues();
// ... get the routing probability toward thisForwardStation ...
double p = ((Double)probabilities.get(thisForwardStation)).doubleValue();
// ... if p = 1 there is an error, put startingStationKey into the
// toBeReturned vector ...
if (p == 1) toBeReturned.add(startingStationKey);
}
}
// ... else thisForwardStation isn't a Sink ...
else {
Vector temp;
// ... if the routing policy is ProbabilityRouting ...
if (strategy instanceof ProbabilityRouting) {
HashMap probabilities = strategy.getValues();
// ... get the routing probability toward thisForwardStation ...
double p = ((Double)probabilities.get(thisForwardStation)).doubleValue();
// ... if p != 0 start exploring from thisForwardStation and collect
// the returned vector into temp ...
if (p != 0) {
temp = exploreForRoutingProblems(classKey,thisForwardStation,alreadyVisited);
}
// ... else temp is not used
else temp = null;
}
// ... if the routing policy is not ProbabilityRouting start exploring
// from thisForwardStation and collect the returned vector into temp ...
else temp = exploreForRoutingProblems(classKey,thisForwardStation,alreadyVisited);
// ... if temp have been used ...
if (temp != nu
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -