Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
sat4j
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
48
Issues
48
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Container Registry
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
SAT4J
sat4j
Commits
1fc1c0dd
Commit
1fc1c0dd
authored
Apr 26, 2017
by
Anne Parrain
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a solver with the "Divide by 2" feature. Correctthe previous version
and remove it from the standard process.
parent
c5a99b7a
Pipeline
#138
failed with stage
Changes
6
Pipelines
1
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
207 additions
and
114 deletions
+207
-114
org.sat4j.pb/src/main/java/org/sat4j/pb/SolverFactory.java
org.sat4j.pb/src/main/java/org/sat4j/pb/SolverFactory.java
+18
-0
org.sat4j.pb/src/main/java/org/sat4j/pb/constraints/pb/ConflictMap.java
...rc/main/java/org/sat4j/pb/constraints/pb/ConflictMap.java
+93
-106
org.sat4j.pb/src/main/java/org/sat4j/pb/constraints/pb/MapPb.java
...j.pb/src/main/java/org/sat4j/pb/constraints/pb/MapPb.java
+6
-2
org.sat4j.pb/src/main/java/org/sat4j/pb/core/PBSolverCP.java
org.sat4j.pb/src/main/java/org/sat4j/pb/core/PBSolverCP.java
+0
-6
org.sat4j.pb/src/main/java/org/sat4j/pb/core/PBSolverCPLongDivideBy2.java
.../main/java/org/sat4j/pb/core/PBSolverCPLongDivideBy2.java
+71
-0
org.sat4j.pb/src/test/java/org/sat4j/pb/constraints/PBCPMaxClauseCardConstrLearningDivideBy2Test.java
...traints/PBCPMaxClauseCardConstrLearningDivideBy2Test.java
+19
-0
No files found.
org.sat4j.pb/src/main/java/org/sat4j/pb/SolverFactory.java
View file @
1fc1c0dd
...
...
@@ -68,6 +68,7 @@ import org.sat4j.pb.core.PBSolverCP;
import
org.sat4j.pb.core.PBSolverCPCardLearning
;
import
org.sat4j.pb.core.PBSolverCPClauseLearning
;
import
org.sat4j.pb.core.PBSolverCPLong
;
import
org.sat4j.pb.core.PBSolverCPLongDivideBy2
;
import
org.sat4j.pb.core.PBSolverCPLongReduceToCard
;
import
org.sat4j.pb.core.PBSolverCPLongRounding
;
//import org.sat4j.pb.core.PBSolverCard;
...
...
@@ -632,6 +633,18 @@ public final class SolverFactory extends ASolverFactory<IPBSolver> {
return
solver
;
}
private
static
PBSolverCP
newPBCPStarDivideBy2
(
PBDataStructureFactory
dsf
,
IOrder
order
,
boolean
noRemove
)
{
MiniSATLearning
<
PBDataStructureFactory
>
learning
=
new
MiniSATLearning
<
PBDataStructureFactory
>();
PBSolverCP
solver
=
new
PBSolverCPLongDivideBy2
(
learning
,
dsf
,
order
,
noRemove
);
learning
.
setDataStructureFactory
(
solver
.
getDSFactory
());
learning
.
setVarActivityListener
(
solver
);
solver
.
setRestartStrategy
(
new
ArminRestarts
());
solver
.
setLearnedConstraintsDeletionStrategy
(
solver
.
lbd_based
);
return
solver
;
}
private
static
PBSolverCP
newPBCPStarRounding
(
PBDataStructureFactory
dsf
,
IOrder
order
,
boolean
noRemove
)
{
MiniSATLearning
<
PBDataStructureFactory
>
learning
=
new
MiniSATLearning
<
PBDataStructureFactory
>();
...
...
@@ -704,6 +717,11 @@ public final class SolverFactory extends ASolverFactory<IPBSolver> {
new
VarOrderHeapObjective
(),
true
);
}
public
static
IPBSolver
newCuttingPlanesStarDivideBy2
()
{
return
newPBCPStarDivideBy2
(
new
PBMaxClauseCardConstrDataStructure
(),
new
VarOrderHeapObjective
(),
true
);
}
/**
* Cutting Planes based solver. The inference during conflict analysis is
* based on cutting planes instead of resolution as in a SAT solver.
...
...
org.sat4j.pb/src/main/java/org/sat4j/pb/constraints/pb/ConflictMap.java
View file @
1fc1c0dd
This diff is collapsed.
Click to expand it.
org.sat4j.pb/src/main/java/org/sat4j/pb/constraints/pb/MapPb.java
View file @
1fc1c0dd
...
...
@@ -75,10 +75,14 @@ public class MapPb implements IDataStructurePB {
}
public
int
reduceCoeffsByPower2
()
{
int
nbBits
=
1
;
for
(
int
i
=
0
;
i
<
this
.
weightedLits
.
size
()
&&
nbBits
>
0
;
i
++)
assert
this
.
weightedLits
.
size
()
>
0
;
int
nbBits
=
this
.
weightedLits
.
getCoef
(
0
).
bitLength
();
for
(
int
i
=
0
;
i
<
this
.
weightedLits
.
size
()
&&
nbBits
>
0
;
i
++)
{
nbBits
=
Math
.
min
(
nbBits
,
this
.
weightedLits
.
getCoef
(
i
).
getLowestSetBit
());
if
(
nbBits
==
0
)
break
;
}
if
(
nbBits
>
0
)
{
for
(
int
i
=
0
;
i
<
this
.
weightedLits
.
size
();
i
++)
{
this
.
weightedLits
.
changeCoef
(
i
,
...
...
org.sat4j.pb/src/main/java/org/sat4j/pb/core/PBSolverCP.java
View file @
1fc1c0dd
...
...
@@ -164,12 +164,6 @@ public class PBSolverCP extends PBSolver {
}
// assertive PB-constraint is build and referenced
int
nbBits
=
confl
.
reduceCoeffsByPower2
();
if
(
nbBits
>
0
)
{
stats
.
numberOfReductionsByPower2
++;
stats
.
numberOfRightShiftsForCoeffs
=
stats
.
numberOfRightShiftsForCoeffs
+
nbBits
;
}
confl
.
postProcess
(
currentLevel
);
PBConstr
resConstr
=
(
PBConstr
)
this
.
dsfactory
.
createUnregisteredPseudoBooleanConstraint
(
confl
);
...
...
org.sat4j.pb/src/main/java/org/sat4j/pb/core/PBSolverCPLongDivideBy2.java
0 → 100644
View file @
1fc1c0dd
package
org
.
sat4j
.
pb
.
core
;
import
org.sat4j.minisat.core.IOrder
;
import
org.sat4j.minisat.core.LearningStrategy
;
import
org.sat4j.minisat.core.RestartStrategy
;
import
org.sat4j.minisat.core.SearchParams
;
import
org.sat4j.pb.constraints.pb.ConflictMap
;
import
org.sat4j.pb.constraints.pb.ConflictMapReduceToClause
;
import
org.sat4j.pb.constraints.pb.IConflict
;
import
org.sat4j.pb.constraints.pb.PBConstr
;
public
class
PBSolverCPLongDivideBy2
extends
PBSolverCPLong
{
public
PBSolverCPLongDivideBy2
(
LearningStrategy
<
PBDataStructureFactory
>
learner
,
PBDataStructureFactory
dsf
,
IOrder
order
)
{
super
(
learner
,
dsf
,
order
);
// TODO Auto-generated constructor stub
}
public
PBSolverCPLongDivideBy2
(
LearningStrategy
<
PBDataStructureFactory
>
learner
,
PBDataStructureFactory
dsf
,
SearchParams
params
,
IOrder
order
,
RestartStrategy
restarter
)
{
super
(
learner
,
dsf
,
params
,
order
,
restarter
);
// TODO Auto-generated constructor stub
}
public
PBSolverCPLongDivideBy2
(
LearningStrategy
<
PBDataStructureFactory
>
learner
,
PBDataStructureFactory
dsf
,
SearchParams
params
,
IOrder
order
)
{
super
(
learner
,
dsf
,
params
,
order
);
// TODO Auto-generated constructor stub
}
public
PBSolverCPLongDivideBy2
(
LearningStrategy
<
PBDataStructureFactory
>
learner
,
PBDataStructureFactory
dsf
,
IOrder
order
,
boolean
noRemove
)
{
super
(
learner
,
dsf
,
order
,
noRemove
);
// TODO Auto-generated constructor stub
}
public
PBSolverCPLongDivideBy2
(
LearningStrategy
<
PBDataStructureFactory
>
learner
,
PBDataStructureFactory
dsf
,
SearchParams
params
,
IOrder
order
,
RestartStrategy
restarter
,
boolean
noRemove
)
{
super
(
learner
,
dsf
,
params
,
order
,
restarter
,
noRemove
);
// TODO Auto-generated constructor stub
}
public
PBSolverCPLongDivideBy2
(
LearningStrategy
<
PBDataStructureFactory
>
learner
,
PBDataStructureFactory
dsf
,
SearchParams
params
,
IOrder
order
,
boolean
noRemove
)
{
super
(
learner
,
dsf
,
params
,
order
,
noRemove
);
// TODO Auto-generated constructor stub
}
@Override
protected
IConflict
chooseConflict
(
PBConstr
myconfl
,
int
level
)
{
return
ConflictMapReduceToClause
.
createConflict
(
myconfl
,
level
,
noRemove
,
ConflictMap
.
POSTPROCESSDIVIDEBY2
,
stats
);
}
@Override
public
String
toString
(
String
prefix
)
{
return
super
.
toString
(
prefix
)
+
"\n"
+
prefix
+
"Performs a post-processing after conflict analysis in order to divide by 2 as much as possible coefficients of learned constraints"
;
}
}
org.sat4j.pb/src/test/java/org/sat4j/pb/constraints/PBCPMaxClauseCardConstrLearningDivideBy2Test.java
0 → 100644
View file @
1fc1c0dd
package
org
.
sat4j
.
pb
.
constraints
;
import
org.sat4j.pb.IPBSolver
;
import
org.sat4j.pb.SolverFactory
;
public
class
PBCPMaxClauseCardConstrLearningDivideBy2Test
extends
AbstractPseudoBooleanAndPigeonHoleTest
{
public
PBCPMaxClauseCardConstrLearningDivideBy2Test
(
String
arg
)
{
super
(
arg
);
// TODO Auto-generated constructor stub
}
@Override
protected
IPBSolver
createSolver
()
{
return
SolverFactory
.
newCuttingPlanesStarDivideBy2
();
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment