通过 A4Solution [英] going through an A4Solution

查看:20
本文介绍了通过 A4Solution的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前在我的项目中使用 Alloy api,我需要显示 A4Solutions.我可以使用 vizualiser Alloy 提供 (vizGUI) 轻松做到这一点,但它对我的目的来说有点太有限了.所以我愿意从 A4Solution 对象生成我自己的图形(使用任何其他图形 API).

I am currently using the Alloy api in my project, and I need to display A4Solutions.I can do that easily with the vizualiser Alloy provides (vizGUI) , but it is a bit too limited for my purpose. So I am willing to generate my own graphs ( using any other graph api ) from an A4Solution objects.

我能够毫无问题地获得原子(这很直接),但我真的不知道如何检索这些原子之间的关系.

I was able to get the Atoms without any problems (that was pretty straight forward ) but I can't really see how to retrieve the relations between those atoms.

我在网上查找了一些有关如何解析 A4Solution 的示例,但不幸的是什么也没找到.

I looked online for some example about how to parse an A4Solution, but found nothing unfortunately.

推荐答案

关系或字段,您可以从 sig 中检索,然后您可以评估它们以获得具体的原子,如下所示:

Relations, or fields, you can retrieve from sigs, and then you can evaluate them to obtains concrete atoms, something like this:

A4Solution sol = ...;
SafeList<Sig> sigs = sol.getAllReachableSigs();
for (Sig sig : sigs) {
  SafeList<Field> fields = sig.getFields();
  for (Field field : fields) {
    A4TupleSet ts = (A4TupleSet)(sol.eval(field));
    for(A4Tuple t: ts)
      for(int i=0; i<t.arity(); i++) 
        t.atom(i);
  }
}

这篇关于通过 A4Solution的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