Commit 2d75931e authored by Lonca Emmanuel's avatar Lonca Emmanuel

fixed a bug that made object ("o") lines display wrong values

In maximization procedures, the values shown in object lines ("o"), were
wrong, due to a wrong correction applied in the minimization subprocess.
parent 3e4cb2b8
Pipeline #200 passed with stage
in 11 minutes and 15 seconds
......@@ -95,7 +95,7 @@ public class ObjBuilder {
coeffs.push(BigInteger.valueOf(val));
}
final ObjectiveFunction obj = new ObjectiveFunction(literals, coeffs);
obj.setCorrection(BigInteger.ONE);
// obj.setCorrection(BigInteger.ONE);
return obj;
}
......@@ -160,6 +160,7 @@ public class ObjBuilder {
throw new UnsupportedOperationException();
}
if(negate) {
obj.setCorrectionFactor(BigInteger.ONE.negate());
obj.negate();
}
addObjectiveFunction(obj);
......@@ -210,7 +211,7 @@ public class ObjBuilder {
}
if(min < 0) throw new UnsupportedOperationException("negative coeff");
final ObjectiveFunction obj = new ObjectiveFunction();
obj.setCorrection(BigInteger.ONE);
// obj.setCorrection(BigInteger.ONE);
final BigInteger step = BigInteger.valueOf(max+1);
BigInteger fact = BigInteger.ONE;
for(int i=xlist.length; i>=0; --i) {
......@@ -226,16 +227,17 @@ public class ObjBuilder {
private ObjectiveFunction buildExprObjToMinimize(String expr, boolean negate) {
final ObjectiveFunction obj = this.intensionEnc.encodeObj(expr);
obj.setCorrection(BigInteger.ONE);
// obj.setCorrection(BigInteger.ONE);
if(negate) {
obj.negate();
obj.setCorrectionFactor(BigInteger.ONE.negate());
}
return obj;
}
private ObjectiveFunction buildSumObjToMinimize(final XVarInteger[] xlist, final int[] xcoeffs) {
final ObjectiveFunction obj = new ObjectiveFunction();
obj.setCorrection(BigInteger.ONE);
// obj.setCorrection(BigInteger.ONE);
final int size = xlist.length;
for(int i=0; i<size; ++i) {
obj.add(buildObjForVar(xlist[i]).multiply(BigInteger.valueOf(xcoeffs[i])));
......
......@@ -176,10 +176,9 @@ public class XMLCSP3Reader extends Reader implements XCallbacks2 {
case OPTIMUM_FOUND:
final ObjectiveFunction obj = this.solver.getObjectiveFunction();
BigInteger degree = obj.calculateDegree(this.solver);
final BigInteger correction = obj.getCorrection();
if(!correction.equals(BigInteger.ZERO)) {
degree = degree.multiply(correction);
}
final BigInteger offset = obj.getCorrectionOffset();
final BigInteger factor = obj.getCorrectionFactor();
degree = degree.multiply(factor).add(offset);
strModelBuffer.append("<instantiation type=\"optimum\" cost=\"")
.append(degree.toString())
.append("\">\n");
......
Markdown is supported
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