How to iterate over solutions using the Alloy API?

喜欢而已 提交于 2019-12-11 02:28:20

问题


I'm using Alloy using its API as explained in Alloy - Generate .xml instance from .als.

I want to iterate over all solutions.

How to do this?


回答1:


In order to iterate over all the satisfiable solutions, you can simply loop over calls of the next() method on your A4Solution object, until the solution obtained is unsatisfiable (check with the satisfiable() method).

You will have something like :

A4Solution mySolution = TranslateAlloyToKodkod.execute_command(null, model.getAllReachableSigs(), cmd, new A4Options());

while(mySolution.satisfiable()){
    mySolution=mySolution.next();
    //...
}


来源:https://stackoverflow.com/questions/27227303/how-to-iterate-over-solutions-using-the-alloy-api

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!