當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。