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


Java Instance类代码示例

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


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

示例1: testDeepSkolems

import kodkod.instance.Instance; //导入依赖的package包/类
public final void testDeepSkolems() {
	solver.options().setSkolemDepth(3);
	testDeepSkolems(Multiplicity.ONE);
	testDeepSkolems(Multiplicity.LONE);
	testDeepSkolems(Multiplicity.SOME);
	testDeepSkolems(Multiplicity.SET);
	final Variable va = Variable.unary("va");
	final Variable vb = Variable.unary("vb");
	Decl da1 = va.oneOf(r1a);
	Decl db = vb.oneOf(r1b);
	final Formula f0 = va.in(vb.join(r2b));
	final Formula f1 = f0.forAll(db).not().forAll(da1);
	final Formula f2 = f0.forSome(db).forSome(da1);
	Instance inst = solve(f1.and(f2));
	assertEquals(bounds.relations().size() + 3, inst.relations().size());
}
 
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:17,代码来源:SkolemizationTest.java

示例2: testEmina_01232006

import kodkod.instance.Instance; //导入依赖的package包/类
public final void testEmina_01232006() {
	final List<String> atoms = new ArrayList<String>(5);
	for (int i = 0; i < 5; i++)
		atoms.add("a" + i);
	final Universe u = new Universe(atoms);
	final TupleFactory tf = u.factory();

	final Relation r1 = Relation.unary("r1"), r2 = Relation.binary("r2"), r3 = Relation.ternary("r3");
	final Bounds b = new Bounds(u);
	final TupleSet r2Bound = tf.noneOf(2);
	for (int i = 0; i < 4; i++)
		r2Bound.add(tf.tuple(atoms.get(i), atoms.get(i)));
	r2Bound.add(tf.tuple("a4", "a1"));
	r2Bound.add(tf.tuple("a4", "a2"));
	b.bound(r2, r2Bound);
	b.bound(r1, tf.setOf("a0", "a3"), tf.setOf("a0", "a3", "a4"));
	b.bound(r3, tf.setOf(tf.tuple("a0", "a0", "a0"), tf.tuple("a3", "a3", "a3")));
	final Formula f = r1.product(r2).in(r3);

	final Instance instance = solver.solve(f, b).instance();
	assertTrue((new Evaluator(instance)).evaluate(f));
	// System.out.println(instance);
	// System.out.println((new Evaluator(instance)).evaluate(f ));

}
 
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:26,代码来源:BugTests.java

示例3: interpret

import kodkod.instance.Instance; //导入依赖的package包/类
/**
	 * If this.solver.solve() is true, returns 
	 * an interpretation of the cnf solution as a 
	 * mapping from Relations to sets of Tuples.  The Relations
	 * mapped by the returned instance are either leaves
	 * of this.formula with different lower and upper
	 * bounds (i.e. {r: this.formula.*children & Relation | 
	 * this.bounds.upperBound[r] != this.bounds.lowerBound[r]}), 
	 * or skolem constants.
	 * @return an interpretation of the cnf solution as
	 * a mapping from (this.variableUsage().keySet() & Relation) to sets of Tuples.
	 * @throws IllegalStateException - this.solver.solve() has not been called or the 
	 * outcome of the last call was not <code>true</code>.
	 */
	public Instance interpret() {
		final TupleFactory f = bounds.universe().factory();
		final Instance instance = new Instance(bounds.universe());
//		System.out.println(varUsage);
		for(Relation r : bounds.relations()) {
			TupleSet lower = bounds.lowerBound(r);
			IntSet indeces = Ints.bestSet(lower.capacity());
			indeces.addAll(lower.indexView());
			IntSet vars = primaryVarUsage.get(r);
			if (vars!=null) {
				int lit = vars.min();
				for(IntIterator iter = bounds.upperBound(r).indexView().iterator(); iter.hasNext();) {
					final int index = iter.next();
					if (!indeces.contains(index) && solver.valueOf(lit++))
						indeces.add(index);
				}
			}
			instance.add(r, f.setOf(r.arity(), indeces));
		}
		return instance;
	}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:36,代码来源:Translation.java

示例4: print

import kodkod.instance.Instance; //导入依赖的package包/类
/**
	 * Prints the given solution using the given options to the console
	 */
	void print(Instance instance, Options options) {
		final Evaluator eval = new Evaluator(instance, options);
		final int n = instance.universe().size();
		for(int i = 0; i < n; i++) { 
			Expression x = IntConstant.constant(i).toExpression();
			for(int j = 0; j < n; j++) { 
				Expression y = IntConstant.constant(j).toExpression();
				if (eval.evaluate(x.product(y).in(queen))) { 
					System.out.print(" Q");
				} else {
					System.out.print(" .");
				}
			}
			System.out.println();
		}
//		System.out.println(instance); 
	}
 
开发者ID:emina,项目名称:kodkod,代码行数:21,代码来源:BlockedNQueens2.java

示例5: print

import kodkod.instance.Instance; //导入依赖的package包/类
/**
	 * Prints the given solution using the given options to the console
	 */
	void print(Instance instance, Options options) {
		final Evaluator eval = new Evaluator(instance, options);
		final int n = instance.tuples(queen).size();
		for(int i = 0; i < n; i++) { 
			Expression ci = IntConstant.constant(i).toExpression();
			for(int j = 0; j < n; j++) { 
				Expression cj = IntConstant.constant(j).toExpression();
				if (eval.evaluate(x.join(ci).intersection(y.join(cj)).some())) { 
					System.out.print(" Q");
				} else {
					System.out.print(" .");
				}
			}
			System.out.println();
		}
//		System.out.println(instance); 
	}
 
开发者ID:emina,项目名称:kodkod,代码行数:21,代码来源:BlockedNQueens.java

示例6: print

import kodkod.instance.Instance; //导入依赖的package包/类
/**
		 * Prints the given solution
		 */
		void print(Instance instance, Options options) {
			final Evaluator eval = new Evaluator(instance, options);
			for(int i = 0; i < n; i++) { 
				Expression ci = IntConstant.constant(i).toExpression();
				for(int j = 0; j < n; j++) { 
					Expression cj = IntConstant.constant(j).toExpression();
					if (eval.evaluate(x.join(ci).intersection(y.join(cj)).some())) { 
						System.out.print(" Q");
					} else {
						System.out.print(" .");
					}
				}
				System.out.println();
			}
//			System.out.println(instance); 
		}
 
开发者ID:emina,项目名称:kodkod,代码行数:20,代码来源:NQueens.java

示例7: testDeepSkolems

import kodkod.instance.Instance; //导入依赖的package包/类
@Test
public final void testDeepSkolems() {
	solver.options().setSkolemDepth(3);
	testDeepSkolems(Multiplicity.ONE);
	testDeepSkolems(Multiplicity.LONE);
	testDeepSkolems(Multiplicity.SOME);
	testDeepSkolems(Multiplicity.SET);
	final Variable va = Variable.unary("va");
	final Variable vb = Variable.unary("vb");
	Decl da1 = va.oneOf(r1a);
	Decl db = vb.oneOf(r1b);
	final Formula f0 = va.in(vb.join(r2b));
	final Formula f1 = f0.forAll(db).not().forAll(da1);
	final Formula f2 = f0.forSome(db).forSome(da1);
	Instance inst = solve(f1.and(f2));
	assertEquals(bounds.relations().size()+3, inst.relations().size());
}
 
开发者ID:emina,项目名称:kodkod,代码行数:18,代码来源:SkolemizationTest.java

示例8: Evaluator

import kodkod.instance.Instance; //导入依赖的package包/类
/**
 * Constructs a new Evaluator for the given instance and options
 * 
 * @ensures this.instance' = instance && this.options' = options
 * @throws NullPointerException instance = null || options = null
 */
public Evaluator(Instance instance, Options options) {
	if (instance == null || options == null)
		throw new NullPointerException();
	this.instance = instance;
	this.options = options;
}
 
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:13,代码来源:Evaluator.java

示例9: holFixpointIncrementingOutcome

import kodkod.instance.Instance; //导入依赖的package包/类
@Override
public void holFixpointIncrementingOutcome(HOLTranslation tr, Instance next) {
	if (next != null)
		System.out.println(String.format("  [%s]   climbed one step", tr));
	else
		System.out.println(String.format("  [%s]   fixpoint reached", tr));
}
 
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:8,代码来源:ConsoleReporter.java

示例10: Solution

import kodkod.instance.Instance; //导入依赖的package包/类
/**
 * Constructs a Solution from the given values.
 * 
 * @requires outcome != null && stats != null
 * @requires outcome = SATISFIABLE || TRIVIALLY_SATISFIABLE => instance !=
 *           null
 */
private Solution(Outcome outcome, Statistics stats, Instance instance, Proof proof) {
	assert outcome != null && stats != null;
	this.outcome = outcome;
	this.stats = stats;
	this.instance = instance;
	this.proof = proof;
}
 
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:15,代码来源:Solution.java

示例11: display

import kodkod.instance.Instance; //导入依赖的package包/类
/**
 * Displays an instance obtained with the given options.
 * 
 * @requires inst != null and opt != null
 */
private final void display(Instance inst, Options opt) {
	final Universe univ = inst.universe();
	final Evaluator eval = new Evaluator(inst, opt);
	final TupleFactory factory = univ.factory();
	final List<TupleSet> subnets = new ArrayList<TupleSet>();

	System.out.println("address\t\tnetwork id\tmask\tdevice-interface");
	for (int i = 0, ports = univ.size() - 32; i < ports; i++) {
		final Object atom = univ.atom(i);
		final Relation p = Relation.unary(atom.toString());
		inst.add(p, factory.setOf(atom));

		System.out.print(toQuad(eval.evaluate(addr(p))) + "\t");
		System.out.print(toQuad(eval.evaluate(netid(p))) + "\t");
		System.out.print(eval.evaluate(implicitMask(p)) + "\t");
		System.out.println(p);

		final TupleSet members = eval.evaluate(subnet(p));
		if (!members.isEmpty())
			subnets.add(members);
	}

	System.out.println("\nsubnets:");
	for (TupleSet sub : subnets) {
		System.out.println(sub);
	}

}
 
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:34,代码来源:ConfigAssure.java

示例12: displayOp

import kodkod.instance.Instance; //导入依赖的package包/类
private static void displayOp(Instance instance, Relation op) {
	System.out.println("\n" + op + ":");
	final Iterator<Tuple> iter = instance.tuples(op).iterator();
	for (int i = 0; i < 7; i++) {
		for (int j = 0; j < 7; j++) {
			System.out.print(iter.next().atom(2));
			System.out.print("\t");
		}
		System.out.println();
	}
}
 
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:12,代码来源:ALG195_1.java

示例13: display

import kodkod.instance.Instance; //导入依赖的package包/类
/**
 * Prints the values of the op1, op2, and h1-h7 relations to standard out.
 */
void display(Instance instance) {
	displayOp(instance, op1);
	displayOp(instance, op2);
	for (int i = 0; i < 7; i++) {
		System.out.println("\n" + h[i] + ":");
		System.out.println(instance.tuples(h[i]));
	}
}
 
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:12,代码来源:ALG195_1.java

示例14: display

import kodkod.instance.Instance; //导入依赖的package包/类
private final void display(Instance instance, Options options) {
	final Evaluator eval = new Evaluator(instance, options);
	for (int i = 0; i < 2; i++) {
		System.out.print("                      | ");
		System.out.print(instance.tuples(x[i]).indexView().min());
		System.out.println(" |");
	}

	for (int i = 0; i < rows; i++) {
		System.out.print("| ");
		for (int j = 0; j < cols; j++) {
			System.out.print(instance.tuples(a[i][j]).isEmpty() ? 0 : 1);
			System.out.print(" ");
		}
		System.out.print(i == 1 ? "| * | " : "|   | ");
		System.out.print(instance.tuples(x[i + 2]).indexView().min());
		System.out.print(i == 1 ? " | = | " : " |   | ");
		System.out.print(eval.evaluate(b[i]));
		System.out.println(" |");
	}

	for (int i = 5; i < 8; i++) {
		System.out.print("                      | ");
		System.out.print(instance.tuples(x[i]).indexView().min());
		System.out.println(" |");
	}

	// for(int i = 0; i < 3; i++)
	// System.out.println(b[i]);
	//
	// for(int i = 0; i < rows; i++) {
	// for(int j = 0 ; j < 8; j++) {
	// IntExpression e0 = x[j].sum();
	// IntExpression e1 = a[i][j].some().thenElse(e0,
	// IntConstant.constant(0));
	// System.out.println(e0 + " : " + eval.evaluate(e0));
	// System.out.println(e1 + " : " + eval.evaluate(e1));
	// }
	// }
}
 
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:41,代码来源:Viktor.java

示例15: testIntersectionMultiplicity

import kodkod.instance.Instance; //导入依赖的package包/类
private final void testIntersectionMultiplicity(Multiplicity mult, Relation p, Relation q, Tuple intersection) {
	final Instance m = solve(p.intersection(q).apply(mult));
	assertNotNull(m);
	final Set<Tuple> ps = m.tuples(p), qs = m.tuples(q);
	assertFalse(ps.isEmpty());
	assertFalse(qs.isEmpty());
	assertTrue(ps.contains(intersection));
	assertTrue(qs.contains(intersection));
}
 
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:10,代码来源:TranslatorTest.java


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