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


Java TranslateAlloyToKodkod.execute_command方法代码示例

本文整理汇总了Java中edu.mit.csail.sdg.alloy4compiler.translator.TranslateAlloyToKodkod.execute_command方法的典型用法代码示例。如果您正苦于以下问题:Java TranslateAlloyToKodkod.execute_command方法的具体用法?Java TranslateAlloyToKodkod.execute_command怎么用?Java TranslateAlloyToKodkod.execute_command使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在edu.mit.csail.sdg.alloy4compiler.translator.TranslateAlloyToKodkod的用法示例。


在下文中一共展示了TranslateAlloyToKodkod.execute_command方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main2

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

示例2: validate

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

示例3: validate

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

示例4: validate

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

示例5: validate

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

示例6: executeCommand

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

示例7: runFor3

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

示例8: main

import edu.mit.csail.sdg.alloy4compiler.translator.TranslateAlloyToKodkod; //导入方法依赖的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.TranslateAlloyToKodkod.execute_command方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。