Commit 7cd1d13a authored by Thibault Falque's avatar Thibault Falque
Browse files

updates Gaussian

parent 17975130
Pipeline #17570 failed with stages
in 16 minutes and 6 seconds
......@@ -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 addExactly(IVecInt literals, IVecInt coeffs, int weight)
public IConstr addAtMost(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();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment