Commit 3e4cb2b8 authored by Lonca Emmanuel's avatar Lonca Emmanuel

made objective functions corrections linear

parent bbd24d04
......@@ -66,6 +66,8 @@ public class ObjectiveFunction implements Serializable {
private BigInteger correction = BigInteger.ZERO;
private BigInteger correctionFactor = BigInteger.ONE;
public ObjectiveFunction() {
this.vars = new VecInt();
this.coeffs = new Vec<BigInteger>();
......@@ -142,14 +144,32 @@ public class ObjectiveFunction implements Serializable {
return this.vars;
}
@Deprecated // replaced by setCorrectionOffset()
public void setCorrection(BigInteger correction) {
this.correction = correction;
}
public void setCorrectionOffset(BigInteger correction) {
this.correction = correction;
}
@Deprecated // replaced by getCorrectionOffset()
public BigInteger getCorrection() {
return this.correction;
}
public BigInteger getCorrectionOffset() {
return this.correction;
}
public void setCorrectionFactor(final BigInteger correctionFactor) {
this.correctionFactor = correctionFactor;
}
public BigInteger getCorrectionFactor() {
return this.correctionFactor;
}
@Override
public String toString() {
StringBuilder stb = new StringBuilder();
......@@ -164,7 +184,8 @@ public class ObjectiveFunction implements Serializable {
lit = -lit;
coef = coef.negate();
}
stb.append((coef.signum() < 0 ? "" : "+") + coef + " x" + lit + " ");
stb.append(
(coef.signum() < 0 ? "" : "+") + coef + " x" + lit + " ");
}
return stb.toString();
}
......
......@@ -308,8 +308,11 @@ public class PseudoOptDecorator extends PBSolverDecorator
}
public Number getObjectiveValue() {
return this.objectiveValue
.add(decorated().getObjectiveFunction().getCorrection());
final BigInteger offset = decorated().getObjectiveFunction()
.getCorrectionOffset();
final BigInteger factor = decorated().getObjectiveFunction()
.getCorrectionFactor();
return this.objectiveValue.multiply(factor).add(offset);
}
public void discard() throws ContradictionException {
......
......@@ -74,8 +74,10 @@ public final class SearchOptimizerListener extends
public void solutionFound(int[] model, RandomAccessModel lazyModel) {
if (obj != null) {
this.currentValue = obj.calculateDegree(lazyModel);
final BigInteger offset = obj.getCorrectionOffset();
final BigInteger factor = obj.getCorrectionFactor();
System.out.println(ILauncherMode.CURRENT_OPTIMUM_VALUE_PREFIX
+ this.currentValue.add(obj.getCorrection()));
+ this.currentValue.multiply(factor).add(offset));
if (this.prevConstr != null) {
this.solverService.removeSubsumedConstr(prevConstr);
}
......
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