How to iterate over solutions using the Alloy API?

279 Views Asked by At

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

There are 1 best solutions below

0
On BEST ANSWER

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();
    //...
}