Main Page   Packages   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members  

DSpinOptions.java

00001 package edu.ksu.cis.bandera.dspin;
00002 
00003 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
00004  * Bandera, a Java(TM) analysis and transformation toolkit           *
00005  * Copyright (C) 1999   Matthew Dwyer (dwyer@cis.ksu.edu)            *
00006  * All rights reserved.                                              *
00007  *                                                                   *
00008  * This work was done as a project in the SAnToS Laboratory,         *
00009  * Department of Computing and Information Sciences, Kansas State    *
00010  * University, USA (http://www.cis.ksu.edu/santos).                  *
00011  * It is understood that any modification not identified as such is  *
00012  * not covered by the preceding statement.                           *
00013  *                                                                   *
00014  * This work is free software; you can redistribute it and/or        *
00015  * modify it under the terms of the GNU Library General Public       *
00016  * License as published by the Free Software Foundation; either      *
00017  * version 2 of the License, or (at your option) any later version.  *
00018  *                                                                   *
00019  * This work is distributed in the hope that it will be useful,      *
00020  * but WITHOUT ANY WARRANTY; without even the implied warranty of    *
00021  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU *
00022  * Library General Public License for more details.                  *
00023  *                                                                   *
00024  * You should have received a copy of the GNU Library General Public *
00025  * License along with this toolkit; if not, write to the             *
00026  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,      *
00027  * Boston, MA  02111-1307, USA.                                      *
00028  *                                                                   *
00029  * Java is a trademark of Sun Microsystems, Inc.                     *
00030  *                                                                   *
00031  * To submit a bug report, send a comment, or get the latest news on *
00032  * this project and other SAnToS projects, please visit the web-site *
00033  *                http://www.cis.ksu.edu/santos                      *
00034  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
00035 /**
00036  * DSpinOptions is used to configure the options to be used in invoking
00037  * the SPIN model checker on generated PROMELA systems.
00038  * <p>
00039  * Most user setable options available through the XSPIN interface
00040  * can be configured through this class.  Default values for those
00041  * options are as follows: 
00042  * <ul> 
00043  * <li> <tt>Safety</tt> : false
00044  * <li> <tt>Assertions</tt> : true
00045  * <li> <tt>AcceptanceCycles</tt> : true
00046  * <li> <tt>ApplyNeverClaim</tt> : true
00047  * <li> <tt>SearchMode</tt> : <tt>Exhaustive</tt><br>
00048  *  [out of <tt>{Exhaustive, SuperTrace, HashCompact}</tt>]
00049  * <li> <tt>StopAtError</tt> : 1
00050  * <li> <tt>SaveAllTrails</tt> : true
00051  * <li> <tt>FindShortestTrail</tt> : false
00052  * <li> <tt>MemoryLimit</tt> : 128 (MBytes)
00053  * <li> <tt>SpaceEstimate</tt> : 500 (x10^3)
00054  * <li> <tt>SearchDepth</tt> : 10000
00055  * <li> <tt>POReduction</tt> : false
00056  * <li> <tt>Compression</tt> : false
00057  * </ul>
00058  * <p>
00059  * Some options do not make sense when used with Bandera generated
00060  * models.
00061  * <ul> 
00062  * <li> Bandera models will not contain "progress" state labels
00063  * <li> unreachable model code should not be reported to the user
00064  * <li> weak-fairness is not supported either 
00065  * </ul>
00066  * <p>
00067  * Some basic guidelines for setting SPIN options are:
00068  * <p>
00069  * If the model contains Bandera.assert(...) calls then <tt>Assertions</tt>
00070  * should be enabled.
00071  * <p> 
00072  * If a temporal formula is checked then never claims should be applied, 
00073  * otherwise it is a deadlock check.  If the temporal formula is known
00074  * to be a safety property then <tt>Safety</tt> should be set, otherwise
00075  * <tt>AcceptanceCycles</tt> should be set.  
00076  * <p>
00077  * Some option settings are linked:
00078  * <ul>
00079  * <li> Setting <tt>Safety</tt> to true automatically 
00080  * sets <tt>AcceptanceCycles</tt> to be false, and vice-versa.
00081  * </ul>
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  * @return int
00133  */
00134 public int getMemoryLimit() {
00135     return MemoryLimit;
00136 }
00137 /**
00138  * 
00139  * @return int
00140  */
00141 public int getSearchDepth() {
00142     return SearchDepth;
00143 }
00144 /**
00145  * 
00146  * @return int
00147  */
00148 public int getSpaceEstimate() {
00149     return SpaceEstimate;
00150 }
00151 /**
00152  * 
00153  * @return int
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 }

Generated at Thu Feb 7 06:44:47 2002 for Bandera by doxygen1.2.10 written by Dimitri van Heesch, © 1997-2001