Browse Source

Tweak some warning messages (wrt new log.printWarning method) + add warning message functionality in GUI threads.

git-svn-id: https://www.prismmodelchecker.org/svn/prism/prism/trunk@4178 bbc10eb1-c90d-0410-af57-cb519fbb1720
master
Dave Parker 15 years ago
parent
commit
90c9e53f8c
  1. 6
      prism/src/prism/Modules2MTBDD.java
  2. 10
      prism/src/prism/NondetModelChecker.java
  3. 4
      prism/src/prism/Prism.java
  4. 2
      prism/src/prism/PrismCL.java
  5. 22
      prism/src/prism/PrismLog.java
  6. 19
      prism/src/prism/ProbModelChecker.java
  7. 6
      prism/src/simulator/SimulatorEngine.java
  8. 1
      prism/src/userinterface/GUIComputationThread.java
  9. 8
      prism/src/userinterface/GUIPlugin.java
  10. 4
      prism/src/userinterface/log/GUILog.java
  11. 2
      prism/src/userinterface/model/computation/BuildModelThread.java
  12. 2
      prism/src/userinterface/properties/GUIExperiment.java
  13. 1
      prism/src/userinterface/util/GUILogEvent.java

6
prism/src/prism/Modules2MTBDD.java

@ -533,7 +533,7 @@ public class Modules2MTBDD
break; break;
default: default:
mainLog.printWarning("Invalid MTBDD ordering selected - it's all going to go wrong.\n");
mainLog.printWarning("Invalid MTBDD ordering selected - it's all going to go wrong.");
break; break;
} }
@ -1449,7 +1449,7 @@ public class Modules2MTBDD
if (guardDDs[l].equals(JDD.ZERO)) { if (guardDDs[l].equals(JDD.ZERO)) {
// display a warning (unless guard is "false", in which case was probably intentional // display a warning (unless guard is "false", in which case was probably intentional
if (!Expression.isFalse(command.getGuard())) { if (!Expression.isFalse(command.getGuard())) {
String s = "Guard for command " + (l+1) + " of module \"" + module.getName() + "\" is never satisfied.\n";
String s = "Guard for command " + (l+1) + " of module \"" + module.getName() + "\" is never satisfied.";
mainLog.printWarning(s); mainLog.printWarning(s);
} }
// no point bothering to compute the mtbdds for the update // no point bothering to compute the mtbdds for the update
@ -1606,7 +1606,7 @@ public class Modules2MTBDD
if (!(tmp.equals(JDD.ZERO))) { if (!(tmp.equals(JDD.ZERO))) {
// if so, output a warning (but carry on regardless) // if so, output a warning (but carry on regardless)
mainLog.printWarning("Guard for command " + (i+1) + " of module \"" mainLog.printWarning("Guard for command " + (i+1) + " of module \""
+ moduleNames[m] + "\" overlaps with previous commands.\n");
+ moduleNames[m] + "\" overlaps with previous commands.");
} }
JDD.Deref(tmp); JDD.Deref(tmp);
// add this command's guard to 'covered' // add this command's guard to 'covered'

10
prism/src/prism/NondetModelChecker.java

@ -177,11 +177,11 @@ public class NondetModelChecker extends NonProbModelChecker
// Check for trivial (i.e. stupid) cases // Check for trivial (i.e. stupid) cases
if (pb != null) { if (pb != null) {
if ((p == 0 && relOp.equals(">=")) || (p == 1 && relOp.equals("<="))) { if ((p == 0 && relOp.equals(">=")) || (p == 1 && relOp.equals("<="))) {
mainLog.printWarning("Checking for probability " + relOp + " " + p + " - formula trivially satisfies all states\n");
mainLog.printWarning("Checking for probability " + relOp + " " + p + " - formula trivially satisfies all states");
JDD.Ref(reach); JDD.Ref(reach);
return new StateValuesMTBDD(reach, model); return new StateValuesMTBDD(reach, model);
} else if ((p == 0 && relOp.equals("<")) || (p == 1 && relOp.equals(">"))) { } else if ((p == 0 && relOp.equals("<")) || (p == 1 && relOp.equals(">"))) {
mainLog.printWarning("Checking for probability " + relOp + " " + p + " - formula trivially satisfies no states\n");
mainLog.printWarning("Checking for probability " + relOp + " " + p + " - formula trivially satisfies no states");
return new StateValuesMTBDD(JDD.Constant(0), model); return new StateValuesMTBDD(JDD.Constant(0), model);
} }
} }
@ -269,11 +269,11 @@ public class NondetModelChecker extends NonProbModelChecker
// check for trivial (i.e. stupid) cases // check for trivial (i.e. stupid) cases
if (rb != null) { if (rb != null) {
if (r == 0 && relOp.equals(">=")) { if (r == 0 && relOp.equals(">=")) {
mainLog.printWarning("Checking for reward " + relOp + " " + r + " - formula trivially satisfies all states\n");
mainLog.printWarning("Checking for reward " + relOp + " " + r + " - formula trivially satisfies all states");
JDD.Ref(reach); JDD.Ref(reach);
return new StateValuesMTBDD(reach, model); return new StateValuesMTBDD(reach, model);
} else if (r == 0 && relOp.equals("<")) { } else if (r == 0 && relOp.equals("<")) {
mainLog.printWarning("Checking for reward " + relOp + " " + r + " - formula trivially satisfies no states\n");
mainLog.printWarning("Checking for reward " + relOp + " " + r + " - formula trivially satisfies no states");
return new StateValuesMTBDD(JDD.Constant(0), model); return new StateValuesMTBDD(JDD.Constant(0), model);
} }
} }
@ -670,7 +670,7 @@ public class NondetModelChecker extends NonProbModelChecker
// if requested (i.e. when prob bound is 0 or 1 and precomputation algorithms are enabled), // if requested (i.e. when prob bound is 0 or 1 and precomputation algorithms are enabled),
// compute probabilities qualitatively // compute probabilities qualitatively
if (qual) { if (qual) {
mainLog.printWarning("Probability bound in formula is" + " 0/1 so exact probabilities may not be computed\n");
mainLog.print("\nProbability bound in formula is 0/1 so not computing exact probabilities...\n");
// for fairness, we compute max here // for fairness, we compute max here
probs = computeUntilProbsQual(trans01, newb1, newb2, min && !fairness); probs = computeUntilProbsQual(trans01, newb1, newb2, min && !fairness);
} }

4
prism/src/prism/Prism.java

@ -1357,12 +1357,12 @@ public class Prism implements PrismSettingsListener
// can only do ordered version of export for MDPs // can only do ordered version of export for MDPs
if (model.getModelType() == ModelType.MDP) { if (model.getModelType() == ModelType.MDP) {
if (!ordered) mainLog.printWarning("Cannot export unordered transition reward matrix for MDPs; using ordered");
if (!ordered) mainLog.printWarning("Cannot export unordered transition reward matrix for MDPs; using ordered.");
ordered = true; ordered = true;
} }
// can only do ordered version of export for MRMC // can only do ordered version of export for MRMC
if (exportType == EXPORT_MRMC) { if (exportType == EXPORT_MRMC) {
if (!ordered) mainLog.printWarning("Cannot export unordered transition reward matrix in MRMC format; using ordered");
if (!ordered) mainLog.printWarning("Cannot export unordered transition reward matrix in MRMC format; using ordered.");
ordered = true; ordered = true;
} }
// can only do ordered version of export for rows format // can only do ordered version of export for rows format

2
prism/src/prism/PrismCL.java

@ -755,7 +755,7 @@ public class PrismCL
} }
// if requested, remove them // if requested, remove them
else if (fixdl) { else if (fixdl) {
mainLog.printWarning(states.size() + " deadlock states detected; adding self-loops in these states...\n");
mainLog.printWarning(states.size() + " deadlock states detected; adding self-loops in these states...");
model.fixDeadlocks(); model.fixDeadlocks();
} }
// otherwise print error and bail out // otherwise print error and bail out

22
prism/src/prism/PrismLog.java

@ -87,18 +87,29 @@ public abstract class PrismLog
} }
public abstract boolean ready(); public abstract boolean ready();
public abstract long getFilePointer(); public abstract long getFilePointer();
public abstract void flush(); public abstract void flush();
public abstract void close(); public abstract void close();
public abstract void print(boolean b); public abstract void print(boolean b);
public abstract void print(char c); public abstract void print(char c);
public abstract void print(double d); public abstract void print(double d);
public abstract void print(float f); public abstract void print(float f);
public abstract void print(int i); public abstract void print(int i);
public abstract void print(long l); public abstract void print(long l);
public abstract void print(Object obj); public abstract void print(Object obj);
public abstract void print(String s); public abstract void print(String s);
public abstract void println(); public abstract void println();
/** /**
@ -355,16 +366,15 @@ public abstract class PrismLog
} }
/** /**
* Prints a warning message {@code s}, preceded by "\\nWarning: " string
* and followed by a newline characted.
* Prints a warning message {@code s}, preceded by "\nWarning: " and followed by a newline character.
* <p/> * <p/>
* Also increases {@link #numberOfWarnings} by one. This variable can be then
* Also increases {@link #numberOfWarnings} by one. This variable can then be
* queried using {@link #getNumberOfWarnings()} at the end of computation * queried using {@link #getNumberOfWarnings()} at the end of computation
* and the user can be appropriately informed that there were warnings
* generated.
* and the user can be appropriately informed that there were warnings generated.
* @param s The warning message. * @param s The warning message.
*/ */
public void printWarning(String s) {
public void printWarning(String s)
{
println("\nWarning: " + s); println("\nWarning: " + s);
this.numberOfWarnings++; this.numberOfWarnings++;
} }

19
prism/src/prism/ProbModelChecker.java

@ -176,19 +176,19 @@ public class ProbModelChecker extends NonProbModelChecker
if (pb != null) { if (pb != null) {
if ((p == 0 && relOp.equals(">=")) || (p == 1 && relOp.equals("<="))) { if ((p == 0 && relOp.equals(">=")) || (p == 1 && relOp.equals("<="))) {
mainLog.printWarning("Checking for probability " + relOp + " " + p mainLog.printWarning("Checking for probability " + relOp + " " + p
+ " - formula trivially satisfies all states\n");
+ " - formula trivially satisfies all states");
JDD.Ref(reach); JDD.Ref(reach);
return new StateValuesMTBDD(reach, model); return new StateValuesMTBDD(reach, model);
} else if ((p == 0 && relOp.equals("<")) || (p == 1 && relOp.equals(">"))) { } else if ((p == 0 && relOp.equals("<")) || (p == 1 && relOp.equals(">"))) {
mainLog.printWarning("Checking for probability " + relOp + " " + p mainLog.printWarning("Checking for probability " + relOp + " " + p
+ " - formula trivially satisfies no states\n");
+ " - formula trivially satisfies no states");
return new StateValuesMTBDD(JDD.Constant(0), model); return new StateValuesMTBDD(JDD.Constant(0), model);
} }
} }
// Print a warning if Pmin/Pmax used // Print a warning if Pmin/Pmax used
if (relOp.equals("min=") || relOp.equals("max=")) { if (relOp.equals("min=") || relOp.equals("max=")) {
mainLog.printWarning("\"Pmin=?\" and \"Pmax=?\" operators are identical to \"P=?\" for DTMCs/CTMCs\n");
mainLog.printWarning("\"Pmin=?\" and \"Pmax=?\" operators are identical to \"P=?\" for DTMCs/CTMCs");
} }
// Compute probabilities // Compute probabilities
@ -263,19 +263,19 @@ public class ProbModelChecker extends NonProbModelChecker
if (rb != null) { if (rb != null) {
if (r == 0 && relOp.equals(">=")) { if (r == 0 && relOp.equals(">=")) {
mainLog.printWarning("Checking for reward " + relOp + " " + r mainLog.printWarning("Checking for reward " + relOp + " " + r
+ " - formula trivially satisfies all states\n");
+ " - formula trivially satisfies all states");
JDD.Ref(reach); JDD.Ref(reach);
return new StateValuesMTBDD(reach, model); return new StateValuesMTBDD(reach, model);
} else if (r == 0 && relOp.equals("<")) { } else if (r == 0 && relOp.equals("<")) {
mainLog.printWarning("Checking for reward " + relOp + " " + r mainLog.printWarning("Checking for reward " + relOp + " " + r
+ " - formula trivially satisfies no states\n");
+ " - formula trivially satisfies no states");
return new StateValuesMTBDD(JDD.Constant(0), model); return new StateValuesMTBDD(JDD.Constant(0), model);
} }
} }
// print a warning if Rmin/Rmax used // print a warning if Rmin/Rmax used
if (relOp.equals("min=") || relOp.equals("max=")) { if (relOp.equals("min=") || relOp.equals("max=")) {
mainLog.printWarning("\"Rmin=?\" and \"Rmax=?\" operators are identical to \"R=?\" for DTMCs/CTMCs\n");
mainLog.printWarning("\"Rmin=?\" and \"Rmax=?\" operators are identical to \"R=?\" for DTMCs/CTMCs");
} }
// compute rewards // compute rewards
@ -352,12 +352,12 @@ public class ProbModelChecker extends NonProbModelChecker
if (pb != null) { if (pb != null) {
if ((p == 0 && relOp.equals(">=")) || (p == 1 && relOp.equals("<="))) { if ((p == 0 && relOp.equals(">=")) || (p == 1 && relOp.equals("<="))) {
mainLog.printWarning("Checking for probability " + relOp + " " + p mainLog.printWarning("Checking for probability " + relOp + " " + p
+ " - formula trivially satisfies all states\n");
+ " - formula trivially satisfies all states");
JDD.Ref(reach); JDD.Ref(reach);
return new StateValuesMTBDD(reach, model); return new StateValuesMTBDD(reach, model);
} else if ((p == 0 && relOp.equals("<")) || (p == 1 && relOp.equals(">"))) { } else if ((p == 0 && relOp.equals("<")) || (p == 1 && relOp.equals(">"))) {
mainLog.printWarning("Checking for probability " + relOp + " " + p mainLog.printWarning("Checking for probability " + relOp + " " + p
+ " - formula trivially satisfies no states\n");
+ " - formula trivially satisfies no states");
return new StateValuesMTBDD(JDD.Constant(0), model); return new StateValuesMTBDD(JDD.Constant(0), model);
} }
} }
@ -802,8 +802,7 @@ public class ProbModelChecker extends NonProbModelChecker
// if requested (i.e. when prob bound is 0 or 1 and precomputation algorithms are enabled), // if requested (i.e. when prob bound is 0 or 1 and precomputation algorithms are enabled),
// compute probabilities qualitatively // compute probabilities qualitatively
if (qual) { if (qual) {
mainLog.printWarning("Probability bound in formula is"
+ " 0/1 so exact probabilities may not be computed\n");
mainLog.print("\nProbability bound in formula is 0/1 so not computing exact probabilities...\n");
probs = computeUntilProbsQual(trans01, b1, b2); probs = computeUntilProbsQual(trans01, b1, b2);
} }
// otherwise actually compute probabilities // otherwise actually compute probabilities

