00001 package edu.ksu.cis.bandera.dspin;
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083 import edu.ksu.cis.bandera.checker.*;
00084
00085 public class DSpinOptions extends CheckerOption
00086 {
00087 boolean Safety = false;
00088 boolean Assertions = true;
00089 boolean AcceptanceCycles = true;
00090 boolean ApplyNeverClaim = true;
00091
00092 public static final int Exhaustive = 0;
00093 public static final int SuperTrace = 1;
00094 public static final int HashCompact = 2;
00095
00096 int SearchMode = Exhaustive;
00097
00098 int StopAtError = 1;
00099 boolean SaveAllTrails = true;
00100 boolean FindShortestTrail = false;
00101
00102 int MemoryLimit = 128;
00103 int SpaceEstimate = 500;
00104 int SearchDepth = 10000;
00105
00106 boolean POReduction = false;
00107 boolean Compression = false;
00108
00109 public DSpinOptions() { super(); }
00110 public DSpinOptions(String s) { super(s); }
00111 public String compileOptions() {
00112 String co;
00113 switch (SearchMode) {
00114 case SuperTrace :
00115 co = "-DBITSTATE -DMEMLIM=" + MemoryLimit;
00116 break;
00117 case HashCompact :
00118 co = "-DHC -DMEMLIM=" + MemoryLimit;
00119 break;
00120 default :
00121 co = "-DMEMLIM=" + MemoryLimit;
00122 break;
00123 }
00124 if (Safety) co = co + " -DSAFETY";
00125 if (!ApplyNeverClaim) co = co + " -DNOCLAIM";
00126 if (!POReduction) co = co + " -DNOREDUCE";
00127 if (Compression) co = co + " -DCOLLAPSE";
00128 return co;
00129 }
00130
00131
00132
00133
00134 public int getMemoryLimit() {
00135 return MemoryLimit;
00136 }
00137
00138
00139
00140
00141 public int getSearchDepth() {
00142 return SearchDepth;
00143 }
00144
00145
00146
00147
00148 public int getSpaceEstimate() {
00149 return SpaceEstimate;
00150 }
00151
00152
00153
00154
00155 public int getStopAtError() {
00156 return StopAtError;
00157 }
00158 int log2(int x) {
00159 int log = 0;
00160 for (int total = 1; total < x; log++) {
00161 total = total * 2;
00162 }
00163 return log-1;
00164 }
00165 public static void main (String argv[]) {
00166 DSpinOptions so = new DSpinOptions();
00167 System.out.println("Default compile options :" + so.compileOptions());
00168 System.out.println("Default pan options :" + so.panOptions());
00169 (so = new DSpinOptions()).setSearchMode(SuperTrace);
00170 System.out.println("Supertrace compile options :" + so.compileOptions());
00171 System.out.println("Supertrace pan options :" + so.panOptions());
00172 (so = new DSpinOptions()).setSearchMode(HashCompact);
00173 System.out.println("Hash-compact compile options :" + so.compileOptions());
00174 System.out.println("Hash-compact pan options :" + so.panOptions());
00175 (so = new DSpinOptions()).setSafety(true);
00176 System.out.println("Safety compile options :" + so.compileOptions());
00177 System.out.println("Safety pan options :" + so.panOptions());
00178 (so = new DSpinOptions()).setMemoryLimit(1000);
00179 so.setSearchDepth(50000);
00180 so.setSpaceEstimate(2050);
00181 System.out.println("Limits compile options :" + so.compileOptions());
00182 System.out.println("Limits pan options :" + so.panOptions());
00183 (so = new DSpinOptions()).setApplyNeverClaim(false);
00184 so.setPOReduction(true);
00185 so.setCompression(true);
00186 System.out.println("No never, po, compress compile options :" + so.compileOptions());
00187 System.out.println("No never, po, compress pan options :" + so.panOptions());
00188 }
00189 public String panOptions() {
00190 String po;
00191 po = "-n -m" + SearchDepth + " -w" + (10 + log2(SpaceEstimate));
00192 if (AcceptanceCycles) po = po + " -a";
00193 if (!Assertions) po = po + " -A";
00194 if (StopAtError>1) po = po + " -c" + StopAtError;
00195 if (SaveAllTrails) po = po + " -e";
00196 if (FindShortestTrail) po = po + " -I";
00197 return po;
00198 }
00199 public void parseOptions(String s) {}
00200 public void setAcceptanceCycles(boolean ac) {
00201 AcceptanceCycles = ac;
00202 Safety = !ac;
00203 }
00204 public void setApplyNeverClaim(boolean nc) { ApplyNeverClaim = nc; }
00205 public void setAssertions(boolean as) {
00206 Assertions = as;
00207 }
00208 public void setCompression(boolean c) { Compression = c;}
00209 public void setFindShortestTrail(boolean st) { FindShortestTrail = st; }
00210 public void setMemoryLimit(int l) { MemoryLimit = l;}
00211 public void setPOReduction(boolean po) { POReduction = po;}
00212 public void setSafety(boolean s) {
00213 Safety = s;
00214 AcceptanceCycles = !s;
00215 ApplyNeverClaim = !s;
00216 }
00217 public void setSaveAllTrails(boolean at) { SaveAllTrails = at; }
00218 public void setSearchDepth(int d) { SearchDepth = d;}
00219 public void setSearchMode(int m) { SearchMode = m; }
00220 public void setSpaceEstimate(int e) { SpaceEstimate = e;}
00221 public void setStopAtError(int e) { StopAtError = 1; }
00222 }