Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
probkodkod
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
general
stups
probkodkod
Commits
00d8a057
Commit
00d8a057
authored
8 years ago
by
Sebastian Krings
Browse files
Options
Downloads
Patches
Plain Diff
if finding multiple solutions fails due to a non-incremental solver find a single one instead
parent
40927bf3
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/de/stups/probkodkod/ImmutableProblem.java
+29
-24
29 additions, 24 deletions
src/main/java/de/stups/probkodkod/ImmutableProblem.java
with
29 additions
and
24 deletions
src/main/java/de/stups/probkodkod/ImmutableProblem.java
+
29
−
24
View file @
00d8a057
...
@@ -10,6 +10,7 @@ import java.util.Map;
...
@@ -10,6 +10,7 @@ import java.util.Map;
import
java.util.logging.Level
;
import
java.util.logging.Level
;
import
java.util.logging.Logger
;
import
java.util.logging.Logger
;
import
de.stups.probkodkod.types.TupleType
;
import
kodkod.ast.Formula
;
import
kodkod.ast.Formula
;
import
kodkod.engine.Solution
;
import
kodkod.engine.Solution
;
import
kodkod.engine.Solver
;
import
kodkod.engine.Solver
;
...
@@ -17,7 +18,6 @@ import kodkod.instance.Bounds;
...
@@ -17,7 +18,6 @@ import kodkod.instance.Bounds;
import
kodkod.instance.TupleFactory
;
import
kodkod.instance.TupleFactory
;
import
kodkod.instance.TupleSet
;
import
kodkod.instance.TupleSet
;
import
kodkod.instance.Universe
;
import
kodkod.instance.Universe
;
import
de.stups.probkodkod.types.TupleType
;
/**
/**
* This is the immutable Version of a Kodkod problem description. Objects of
* This is the immutable Version of a Kodkod problem description. Objects of
...
@@ -34,8 +34,7 @@ import de.stups.probkodkod.types.TupleType;
...
@@ -34,8 +34,7 @@ import de.stups.probkodkod.types.TupleType;
* @author plagge
* @author plagge
*/
*/
public
final
class
ImmutableProblem
{
public
final
class
ImmutableProblem
{
private
static
final
Logger
logger
=
Logger
private
static
final
Logger
logger
=
Logger
.
getLogger
(
ImmutableProblem
.
class
.
getName
());
.
getLogger
(
ImmutableProblem
.
class
.
getName
());
// The id of the problem
// The id of the problem
private
final
String
id
;
private
final
String
id
;
...
@@ -57,10 +56,8 @@ public final class ImmutableProblem {
...
@@ -57,10 +56,8 @@ public final class ImmutableProblem {
// The factory is used to create tuples and tupleSets
// The factory is used to create tuples and tupleSets
private
final
Universe
universe
;
private
final
Universe
universe
;
public
ImmutableProblem
(
final
String
id
,
final
Formula
formula
,
public
ImmutableProblem
(
final
String
id
,
final
Formula
formula
,
final
Integer
bitwidth
,
final
Universe
universe
,
final
Integer
bitwidth
,
final
Universe
universe
,
final
Collection
<
RelationInfo
>
infos
,
final
int
numberOffset
,
final
int
[]
numbers
)
{
final
Collection
<
RelationInfo
>
infos
,
final
int
numberOffset
,
final
int
[]
numbers
)
{
this
.
id
=
id
;
this
.
id
=
id
;
this
.
solverBitwidth
=
bitwidth
;
this
.
solverBitwidth
=
bitwidth
;
this
.
universe
=
universe
;
this
.
universe
=
universe
;
...
@@ -80,10 +77,8 @@ public final class ImmutableProblem {
...
@@ -80,10 +77,8 @@ public final class ImmutableProblem {
}
}
}
}
private
static
Bounds
setUpBounds
(
final
Universe
universe
,
private
static
Bounds
setUpBounds
(
final
Universe
universe
,
final
RelationInfo
[]
variableInfos
,
final
RelationInfo
[]
variableInfos
,
final
Map
<
String
,
RelationInfo
>
relations
,
final
Collection
<
RelationInfo
>
infos
)
{
final
Map
<
String
,
RelationInfo
>
relations
,
final
Collection
<
RelationInfo
>
infos
)
{
Bounds
preBounds
=
new
Bounds
(
universe
);
Bounds
preBounds
=
new
Bounds
(
universe
);
int
indexVar
=
0
;
int
indexVar
=
0
;
for
(
final
RelationInfo
relinfo
:
infos
)
{
for
(
final
RelationInfo
relinfo
:
infos
)
{
...
@@ -101,8 +96,7 @@ public final class ImmutableProblem {
...
@@ -101,8 +96,7 @@ public final class ImmutableProblem {
return
preBounds
;
return
preBounds
;
}
}
private
static
void
registerNumbers
(
final
Bounds
bounds
,
private
static
void
registerNumbers
(
final
Bounds
bounds
,
final
int
numberOffset
,
final
int
[]
numbers
)
{
final
int
numberOffset
,
final
int
[]
numbers
)
{
if
(
numbers
!=
null
)
{
if
(
numbers
!=
null
)
{
final
Universe
universe
=
bounds
.
universe
();
final
Universe
universe
=
bounds
.
universe
();
final
TupleFactory
factory
=
universe
.
factory
();
final
TupleFactory
factory
=
universe
.
factory
();
...
@@ -113,8 +107,7 @@ public final class ImmutableProblem {
...
@@ -113,8 +107,7 @@ public final class ImmutableProblem {
}
}
}
}
private
Formula
addOnePredicates
(
Formula
formula
,
private
Formula
addOnePredicates
(
Formula
formula
,
final
RelationInfo
[]
variables
)
{
final
RelationInfo
[]
variables
)
{
for
(
RelationInfo
relinfo
:
variables
)
{
for
(
RelationInfo
relinfo
:
variables
)
{
final
TupleType
tupleType
=
relinfo
.
getTupleType
();
final
TupleType
tupleType
=
relinfo
.
getTupleType
();
if
(
tupleType
.
formulaOneShouldBeAdded
())
{
if
(
tupleType
.
formulaOneShouldBeAdded
())
{
...
@@ -168,8 +161,7 @@ public final class ImmutableProblem {
...
@@ -168,8 +161,7 @@ public final class ImmutableProblem {
* @return A request object
* @return A request object
* @see Request
* @see Request
*/
*/
public
Request
createRequest
(
final
Solver
solver
,
final
boolean
signum
,
public
Request
createRequest
(
final
Solver
solver
,
final
boolean
signum
,
final
Map
<
String
,
TupleSet
>
values
)
{
final
Map
<
String
,
TupleSet
>
values
)
{
final
Bounds
bounds
=
preBounds
.
clone
();
final
Bounds
bounds
=
preBounds
.
clone
();
final
int
resultSize
=
variableInfos
.
length
-
values
.
size
();
final
int
resultSize
=
variableInfos
.
length
-
values
.
size
();
...
@@ -187,14 +179,27 @@ public final class ImmutableProblem {
...
@@ -187,14 +179,27 @@ public final class ImmutableProblem {
}
}
}
}
final
Formula
effFormula
=
signum
?
formula
:
formula
.
not
();
final
Formula
effFormula
=
signum
?
formula
:
formula
.
not
();
try
{
Iterator
<
Solution
>
iterator
=
solver
.
solveAll
(
effFormula
,
bounds
);
Iterator
<
Solution
>
iterator
=
solver
.
solveAll
(
effFormula
,
bounds
);
if
(
logger
.
isLoggable
(
Level
.
FINE
))
{
if
(
logger
.
isLoggable
(
Level
.
FINE
))
{
logger
.
fine
(
"request for '"
+
id
+
"': args="
+
values
.
keySet
()
logger
.
fine
(
"request for '"
+
id
+
"': args="
+
values
.
keySet
()
+
", remaining vars="
+
", remaining vars="
+
Arrays
.
asList
(
variables
));
+
Arrays
.
asList
(
variables
));
logger
.
info
(
"formula: "
+
effFormula
);
logger
.
info
(
"formula: "
+
effFormula
);
logger
.
info
(
bounds
.
toString
());
logger
.
info
(
bounds
.
toString
());
}
}
return
new
Request
(
variables
,
iterator
);
return
new
Request
(
variables
,
iterator
);
}
catch
(
IllegalArgumentException
e
)
{
Solution
sol
=
solver
.
solve
(
effFormula
,
bounds
);
if
(
logger
.
isLoggable
(
Level
.
FINE
))
{
logger
.
fine
(
"request for '"
+
id
+
"': args="
+
values
.
keySet
()
+
", remaining vars="
+
Arrays
.
asList
(
variables
));
logger
.
info
(
"formula: "
+
effFormula
);
logger
.
info
(
bounds
.
toString
());
}
return
new
Request
(
variables
,
Arrays
.
asList
(
sol
).
iterator
());
}
}
}
public
Universe
getUniverse
()
{
public
Universe
getUniverse
()
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment