Skip to content

Commit 6e8e2de

Browse files
author
nmacedo
committed
code cleanup, documentation
1 parent 5fc6f63 commit 6e8e2de

10 files changed

Lines changed: 75 additions & 2699 deletions

File tree

src/main/java/kodkod/engine/AbstractKodkodSolver.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
* @modified Nuno Macedo // [HASLab] model finding hierarchy
7373
*/
7474
//[HASLab] solver hierarchy
75-
public abstract class AbstractKodkodSolver<B extends Bounds, O extends Options> implements KodkodSolver<B,O> {
75+
public abstract class AbstractKodkodSolver<B extends Bounds, O extends Options> implements KodkodSolver<B,O>, IterableSolver<B, O> {
7676

7777
/**
7878
* {@inheritDoc}

src/main/java/kodkod/engine/ElectrodSolver.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@
6767
* restarting the solver.
6868
* </p>
6969
*
70+
* As or Pardinus 1.2, SMV iteration is disabled due to issues on the backends.
71+
*
7072
* @author Nuno Macedo // [HASLab] unbounded temporal model finding
7173
*/
7274
public class ElectrodSolver implements UnboundedSolver<ExtendedOptions>,

src/main/java/kodkod/engine/ExplorableSolver.java

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -27,31 +27,28 @@
2727
import kodkod.instance.Bounds;
2828

2929
/**
30-
* Å relational constraint solver interface that support solution iteration,
31-
* independent of the underlying technology (bounded vs. unbounded) and
32-
* functionalities (temporal, target-oriented, decomposed, symbolic).
30+
* A relational constraint solver interface that support solution advanced
31+
* iteration operations, independent of the underlying technology (bounded vs.
32+
* unbounded) and functionalities (temporal, target-oriented, decomposed,
33+
* symbolic).
3334
*
3435
* @author Nuno Macedo // [HASLab] model finding hierarchy
3536
*
36-
* @param <B>
37-
* the class of bounds required by a concrete solver
38-
* @param <O>
39-
* the class of options required by a concrete solver
37+
* @param <B> the class of bounds required by a concrete solver
38+
* @param <O> the class of options required by a concrete solver
4039
*/
41-
public interface ExplorableSolver<B extends Bounds, O extends PardinusOptions>
42-
extends IterableSolver<B, O> {
40+
public interface ExplorableSolver<B extends Bounds, O extends PardinusOptions> extends IterableSolver<B, O> {
4341

4442
/**
4543
* Attempts to find a set of solutions to the given {@code formula} and
46-
* {@code bounds} with respect to the set options or, optionally, to
47-
* prove the formula's unsatisfiability. If the operation is successful, the
48-
* method returns an iterator over {@link Solution} objects. If there is
49-
* more than one solution, the outcome of all of them is SAT or trivially
50-
* SAT. If the problem is unsatisfiable, the iterator will produce a single
51-
* {@link Solution} whose outcome is UNSAT or trivially UNSAT. The set of
52-
* returned solutions must be non-empty, but it is not required to be
53-
* complete; a solver could simply return a singleton set containing just
54-
* the first available solution.
44+
* {@code bounds} with respect to the set options or, optionally, to prove the
45+
* formula's unsatisfiability. If the operation is successful, the method
46+
* returns an iterator over {@link Solution} objects. If there is more than one
47+
* solution, the outcome of all of them is SAT or trivially SAT. If the problem
48+
* is unsatisfiable, the iterator will produce a single {@link Solution} whose
49+
* outcome is UNSAT or trivially UNSAT. The set of returned solutions must be
50+
* non-empty, but it is not required to be complete; a solver could simply
51+
* return a singleton set containing just the first available solution.
5552
*/
5653
public Explorer<Solution> solveAll(Formula formula, B bounds);
5754

Lines changed: 55 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,25 @@
1+
/*
2+
* Kodkod -- Copyright (c) 2005-present, Emina Torlak
3+
* Pardinus -- Copyright (c) 2013-present, Nuno Macedo, INESC TEC
4+
*
5+
* Permission is hereby granted, free of charge, to any person obtaining a copy
6+
* of this software and associated documentation files (the "Software"), to deal
7+
* in the Software without restriction, including without limitation the rights
8+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
* copies of the Software, and to permit persons to whom the Software is
10+
* furnished to do so, subject to the following conditions:
11+
*
12+
* The above copyright notice and this permission notice shall be included in
13+
* all copies or substantial portions of the Software.
14+
*
15+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
* THE SOFTWARE.
22+
*/
123
package kodkod.engine;
224

325
import java.util.Iterator;
@@ -17,30 +39,47 @@
1739
public interface Explorer<T> extends Iterator<T> {
1840

1941
/**
20-
* Produces an alternative solution by iterating over the selected {@code state}
21-
* of the trace, fixing all previous states. A set {@code ignore} of relations
22-
* can be specified so that their valuations are ignored during iteration.
23-
* Iteration may or not {@code exclude} the state at the selected position from
24-
* future iterations, and that of higher positions is reset.
42+
* Produces an alternative solution by iterating over the static relations,
43+
* i.e., the configuration, while leaving the mutable ones free to adapt.
2544
*
26-
* @param state the state which will be iterated.
27-
* @param steps TODO
28-
* @param ignore relations whose valuation will be ignored in iteration of
29-
* {@code state}.
30-
* @param force fixed valuations for a set of relations that will be changed
31-
* at {@code state}.
32-
* @param exclude whether the current value of the {@code state} is to be
33-
* excluded from future iterations.
3445
* @return the next branching solution
3546
*/
3647
public T nextC();
3748

49+
/**
50+
* Produces an alternative solution by iterating over the mutable relations
51+
* while fixing the static ones, i.e., the configuration.
52+
*
53+
* @return the next branching solution
54+
*/
3855
public T nextP();
3956

57+
/**
58+
* Produces an alternative solution by iterating over the selected {@code state}
59+
* of the trace, fixing all previous states. A set {@code change} of relations
60+
* can be specified on which a change must occur.
61+
*
62+
* @param state the state which will be iterated.
63+
* @param delta the number of states from <state>, inclusive, in which the
64+
* change must occur
65+
* @param change a set of relations in which the change must occur
66+
* @return the next branching solution
67+
*/
4068
public T nextS(int state, int delta, Set<Relation> change);
41-
42-
public boolean hasNextP();
43-
69+
70+
/**
71+
* Whether there is a next configuration.
72+
*
73+
* @return true if another configuration
74+
*/
4475
public boolean hasNextC();
4576

77+
/**
78+
* Whether there is a next path for the current configuration. Is reseted by a
79+
* new configuration.
80+
*
81+
* @return true if another path for this configuration
82+
*/
83+
public boolean hasNextP();
84+
4685
}

src/main/java/kodkod/engine/IterableSolver.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
import kodkod.instance.Bounds;
3030

3131
/**
32-
* Å relational constraint solver interface that support solution iteration,
32+
* A relational constraint solver interface that support solution iteration,
3333
* independent of the underlying technology (bounded vs. unbounded) and
3434
* functionalities (temporal, target-oriented, decomposed, symbolic).
3535
*

src/main/java/kodkod/engine/PardinusSolver.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ public Explorer<Solution> solveAll(Formula formula, PardinusBounds bounds) throw
192192
// assert options.solver().incremental();
193193

194194
if (solver instanceof IterableSolver<?,?>) {
195-
Iterator<Solution> it = ((IterableSolver) solver).solveAll(formula, bounds);
195+
Iterator<Solution> it = ((IterableSolver<PardinusBounds, ExtendedOptions>) solver).solveAll(formula, bounds);
196196
if (it instanceof Explorer)
197197
return (Explorer<Solution>) it;
198198
else {

0 commit comments

Comments
 (0)