Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Romain WALLON
sat4j
Commits
7cd1d13a
Commit
7cd1d13a
authored
Nov 22, 2021
by
Thibault Falque
Browse files
updates Gaussian
parent
17975130
Pipeline
#17570
failed with stages
in 16 minutes and 6 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
org.sat4j.pb/src/main/java/org/sat4j/pb/GaussPreprocessingPBDecorator.java
View file @
7cd1d13a
...
...
@@ -8,6 +8,8 @@ import java.util.ArrayList;
import
java.util.List
;
import
org.sat4j.core.ConstrGroup
;
import
org.sat4j.pb.constraints.pb.PBConstr
;
import
org.sat4j.pb.constraints.pb.SubsetSum
;
import
org.sat4j.pb.preprocessing.IConstraintGroupSelectionStrategy
;
import
org.sat4j.pb.preprocessing.PBPreprocessingConstraint
;
import
org.sat4j.pb.preprocessing.PBPreprocessingConstraintGroup
;
...
...
@@ -24,21 +26,65 @@ public class GaussPreprocessingPBDecorator extends PBSolverDecorator {
private
final
List
<
PBPreprocessingConstraintGroup
>
groups
;
private
IConstraintGroupSelectionStrategy
strategy
;
private
final
SubsetSum
subset
;
private
static
final
int
MAX_ELEMENT
=
100
;
private
static
final
int
MAX_SUM
=
4000
;
public
GaussPreprocessingPBDecorator
(
IPBSolver
solver
)
{
super
(
solver
);
this
.
groups
=
new
ArrayList
<>();
this
.
subset
=
new
SubsetSum
(
MAX_SUM
,
MAX_ELEMENT
);
}
public
IConstr
updateDegree
(
IConstr
ctr
)
{
if
(!(
ctr
instanceof
PBConstr
))
{
return
ctr
;
}
PBConstr
pbCtr
=
(
PBConstr
)
ctr
;
int
[]
coeffs
=
new
int
[
ctr
.
size
()];
for
(
int
i
=
0
;
i
<
ctr
.
size
();
i
++)
{
coeffs
[
i
]
=
(
pbCtr
.
getCoefs
()[
i
].
intValue
());
}
subset
.
setElements
(
coeffs
);
}
@Override
public
IConstr
add
Exactly
(
IVecInt
literals
,
IVecInt
coeffs
,
int
weight
)
public
IConstr
add
AtMost
(
IVecInt
literals
,
IVecInt
coeffs
,
int
degree
)
throws
ContradictionException
{
PBConstr
ctr
=
super
.
addAtMost
(
literals
,
coeffs
,
degree
);
return
new
ConstrGroup
();
}
@Override
public
IConstr
addAtMost
(
IVecInt
literals
,
IVec
<
BigInteger
>
coeffs
,
BigInteger
degree
)
throws
ContradictionException
{
// TODO Auto-generated method stub
return
super
.
addAtMost
(
literals
,
coeffs
,
degree
);
}
@Override
public
IConstr
addAtLeast
(
IVecInt
literals
,
IVecInt
coeffs
,
int
degree
)
throws
ContradictionException
{
// TODO Auto-generated method stub
return
super
.
addAtLeast
(
literals
,
coeffs
,
degree
);
}
@Override
public
IConstr
addAtLeast
(
IVecInt
literals
,
IVec
<
BigInteger
>
coeffs
,
BigInteger
degree
)
throws
ContradictionException
{
// TODO Auto-generated method stub
return
super
.
addAtLeast
(
literals
,
coeffs
,
degree
);
}
@Override
public
IConstr
addExactly
(
IVecInt
literals
,
IVec
<
BigInteger
>
coeffs
,
BigInteger
weight
)
throws
ContradictionException
{
PBPreprocessingConstraint
pbCtr
=
PBPreprocessingConstraint
.
newInstance
(
literals
,
coeffs
,
weight
);
if
(!
strategy
.
add
(
groups
,
pbCtr
))
{
...
...
@@ -49,6 +95,13 @@ public class GaussPreprocessingPBDecorator extends PBSolverDecorator {
return
new
ConstrGroup
();
}
@Override
public
IConstr
addExactly
(
IVecInt
literals
,
IVecInt
coeffs
,
int
weight
)
throws
ContradictionException
{
return
new
ConstrGroup
();
}
@Override
public
void
preprocessing
()
{
super
.
preprocessing
();
...
...
Write
Preview
Supports
Markdown
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