• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java ReductionStrategy类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: testProofExtractor

import kodkod.engine.satlab.ReductionStrategy; //导入依赖的package包/类
private final void testProofExtractor(Class<?>[] probs, Class<? extends ReductionStrategy> strategy, int maxScope) { 
	for(Class<?> prob : probs) { 
		Object instance = instance(prob);
		Map<Method, Formula> checks = invokeAll(instance, checks(prob));
		for(Formula check : checks.values()) { 
			for(int scope = 1; scope <= maxScope; scope++ ) { 
				Bounds bounds = bounds(instance, scope);
				Solution sol = solver.solve(check, bounds);
				if (sol.outcome()==Solution.Outcome.UNSATISFIABLE) {
					minimizeAndVerify(check, bounds, sol.proof(), strategy(strategy, sol.proof().log()));
				} 
			}
		}
		
	}
}
 
开发者ID:emina,项目名称:kodkod,代码行数:17,代码来源:UCoreTest.java


示例2: findStrategy

import kodkod.engine.satlab.ReductionStrategy; //导入依赖的package包/类
/**
 * @return strategy with the given name
 */
@SuppressWarnings("unchecked")
private static Class< ? extends ReductionStrategy> findStrategy(String className) {
	try {
		final Class< ? > c = Class.forName(className);
		if (ReductionStrategy.class.isAssignableFrom(c))
			return (Class<ReductionStrategy>) c;
		else {
			throw new IllegalArgumentException(className + " is not a known strategy.");
		}
	} catch (ClassNotFoundException e) {
		throw new IllegalArgumentException(className + " is not a known strategy.");
	}
}
 
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:17,代码来源:UCoreStats.java


示例3: findMinCore

import kodkod.engine.satlab.ReductionStrategy; //导入依赖的package包/类
/**
 * Runs the minimal core finder using the specified strategy (with the given
 * resolution depth, if applicable) on the given methods, bounds, and prints
 * out results using the given results printer.
 */
private static void findMinCore(final Class< ? extends ReductionStrategy> strategy, final int depth,
		final Map<Method,Formula> checks, final Bounds bounds, final ResultPrinter out) {

	try {

		final Solver solver = solver();
		final ThreadMXBean bean = ManagementFactory.getThreadMXBean();
		bean.setThreadCpuTimeEnabled(true);
		for (Map.Entry<Method,Formula> check : checks.entrySet()) {
			// System.out.println(PrettyPrinter.print(check.getValue(), 1));
			Solution sol = solver.solve(check.getValue(), bounds);

			if (sol.outcome() == Solution.Outcome.UNSATISFIABLE) {

				final long start = bean.getCurrentThreadUserTime() / 1000000;
				final Set<Formula> initialCore = Nodes.minRoots(check.getValue(),
						sol.proof().highLevelCore().values());
				final Set<Formula> minCore;

				if (strategy == null) { // no strategy -- one-step
					minCore = initialCore;
				} else {
					if (strategy.getSimpleName().startsWith("RCE")) {
						sol.proof().minimize(strategy(strategy, sol.proof().log(), depth));
					} else {
						sol.proof().minimize(strategy(strategy, sol.proof().log()));
					}
					minCore = Nodes.minRoots(check.getValue(), sol.proof().highLevelCore().values());
				}
				final long end = bean.getCurrentThreadUserTime() / 1000000;

				out.printUnsat(check.getKey().getName(), check.getValue(), bounds, sol.stats(), initialCore,
						minCore, end - start);
 
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:39,代码来源:UCoreStats.java


示例4: minimizeAndVerify

import kodkod.engine.satlab.ReductionStrategy; //导入依赖的package包/类
private final void minimizeAndVerify(Formula formula, Bounds bounds, Proof proof, ReductionStrategy strategy) { 
	proof.minimize(strategy);
	final Set<Formula> core = Nodes.allRoots(formula, proof.highLevelCore().values());
	final Set<Formula> tcore = proof.highLevelCore().keySet();
	verify(tcore, proof.log().bounds());
	if (solver.options().coreGranularity()==0) { 
		assertEquals(tcore.size(), core.size());
		verify(core, bounds);
	} else {
		assertNull(vSolver.solve(Formula.and(core), bounds).instance());
	}
}
 
开发者ID:emina,项目名称:kodkod,代码行数:13,代码来源:UCoreTest.java


示例5: unsatCore

import kodkod.engine.satlab.ReductionStrategy; //导入依赖的package包/类
@Override
public String unsatCore() {
    Proof proof = solution.proof();
    if (proof == null)
        return "unknown";
    ReductionStrategy strategy = new AdaptiveRCEStrategy(proof.log()); 
    proof.minimize(strategy);
    int minCore = proof.highLevelCore().size();
    StringBuilder sb = new StringBuilder(); 
    sb.append("Core (size="+minCore+"):\n");
    for(Node n : proof.highLevelCore().values()) { 
        sb.append(PrettyPrinter.print(n, 0)).append("\n");
    }
    return sb.toString();
}
 
开发者ID:aleksandarmilicevic,项目名称:squander,代码行数:16,代码来源:SquanderKodkodImpl.java


示例6: minimize

import kodkod.engine.satlab.ReductionStrategy; //导入依赖的package包/类
/**
 * {@inheritDoc}
 * 
 * @see kodkod.engine.Proof#minimize(kodkod.engine.satlab.ReductionStrategy)
 */
public void minimize(ReductionStrategy strategy) {
	solver.reduce(strategy);
	coreFilter = null;
	coreRoots = null;
}
 
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:11,代码来源:ResolutionBasedProof.java


示例7: minimize

import kodkod.engine.satlab.ReductionStrategy; //导入依赖的package包/类
/**
 * Minimizes the current core using the trivial strategy that does one of
 * the following: (1) if there is a root that simplified to FALSE, sets the
 * minimal core to that root; or (2) if not, there must be two roots that
 * translated to x and -x, where x is a boolean literal, so we pick those
 * two as the minimal core. The strategy argument is ignored (it can be
 * null).
 * 
 * @see Proof#minimize(ReductionStrategy)
 */
@Override
public void minimize(ReductionStrategy strategy) {
	final Map<Formula,int[]> rootLits = new LinkedHashMap<Formula,int[]>();
	final Map<Formula,Node> rootNodes = new LinkedHashMap<Formula,Node>();
	final Set<Formula> roots = log().roots();

	for (Iterator<TranslationRecord> itr = core(); itr.hasNext();) {
		final TranslationRecord rec = itr.next();
		if (roots.contains(rec.translated())) {
			// simply record the most recent output value for each formula:
			// this is guaranteed to be the final output value for that
			// formula because of the translation log guarantee that the
			// log is replayed in the order of translation: i.e. a child's
			// output value is always recorded before the parent's
			int[] val = rootLits.get(rec.translated());
			if (val == null) {
				val = new int[1];
				rootLits.put(rec.translated(), val);
			}
			val[0] = rec.literal();
			rootNodes.put(rec.translated(), rec.node());
		}
	}

	final SparseSequence<Formula> lits = new TreeSequence<Formula>();
	for (Map.Entry<Formula,int[]> entry : rootLits.entrySet()) {
		final int lit = entry.getValue()[0];
		if (lit == -Integer.MAX_VALUE) {
			coreRoots = Collections.singletonMap(entry.getKey(), rootNodes.get(entry.getKey()));
			break;
		} else if (lits.containsIndex(-lit)) {
			final Formula f0 = lits.get(-lit);
			final Formula f1 = entry.getKey();
			coreRoots = new LinkedHashMap<Formula,Node>(3);
			coreRoots.put(f0, rootNodes.get(f0));
			coreRoots.put(f1, rootNodes.get(f1));
			coreRoots = Collections.unmodifiableMap(coreRoots);
			break;
		} else {
			lits.put(lit, entry.getKey());
		}
	}

	coreFilter = null;
	assert coreRoots.size() == 1 && rootLits.get(coreRoots.keySet().iterator().next())[0] == -Integer.MAX_VALUE
			|| coreRoots.size() == 2;
}
 
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:58,代码来源:TrivialProof.java


示例8: main

import kodkod.engine.satlab.ReductionStrategy; //导入依赖的package包/类
/**
 * Usage: java tests.benchmarks.UCoreStats <class> <scope> [-m method] [-s
 * strategy | oce] [-d depth] [-o (user | stats) ]
 */
public static void main(String[] args) {
	if (args.length < 2)
		usage();
	final Class< ? > problem = findClass(args[0]);
	final Map<String,String> optional = processOptionalArgs(args);

	final Object instance = instance(problem);
	final Bounds bounds = bounds(instance, scope(args[1]));
	final Map<Method,Formula> checks = invokeAll(instance,
			optional.containsKey("-m") ? Collections.singleton(formulaCreator(problem, optional.get("-m")))
					: checks(problem));

	if (checks.isEmpty()) {
		usage();
	}

	final String extractor;
	final Class< ? extends ReductionStrategy> strategy;
	if (optional.containsKey("-s")) {
		extractor = optional.get("-s");
		if (extractor.equals("rce")) {
			strategy = findStrategy("kodkod.engine.ucore.RCEStrategy");
		} else if (extractor.equals("sce")) {
			strategy = findStrategy("kodkod.engine.ucore.SCEStrategy");
		} else if (extractor.equals("nce")) {
			strategy = findStrategy("kodkod.engine.ucore.NCEStrategy");
		} else if (!extractor.equals("oce")) {
			strategy = findStrategy(optional.get("-s"));
		} else {
			strategy = null;
		}
	} else {
		extractor = "oce";
		strategy = null;
	}

	final ResultPrinter out = "stats".equals(optional.get("-o")) ? ResultPrinter.STATS : ResultPrinter.USER;

	if (optional.containsKey("-d")) {
		try {
			// findMinCore(strategy, Integer.parseInt(optional.get("-d")),
			// checks, bounds(instance, 2), out);
			findMinCore(strategy, Integer.parseInt(optional.get("-d")), checks, bounds, out);
		} catch (NumberFormatException nfe) {
			usage();
		}
	} else {
		findMinCore(strategy, Integer.MAX_VALUE, checks, bounds, out);
	}

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


示例9: minimize

import kodkod.engine.satlab.ReductionStrategy; //导入依赖的package包/类
/**
 * {@inheritDoc}
 * @see kodkod.engine.Proof#minimize(kodkod.engine.satlab.ReductionStrategy)
 */
public void minimize(ReductionStrategy strategy) {
	solver.reduce(strategy);
	coreFilter = null;
	coreRoots = null;
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:10,代码来源:ResolutionBasedProof.java


示例10: minimize

import kodkod.engine.satlab.ReductionStrategy; //导入依赖的package包/类
/**
 * Minimizes the current core using the trivial strategy
 * that does one of the following: (1) if there is a 
 * root that simplified to FALSE, sets the minimal core
 * to that root; or (2) if not, there must be two
 * roots that translated to x and -x, where x is a boolean 
 * literal, so we pick those two as the minimal core.
 * The strategy argument is ignored (it can be null).
 * @see Proof#minimize(ReductionStrategy)
 */
@Override
public void minimize(ReductionStrategy strategy) {	
	final Map<Formula, int[]> rootLits = new LinkedHashMap<Formula,int[]>();
	final Map<Formula, Node> rootNodes = new LinkedHashMap<Formula, Node>();
	final Set<Formula> roots = log().roots();
	
	for(Iterator<TranslationRecord> itr = core(); itr.hasNext();) { 
		final TranslationRecord rec = itr.next();
		if (roots.contains(rec.translated())) { 
			// simply record the most recent output value for each formula:
			// this is guaranteed to be the final output value for that 
			// formula because of the translation log guarantee that the
			// log is replayed in the order of translation:  i.e. a child's
			// output value is always recorded before the parent's
			int[] val = rootLits.get(rec.translated());
			if (val==null) { 
				val = new int[1]; 
				rootLits.put(rec.translated(), val);
			}
			val[0] = rec.literal();
			rootNodes.put(rec.translated(), rec.node());
		}
	}
	
	final SparseSequence<Formula> lits = new TreeSequence<Formula>();
	for(Map.Entry<Formula,int[]> entry : rootLits.entrySet()) { 
		final int lit = entry.getValue()[0];
		if (lit==-Integer.MAX_VALUE) { 
			coreRoots = Collections.singletonMap(entry.getKey(), rootNodes.get(entry.getKey()));
			break;
		} else if (lits.containsIndex(-lit)) { 
			final Formula f0 = lits.get(-lit);
			final Formula f1 = entry.getKey();
			coreRoots = new LinkedHashMap<Formula, Node>(3);
			coreRoots.put(f0, rootNodes.get(f0));
			coreRoots.put(f1, rootNodes.get(f1));
			coreRoots = Collections.unmodifiableMap(coreRoots);
			break;
		} else {
			lits.put(lit, entry.getKey());
		}
	}
	
	coreFilter = null;
	assert coreRoots.size()==1 && rootLits.get(coreRoots.keySet().iterator().next())[0]==-Integer.MAX_VALUE || coreRoots.size()==2;
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:57,代码来源:TrivialProof.java


示例11: minimize

import kodkod.engine.satlab.ReductionStrategy; //导入依赖的package包/类
/**
 * Minimizes the proof of this.log.formula's unsatisfiability using the
 * specified proof reduction strategy. The strategy argument is ignored (it
 * can be null) if this.formula is trivially unsatisfiable with respect to
 * this.bounds. In that case, the core is reduced using the trivial strategy
 * that does one of the following: (1) if there is a root that simplified to
 * FALSE, sets the minimal core to that root; or (2) if not, then there must
 * be two roots that translated to x and -x, where x is a boolean literal,
 * so we pick those two as the minimal core.
 * <p>
 * <b>Note:</b> the core minimization is performed at the level of the
 * transformed formula, not the original formula if the problem was
 * translated with a non-zero {@linkplain Options#coreGranularity() core
 * granularity} setting. In other words, after this method has been called,
 * {@linkplain #highLevelCore() highLevelCore()} returns a map M such that
 * M.keySet() is a minimal core with respect to this.log.bounds. In
 * contrast, {@linkplain Nodes#allRoots(Formula, java.util.Collection)
 * Nodes.roots(this.log.originalFormula, M.values())} is unsatisfiable with
 * respect this.log.originalBounds. These formulas, however, do not
 * necessarily form a minimal core of this.log.originalFormula if the
 * original problem was translated with a non-zero
 * {@linkplain Options#coreGranularity() core granularity} setting.
 * </p>
 * 
 * @ensures minimizes the proof of this.log.formula's unsatisfiability using
 *          the specified proof reduction strategy (or the trivial strategy
 *          if this.formula is trivially unsatisfiable with respect to
 *          this.bounds).
 * @see kodkod.engine.satlab.ReductionStrategy
 */
public abstract void minimize(ReductionStrategy strategy);
 
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:32,代码来源:Proof.java


示例12: minimize

import kodkod.engine.satlab.ReductionStrategy; //导入依赖的package包/类
/**
 * Minimizes the proof of this.log.formula's unsatisfiability
 * using the specified proof reduction strategy.  The strategy
 * argument is ignored (it can be null) if this.formula is 
 * trivially unsatisfiable with respect to this.bounds.  In that
 * case, the core is reduced using the trivial strategy
 * that does one of the following: (1) if there is a 
 * root that simplified to FALSE, sets the minimal core
 * to that root; or (2) if not, then there must be two
 * roots that translated to x and -x, where x is a boolean 
 * literal, so we pick those two as the minimal core. 
 * 
 * <p><b>Note:</b> the core minimization is performed at the level of the 
 * transformed formula, not the original formula if the problem was translated
 * with a non-zero {@linkplain Options#coreGranularity() core granularity} setting.
 * In other words, after this method has been called, {@linkplain #highLevelCore() highLevelCore()} 
 * returns a map M such that M.keySet() is a minimal core with respect to this.log.bounds. In contrast,
 * {@linkplain Nodes#allRoots(Formula, java.util.Collection) Nodes.roots(this.log.originalFormula, M.values())} is 
 * unsatisfiable with respect this.log.originalBounds.  These formulas, however, do not necessarily form a 
 * minimal core of this.log.originalFormula if the original problem was translated
 * with a non-zero {@linkplain Options#coreGranularity() core granularity} setting.  </p>
 * 
 * @ensures minimizes the proof of this.log.formula's unsatisfiability
 * using the specified proof reduction strategy (or the trivial 
 * strategy if this.formula is trivially unsatisfiable with respect
 * to this.bounds). 
 * 
 * @see kodkod.engine.satlab.ReductionStrategy
 */
public abstract void minimize(ReductionStrategy strategy);
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:31,代码来源:Proof.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Id类代码示例发布时间:2022-05-22
下一篇:
Java CompilationState类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap