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


Java A4Options类代码示例

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


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

示例1: doShowParseTree

import edu.mit.csail.sdg.alloy4compiler.translator.A4Options; //导入依赖的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

示例2: main2

import edu.mit.csail.sdg.alloy4compiler.translator.A4Options; //导入依赖的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

示例3: validate

import edu.mit.csail.sdg.alloy4compiler.translator.A4Options; //导入依赖的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

示例4: validate

import edu.mit.csail.sdg.alloy4compiler.translator.A4Options; //导入依赖的package包/类
public static boolean validate() {
  AlloyValidator.isCanceled = false;
  final InstanceTranslator instanceTranslator = new InstanceTranslator();
  instanceTranslator.translate();

  final String filename = instanceTranslator.getBaseFileDirectory() + "validation.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) {
    e.printStackTrace();
  }
  return false;
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:37,代码来源:AlloyValidator.java

示例5: validate

import edu.mit.csail.sdg.alloy4compiler.translator.A4Options; //导入依赖的package包/类
public static boolean validate() {
  final InstanceTranslatorDiscovering instanceTranslator = new InstanceTranslatorDiscovering();
  instanceTranslator.translate();
  AlloyValidatorDiscovering.discoverSigs = instanceTranslator.getDiscoverSig2ExpectValue();

  final String filename = instanceTranslator.getBaseFileDirectory() + "discovering.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) {
    e.printStackTrace();
  }

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

示例6: validate

