Clover coverage report -
Coverage timestamp: jeu. sept. 29 2005 23:57:39 CEST
file stats: LOC: 63   Methods: 5
NCLOC: 41   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
ObjectiveFunction.java 0% 0% 0% 0%
coverage
 1    package org.sat4j.reader;
 2   
 3    import java.math.BigInteger;
 4   
 5    import org.sat4j.core.Vec;
 6    import org.sat4j.core.VecInt;
 7    import org.sat4j.specs.IVec;
 8    import org.sat4j.specs.IVecInt;
 9   
 10    /**
 11    * Abstraction for an Objective Function for Pseudo Boolean Optimization.
 12    *
 13    * May be generalized in the future to deal with other optimization functions.
 14    *
 15    * @author leberre
 16    *
 17    */
 18    public class ObjectiveFunction {
 19   
 20    // contains the coeffs of the objective function for each variable
 21    private final IVec<BigInteger> coeffs;
 22   
 23    private final IVecInt vars;
 24   
 25  0 public ObjectiveFunction(IVecInt vars, IVec<BigInteger> coeffs) {
 26  0 this.vars = new VecInt(vars.size());
 27  0 vars.copyTo(this.vars);
 28  0 this.coeffs = new Vec<BigInteger>(coeffs.size());
 29  0 coeffs.copyTo(this.coeffs);
 30    }
 31   
 32    // calculate the degree of the objectif function
 33  0 public BigInteger calculateDegree(int[] model) {
 34  0 BigInteger tempDegree = BigInteger.ZERO;
 35   
 36  0 int indice;
 37  0 for (int i = 0; i < vars.size(); i++) {
 38  0 if (varInModel(vars.get(i), model))
 39  0 tempDegree = tempDegree.add(coeffs.get(i));
 40    }
 41  0 return tempDegree;
 42    }
 43   
 44  0 private boolean varInModel(int var, int[] model) {
 45  0 for (int i = 0; i < model.length; i++)
 46  0 if (var == model[i])
 47  0 return true;
 48  0 return false;
 49    }
 50   
 51  0 public IVec<BigInteger> getCoeffs() {
 52  0 IVec<BigInteger> coefbis = new Vec<BigInteger>(coeffs.size());
 53  0 coeffs.copyTo(coefbis);
 54  0 return coefbis;
 55    }
 56   
 57  0 public IVecInt getVars() {
 58  0 IVecInt varbis = new VecInt(vars.size());
 59  0 vars.copyTo(varbis);
 60  0 return varbis;
 61    }
 62   
 63    }