当前位置: 首页>>代码示例>>Java>>正文


Java A4Reporter类代码示例

本文整理汇总了Java中edu.mit.csail.sdg.alloy4.A4Reporter的典型用法代码示例。如果您正苦于以下问题:Java A4Reporter类的具体用法?Java A4Reporter怎么用?Java A4Reporter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


A4Reporter类属于edu.mit.csail.sdg.alloy4包,在下文中一共展示了A4Reporter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import edu.mit.csail.sdg.alloy4.A4Reporter; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
    A4Reporter rep = new A4Reporter();
    
    Module world = CompUtil.parseEverything_fromFile(rep, null, "/home/aleks/mvc.als");
    A4Options options = new A4Options();
    options.solver = A4Options.SatSolver.SAT4J;
    options.skolemDepth = 1;
    
    for (Command command : world.getAllCommands()) {
        A4Solution ans = null;
        try {
            ans = TranslateAlloyToKodkod.execute_commandFromBook(rep, world.getAllReachableSigs(), command, options);
            System.out.println(ans);
        } catch (Err ex) {
            Logger.getLogger(AlloyTest.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}
 
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:19,代码来源:AlloyTest.java

示例2: writeInstance

import edu.mit.csail.sdg.alloy4.A4Reporter; //导入依赖的package包/类
/**
 * If this solution is a satisfiable solution, this method will write it out
 * in XML format.
 */
static void writeInstance(A4Reporter rep, A4Solution sol, PrintWriter out, Iterable<Func> extraSkolems,
		Map<String,String> sources) throws Err {
	if (!sol.satisfiable())
		throw new ErrorAPI("This solution is unsatisfiable.");
	try {
		Util.encodeXMLs(out, "<alloy builddate=\"", Version.buildDate(), "\">\n\n");
		new A4SolutionWriter(rep, sol, sol.getAllReachableSigs(), sol.getBitwidth(), sol.getMaxSeq(),
				sol.getOriginalCommand(), sol.getOriginalFilename(), out, extraSkolems);
		if (sources != null)
			for (Map.Entry<String,String> e : sources.entrySet()) {
				Util.encodeXMLs(out, "\n<source filename=\"", e.getKey(), "\" content=\"", e.getValue(), "\"/>\n");
			}
		out.print("\n</alloy>\n");
	} catch (Throwable ex) {
		if (ex instanceof Err)
			throw (Err) ex;
		else
			throw new ErrorFatal("Error writing the solution XML file.", ex);
	}
	if (out.checkError())
		throw new ErrorFatal("Error writing the solution XML file.");
}
 
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:27,代码来源:A4SolutionWriter.java

示例3: doShowParseTree

import edu.mit.csail.sdg.alloy4.A4Reporter; //导入依赖的package包/类
/** This method displays the parse tree. */
private Runner doShowParseTree() {
	if (wrap)
		return wrapMe();
	doRefreshRun();
	OurUtil.enableAll(runmenu);
	if (commands != null) {
		Module world = null;
		try {
			int resolutionMode = (Version.experimental && ImplicitThis.get()) ? 2 : 1;
			A4Options opt = new A4Options();
			opt.tempDirectory = alloyHome() + fs + "tmp";
			opt.solverDirectory = alloyHome() + fs + "binary";
			opt.originalFilename = Util.canon(text.get().getFilename());
			world = CompUtil.parseEverything_fromFile(A4Reporter.NOP, text.takeSnapshot(), opt.originalFilename,
					resolutionMode);
		} catch (Err er) {
			text.shade(er.pos);
			log.logRed(er.toString() + "\n\n");
			return null;
		}
		world.showAsTree(this);
	}
	return null;
}
 
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:26,代码来源:SimpleGUI.java

示例4: writeXML

import edu.mit.csail.sdg.alloy4.A4Reporter; //导入依赖的package包/类
/** Helper method to write out a full XML file. */
public void writeXML(A4Reporter rep, PrintWriter writer, Iterable<Func> macros, Map<String,String> sourceFiles)
		throws Err {
	A4SolutionWriter.writeInstance(rep, this, writer, macros, sourceFiles);
	if (writer.checkError())
		throw new ErrorFatal("Error writing the solution XML file.");
}
 
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:8,代码来源:A4Solution.java

示例5: TranslateAlloyToKodkod

import edu.mit.csail.sdg.alloy4.A4Reporter; //导入依赖的package包/类
/**
 * Construct a translator based on a already-fully-constructed association
 * map.
 * 
 * @param bitwidth - the integer bitwidth to use
 * @param unrolls - the maximum number of loop unrolling and recursion
 *            allowed
 * @param a2k - the mapping from Alloy sig/field/skolem/atom to the
 *            corresponding Kodkod expression
 */
private TranslateAlloyToKodkod(int bitwidth, int unrolls, Map<Expr,Expression> a2k, Map<String,Expression> s2k)
		throws Err {
	this.unrolls = unrolls;
	if (bitwidth < 0)
		throw new ErrorSyntax("Cannot specify a bitwidth less than 0");
	if (bitwidth > 30)
		throw new ErrorSyntax("Cannot specify a bitwidth greater than 30");
	this.rep = A4Reporter.NOP;
	this.cmd = null;
	this.frame = null;
	this.bitwidth = bitwidth;
	this.max = Util.max(bitwidth);
	this.min = Util.min(bitwidth);
	this.a2k = ConstMap.make(a2k);
	this.s2k = ConstMap.make(s2k);
}
 
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:27,代码来源:TranslateAlloyToKodkod.java

示例6: testRecursion

import edu.mit.csail.sdg.alloy4.A4Reporter; //导入依赖的package包/类
@Test
public void testRecursion() throws Exception {
	String filename = "src/test/resources/test-recursion.als";
	Module world = CompUtil.parseEverything_fromFile(A4Reporter.NOP, null, filename);

	A4Options options = new A4Options();
	options.unrolls = 10;
	for (Command command : world.getAllCommands()) {
		A4Solution ans = TranslateAlloyToKodkod.execute_command(A4Reporter.NOP, world.getAllReachableSigs(),
				command, options);
		while (ans.satisfiable()) {
			String hc = "Answer: " + ans.toString().hashCode();
			System.out.println(hc);
			ans = ans.next();
		}
		return;
	}
}
 
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:19,代码来源:AlloyModelsTest.java

示例7: writeInstance

import edu.mit.csail.sdg.alloy4.A4Reporter; //导入依赖的package包/类
/** If this solution is a satisfiable solution, this method will write it out in XML format. */
static void writeInstance(A4Reporter rep, A4Solution sol, PrintWriter out, Iterable<Func> extraSkolems, Map<String,String> sources) throws Err {
    if (!sol.satisfiable()) throw new ErrorAPI("This solution is unsatisfiable.");
    try {
        Util.encodeXMLs(out, "<alloy builddate=\"", Version.buildDate(), "\">\n\n");
        new A4SolutionWriter(rep, sol, sol.getAllReachableSigs(), sol.getBitwidth(), sol.getMaxSeq(), sol.getOriginalCommand(), sol.getOriginalFilename(), out, extraSkolems);
        if (sources!=null) for(Map.Entry<String,String> e: sources.entrySet()) {
            Util.encodeXMLs(out, "\n<source filename=\"", e.getKey(), "\" content=\"", e.getValue(), "\"/>\n");
        }
        out.print("\n</alloy>\n");
    } catch(Throwable ex) {
        if (ex instanceof Err) throw (Err)ex; else throw new ErrorFatal("Error writing the solution XML file.", ex);
    }
    if (out.checkError()) throw new ErrorFatal("Error writing the solution XML file.");
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:16,代码来源:A4SolutionWriter.java

示例8: doShowParseTree

import edu.mit.csail.sdg.alloy4.A4Reporter; //导入依赖的package包/类
/** This method displays the parse tree. */
private Runner doShowParseTree() {
    if (wrap) return wrapMe();
    doRefreshRun();
    OurUtil.enableAll(runmenu);
    if (commands!=null) {
        Module world = null;
        try {
            int resolutionMode = (Version.experimental && ImplicitThis.get()) ? 2 : 1;
            A4Options opt = new A4Options();
            opt.tempDirectory = alloyHome() + fs + "tmp";
            opt.solverDirectory = alloyHome() + fs + "binary";
            opt.originalFilename = Util.canon(text.get().getFilename());
            world = CompUtil.parseEverything_fromFile(A4Reporter.NOP, text.takeSnapshot(), opt.originalFilename, resolutionMode);
        } catch(Err er) {
            text.shade(er.pos);
            log.logRed(er.toString()+"\n\n");
            return null;
        }
        world.showAsTree(this);
    }
    return null;
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:24,代码来源:SimpleGUI.java

示例9: main2

import edu.mit.csail.sdg.alloy4.A4Reporter; //导入依赖的package包/类
/** Displays the amount of memory taken per solution enumeration. */
public static void main2(String[] args) throws Exception {
    String filename = "models/examples/algorithms/dijkstra.als";
    Module world = CompUtil.parseEverything_fromFile(A4Reporter.NOP, null, filename);
    A4Options options = new A4Options();
    for (Command command: world.getAllCommands()) {
        A4Solution ans = TranslateAlloyToKodkod.execute_command(A4Reporter.NOP, world.getAllReachableSigs(), command, options);
        while(ans.satisfiable()) {
            String hc = "Answer: " + ans.toString().hashCode();
            System.gc();
            System.gc();
            System.gc();
            Thread.sleep(500);
            System.gc();
            System.gc();
            System.gc();
            Thread.sleep(500);
            long t = Runtime.getRuntime().totalMemory(), f = Runtime.getRuntime().freeMemory(), m = Runtime.getRuntime().maxMemory();
            System.out.println(hc + " total=" + t + " free=" + f + " max="+m); System.out.flush();
            ans=ans.next();
        }
        return;
    }
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:25,代码来源:InternalTest.java

示例10: writeXML

import edu.mit.csail.sdg.alloy4.A4Reporter; //导入依赖的package包/类
/** Helper method to write out a full XML file. */
private static void writeXML(A4Reporter rep, Module mod, String filename, A4Solution sol,
		Map<String,String> sources) throws Exception {
	sol.writeXML(rep, filename, mod.getAllFunc(), sources);
	if ("yes".equals(System.getProperty("debug")))
		validate(filename);
}
 
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:8,代码来源:SimpleReporter.java

示例11: compileModuleAndRun

import edu.mit.csail.sdg.alloy4.A4Reporter; //导入依赖的package包/类
public static void compileModuleAndRun(String model) throws Err {
	A4Reporter rep = new A4Reporter();

	// parse model from string
	CompModule world = CompUtil.parseEverything_fromString(rep, model);
	ConstList<Command> commands = world.getAllCommands();
	if (commands.size() != 1)
		throw new ErrorAPI("Must specify exactly one command; number of commands found: " + commands.size());
	Command cmd = commands.get(0);
	A4Options opt = new A4Options();
	opt.solver = A4Options.SatSolver.SAT4J;

	// solve
	A4Solution sol = TranslateAlloyToKodkod.execute_command(rep, world.getAllSigs(), cmd, opt);

	// print solution
	System.out.println(sol);

	for (Sig sig : world.getAllReachableSigs()) {
		System.out.println("traversing sig: " + sig);
		SafeList<Field> fields = sig.getFields();
		for (Field field : fields) {
			System.out.println("  traversing field: " + field);
			A4TupleSet ts = (A4TupleSet) (sol.eval(field));
			for (A4Tuple t : ts) {
				System.out.print("    [");
				for (int i = 0; i < t.arity(); i++)
					System.out.print(t.atom(i) + " ");
				System.out.println("]");
			}
		}
	}
}
 
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:34,代码来源:ExampleCompilingFromSource.java

示例12: main2

import edu.mit.csail.sdg.alloy4.A4Reporter; //导入依赖的package包/类
/** Displays the amount of memory taken per solution enumeration. */
public static void main2(String[] args) throws Exception {
	String filename = "models/examples/algorithms/dijkstra.als";
	Module world = CompUtil.parseEverything_fromFile(A4Reporter.NOP, null, filename);
	A4Options options = new A4Options();
	for (Command command : world.getAllCommands()) {
		A4Solution ans = TranslateAlloyToKodkod.execute_command(A4Reporter.NOP, world.getAllReachableSigs(),
				command, options);
		while (ans.satisfiable()) {
			String hc = "Answer: " + ans.toString().hashCode();
			System.gc();
			System.gc();
			System.gc();
			Thread.sleep(500);
			System.gc();
			System.gc();
			System.gc();
			Thread.sleep(500);
			long t = Runtime.getRuntime().totalMemory(), f = Runtime.getRuntime().freeMemory(),
					m = Runtime.getRuntime().maxMemory();
			System.out.println(hc + " total=" + t + " free=" + f + " max=" + m);
			System.out.flush();
			ans = ans.next();
		}
		return;
	}
}
 
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:28,代码来源:InternalTest.java

示例13: resolveAssertions

import edu.mit.csail.sdg.alloy4.A4Reporter; //导入依赖的package包/类
/**
 * Each assertion name now points to a typechecked Expr rather than an
 * untypechecked Exp.
 */
private JoinableList<Err> resolveAssertions(A4Reporter rep, JoinableList<Err> errors, List<ErrorWarning> warns)
		throws Err {
	Context cx = new Context(this, warns);
	for (Map.Entry<String,Expr> e : asserts.entrySet()) {
		Expr expr = e.getValue();
		expr = cx.check(expr).resolve_as_formula(warns);
		if (expr.errors.isEmpty()) {
			e.setValue(expr);
			rep.typecheck("Assertion " + e.getKey() + ": " + expr.type() + "\n");
		} else
			errors = errors.make(expr.errors);
	}
	return errors;
}
 
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:19,代码来源:CompModule.java

示例14: resolveFacts

import edu.mit.csail.sdg.alloy4.A4Reporter; //导入依赖的package包/类
/**
 * Each fact name now points to a typechecked Expr rather than an
 * untypechecked Exp; we'll also add the sig appended facts.
 */
private JoinableList<Err> resolveFacts(CompModule res, A4Reporter rep, JoinableList<Err> errors,
		List<ErrorWarning> warns) throws Err {
	Context cx = new Context(this, warns);
	for (int i = 0; i < facts.size(); i++) {
		String name = facts.get(i).a;
		Expr expr = facts.get(i).b;
		Expr checked = cx.check(expr);
		expr = checked.resolve_as_formula(warns);
		if (expr.errors.isEmpty()) {
			facts.set(i, new Pair<String,Expr>(name, expr));
			rep.typecheck("Fact " + name + ": " + expr.type() + "\n");
		} else
			errors = errors.make(expr.errors);
	}
	for (Sig s : sigs.values()) {
		Expr f = res.old2appendedfacts.get(res.new2old.get(s));
		if (f == null)
			continue;
		if (f instanceof ExprConstant && ((ExprConstant) f).op == ExprConstant.Op.TRUE)
			continue;
		Expr formula;
		cx.rootsig = s;
		if (s.isOne == null) {
			cx.put("this", s.decl.get());
			formula = cx.check(f).resolve_as_formula(warns);
		} else {
			cx.put("this", s);
			formula = cx.check(f).resolve_as_formula(warns);
		}
		cx.remove("this");
		if (formula.errors.size() > 0)
			errors = errors.make(formula.errors);
		else {
			s.addFact(formula);
			rep.typecheck("Fact " + s + "$fact: " + formula.type() + "\n");
		}
	}
	return errors;
}
 
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:44,代码来源:CompModule.java

示例15: validate

import edu.mit.csail.sdg.alloy4.A4Reporter; //导入依赖的package包/类
public static boolean validate(final String atomType) {
  final InstanceTranslatorReasoningForAtom instanceTranslator =
      new InstanceTranslatorReasoningForAtom(atomType);
  instanceTranslator.translate();
  AlloyValidatorReasoningForAtom.reasonRelations = instanceTranslator.getReasonRelations();

  final String filename = instanceTranslator.getBaseFileDirectory() + "reasoningForAtom.als";

  try {
    final A4Reporter rep = new A4Reporter() {
      @Override
      public void warning(final ErrorWarning msg) {
        System.out.print("Relevance Warning:\n" + msg.toString().trim() + "\n\n");
        System.out.flush();
      }
    };
    Module world = null;

    world = CompUtil.parseEverything_fromFile(rep, null, filename);

    final A4Options options = new A4Options();
    options.solver = A4Options.SatSolver.SAT4J;

    for (final Command command : world.getAllCommands()) {
      A4Solution ans = null;
      ans = TranslateAlloyToKodkod.execute_command(rep, world.getAllReachableSigs(), command,
          options);

      if (ans.satisfiable()) {
        return true;
      }
    }

  } catch (final Err e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
  }

  return false;
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:41,代码来源:AlloyValidatorReasoningForAtom.java


注:本文中的edu.mit.csail.sdg.alloy4.A4Reporter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。