6
prism/src/simulator/SimulatorEngine.java

@ -610,7 +610,7 @@ public class SimulatorEngine
public Object queryProperty(int index) public Object queryProperty(int index)
{ {
if (index < 0 || index >= propertySamplers.size()) { if (index < 0 || index >= propertySamplers.size()) {
mainLog.printWarning("Can't query property " + index);
mainLog.printWarning("Can't query property " + index + ".");
return null; return null;
} }
Sampler sampler = propertySamplers.get(index); Sampler sampler = propertySamplers.get(index);
@ -1589,11 +1589,11 @@ public class SimulatorEngine
// Print a warning if deadlocks occurred at any point // Print a warning if deadlocks occurred at any point
if (deadlocksFound) if (deadlocksFound)
mainLog.printWarning("Deadlocks were found during simulation: self-loops were added\n");
mainLog.printWarning("Deadlocks were found during simulation: self-loops were added.");
// Print a warning if simulation was stopped by the user // Print a warning if simulation was stopped by the user
if (shouldStopSampling) if (shouldStopSampling)
mainLog.printWarning("Simulation was terminated before completion.\n");
mainLog.printWarning("Simulation was terminated before completion.");
// write to feedback file with true to indicate that we have finished sampling // write to feedback file with true to indicate that we have finished sampling
// Write_Feedback(iteration_counter, numIters, true); // Write_Feedback(iteration_counter, numIters, true);

1
prism/src/userinterface/GUIComputationThread.java

@ -71,6 +71,7 @@ public class GUIComputationThread extends Thread
public void logln(short s) { plug.logln(s); } public void logln(short s) { plug.logln(s); }
public void logln(byte b) { plug.logln(b); } public void logln(byte b) { plug.logln(b); }
public void logln(boolean b) { plug.logln(b); } public void logln(boolean b) { plug.logln(b); }
public void logWarning(String s) { plug.logWarning(s); }
// pop up an error dialog // pop up an error dialog
public void errorDialog(String s) public void errorDialog(String s)

8
prism/src/userinterface/GUIPlugin.java

@ -541,6 +541,14 @@ public abstract class GUIPlugin extends JPanel implements GUIEventListener, Pris
gui.enableTab(this, enabled); gui.enableTab(this, enabled);
} }
/** Method to add a warning message to the log contained within the parent GUIPrism.
* @param message The message to be added to the log
*/
public void logWarning(String message)
{
notifyEventListeners(new GUILogEvent(GUILogEvent.PRINTWARNING, message));
}
/** Utility method to automatically jump this plugin to the front of the tabs /** Utility method to automatically jump this plugin to the front of the tabs
* contained within the parent GUIPrism. * contained within the parent GUIPrism.
*/ */

4
prism/src/userinterface/log/GUILog.java

@ -122,6 +122,10 @@ public class GUILog extends GUIPlugin implements MouseListener, PrismSettingsLis
{ {
theLog.print(le.getData()); theLog.print(le.getData());
} }
else if(le.getID() == le.PRINTWARNING)
{
theLog.printWarning((String) le.getData());
}
} }
else if (e instanceof GUIClipboardEvent && super.getGUI().getFocussedPlugin() == this) else if (e instanceof GUIClipboardEvent && super.getGUI().getFocussedPlugin() == this)
{ {

2
prism/src/userinterface/model/computation/BuildModelThread.java

@ -212,7 +212,7 @@ public class BuildModelThread extends GUIComputationThread
String[] options = {"Continue", "Display deadlocks"}; String[] options = {"Continue", "Display deadlocks"};
int choice = plug.question("Error", "Error: Model contains deadlock states.\nAdd self-loops to these states and continue?\nOr stop and display deadlock states in log?", options); int choice = plug.question("Error", "Error: Model contains deadlock states.\nAdd self-loops to these states and continue?\nOr stop and display deadlock states in log?", options);
if (choice == 0) { if (choice == 0) {
log("\nWarning: " + deadlocks.size() + " deadlock states detected; adding self-loops in these states...\n");
logWarning(deadlocks.size() + " deadlock states detected; adding self-loops in these states...");
model.fixDeadlocks(); model.fixDeadlocks();
} }
else { else {

2
prism/src/userinterface/properties/GUIExperiment.java

@ -285,7 +285,7 @@ public class GUIExperiment
StateList states = model.getDeadlockStates(); StateList states = model.getDeadlockStates();
if (states != null) { if (states != null) {
if (states.size() > 0) { if (states.size() > 0) {
guiProp.log("\nWarning: " + states.size() + " deadlock states detected; adding self-loops in these states...\n");
guiProp.logWarning(states.size() + " deadlock states detected; adding self-loops in these states...");
model.fixDeadlocks(); model.fixDeadlocks();
} }
} }

1
prism/src/userinterface/util/GUILogEvent.java

@ -31,6 +31,7 @@ public class GUILogEvent extends GUIEvent
{ {
public static final int PRINTLN = 0; public static final int PRINTLN = 0;
public static final int PRINT = 1; public static final int PRINT = 1;
public static final int PRINTWARNING = 2;
/** /**
* Constructs an instance of <code>GUILogEvent</code> with the specified detail message. * Constructs an instance of <code>GUILogEvent</code> with the specified detail message.

Loading…
Cancel
Save