import edu.mit.csail.sdg.alloy4compiler.translator.A4Options; //导入依赖的package包/类
public static boolean validate() {
  final InstanceTranslatorReasoning instanceTranslator = new InstanceTranslatorReasoning();
  instanceTranslator.translate();
  AlloyValidatorReasoning.reasonRelations = instanceTranslator.getReasonRelations();

  final String filename = instanceTranslator.getBaseFileDirectory() + "reasoning.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,代码行数:40,代码来源:AlloyValidatorReasoning.java

示例7: executeCommand

import edu.mit.csail.sdg.alloy4compiler.translator.A4Options; //导入依赖的package包/类
/**
 * Executes given command
 * 
 * @param command to run
 * @return solution if it is satisfiable else null
 * @throws Err
 */
public A4Solution executeCommand(Command command) throws Err {
  if (world == null)
    return null;

  final A4Options options = new A4Options();
  options.solver = A4Options.SatSolver.SAT4J;
  A4Solution solution =
      TranslateAlloyToKodkod.execute_command(rep, world.getAllReachableSigs(), command, options);
  if (solution.satisfiable()) {
    return solution;
  }

  return null;
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:22,代码来源:AlloyExecuter.java

示例8: runFor3

import edu.mit.csail.sdg.alloy4compiler.translator.A4Options; //导入依赖的package包/类
void runFor3(Expr expr) throws Err {
    A4Options opt = new A4Options();
    Command cmd = new Command(false, 3, 3, 3, expr.and(fact));
    A4Solution sol = TranslateAlloyToKodkod.execute_command(NOP, sigs, cmd, opt);
    System.out.println(sol.toString().trim());
    if (sol.satisfiable()) {
        System.out.println("In particular, File = " + sol.eval(file));
        System.out.println("In particular, Dir = " + sol.eval(dir));
        System.out.println("In particular, contains = " + sol.eval(contains));
        System.out.println("In particular, parent = " + sol.eval(parent));
    }
    System.out.println();
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:14,代码来源:DemoFileSystem.java

示例9: doRun

import edu.mit.csail.sdg.alloy4compiler.translator.A4Options; //导入依赖的package包/类
/** This method executes a particular RUN or CHECK command. */
private Runner doRun(Integer commandIndex) {
    if (wrap) return wrapMe(commandIndex);
    final int index = commandIndex;
    if (WorkerEngine.isBusy()) return null;
    if (index==(-2)) subrunningTask=1; else subrunningTask=0;
    latestAutoInstance="";
    if (index>=0) latestCommand=index;
    if (index==-1 && commands!=null) {
        latestCommand=commands.size()-1;
        if (latestCommand<0) latestCommand=0;
    }
    // To update the accelerator to point to the command actually chosen
    doRefreshRun();
    OurUtil.enableAll(runmenu);
    if (commands==null) return null;
    if (commands.size()==0 && index!=-2 && index!=-3) { log.logRed("There are no commands to execute.\n\n"); return null; }
    int i=index;
    if (i>=commands.size()) i=commands.size()-1;
    SimpleCallback1 cb = new SimpleCallback1(this, null, log, Verbosity.get().ordinal(), latestAlloyVersionName, latestAlloyVersion);
    SimpleTask1 task = new SimpleTask1();
    A4Options opt = new A4Options();
    opt.tempDirectory = alloyHome() + fs + "tmp";
    opt.solverDirectory = alloyHome() + fs + "binary";
    opt.recordKodkod = RecordKodkod.get();
    opt.noOverflow = NoOverflow.get();
    opt.unrolls = Version.experimental ? Unrolls.get() : (-1);
    opt.skolemDepth = SkolemDepth.get();
    opt.coreMinimization = CoreMinimization.get();
    opt.coreGranularity = CoreGranularity.get();
    opt.originalFilename = Util.canon(text.get().getFilename());
    opt.solver = SatSolver.get();
    task.bundleIndex = i;
    task.bundleWarningNonFatal = WarningNonfatal.get();
    task.map = text.takeSnapshot();
    task.options = opt.dup();
    task.resolutionMode = (Version.experimental && ImplicitThis.get()) ? 2 : 1;
    task.tempdir = maketemp();
    try {
        runmenu.setEnabled(false);
        runbutton.setVisible(false);
        showbutton.setEnabled(false);
        stopbutton.setVisible(true);
        int newmem = SubMemory.get(), newstack = SubStack.get();
        if (newmem != subMemoryNow || newstack != subStackNow) WorkerEngine.stop();
        if ("yes".equals(System.getProperty("debug")) && Verbosity.get()==Verbosity.FULLDEBUG)
            WorkerEngine.runLocally(task, cb);
        else
            WorkerEngine.run(task, newmem, newstack, alloyHome() + fs + "binary", "", cb);
        subMemoryNow = newmem;
        subStackNow = newstack;
    } catch(Throwable ex) {
        WorkerEngine.stop();
        log.logBold("Fatal Error: Solver failed due to unknown reason.\n" +
          "One possible cause is that, in the Options menu, your specified\n" +
          "memory size is larger than the amount allowed by your OS.\n" +
          "Also, please make sure \"java\" is in your program path.\n");
        log.logDivider();
        log.flush();
        doStop(2);
    }
    return null;
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:64,代码来源:SimpleGUI.java

示例10: main

import edu.mit.csail.sdg.alloy4compiler.translator.A4Options; //导入依赖的package包/类
public static void main(String[] args) throws Err {

        // Chooses the Alloy4 options
        A4Options opt = new A4Options();
        opt.solver = A4Options.SatSolver.SAT4J;

        // abstract sig A {}
        PrimSig A = new PrimSig("A", Attr.ABSTRACT);

        // sig B {}
        PrimSig B = new PrimSig("B");

        // one sig A1 extends A {}
        PrimSig A1 = new PrimSig("A1", A, Attr.ONE);

        // one sig A2 extends A {}
        PrimSig A2 = new PrimSig("A2", A, Attr.ONE);

        // A { f: B lone->lone B }
        Expr f = A.addField("f", B.lone_arrow_lone(B));
        // Since (B lone->lone B) is not unary,  the default is "setOf",  meaning "f:set (B lone->lone B)"

        // A { g: B }
        Expr g = A.addField("g", B);
        // The line above is the same as:   A.addField(null, "g", B.oneOf())  since B is unary.
        // If you want "setOf", you need:   A.addField(null, "g", B.setOf())

        // pred someG { some g }
        Func someG = new Func(null, "SomeG", null, null, g.some());

        // pred atMostThree[x:univ, y:univ] { #(x+y) >= 3 }
        Decl x = UNIV.oneOf("x");
        Decl y = UNIV.oneOf("y");
        Expr body = x.get().plus(y.get()).cardinality().lte(ExprConstant.makeNUMBER(3));
        Func atMost3 = new Func(null, "atMost3", Util.asList(x,y), null, body);

        List<Sig> sigs = Arrays.asList(new Sig[]{A, B, A1, A2});

        // run { some A && atMostThree[B,B] } for 3 but 3 int, 3 seq
        Expr expr1 = A.some().and(atMost3.call(B,B));
        Command cmd1 = new Command(false, 3, 3, 3, expr1);
        A4Solution sol1 = TranslateAlloyToKodkod.execute_command(NOP, sigs, cmd1, opt);
        System.out.println("[Solution1]:");
        System.out.println(sol1.toString());

        // run { some f && SomeG[] } for 3 but 2 int, 1 seq, 5 A, exactly 6 B
        Expr expr2 = f.some().and(someG.call());
        Command cmd2 = new Command(false, 3, 2, 1, expr2);
        cmd2 = cmd2.change(A, false, 5);
        cmd2 = cmd2.change(B, true, 6);
        A4Solution sol2 = TranslateAlloyToKodkod.execute_command(NOP, sigs, cmd2, opt);
        System.out.println("[Solution2]:");
        System.out.println(sol2.toString());
    }
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:55,代码来源:ExampleUsingTheAPI.java


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