Clover coverage report -
Coverage timestamp: ven. févr. 24 2006 06:59:02 CET
file stats: LOC: 79   Methods: 2
NCLOC: 54   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
PickGSatSimple.java 0% 0% 0% 0%
coverage
 1    /**
 2    *
 3    */
 4    package org.sat4j.ubcsat.algorithms;
 5   
 6    import org.sat4j.ubcsat.Random;
 7    import org.sat4j.ubcsat.lit.Lits;
 8    import org.sat4j.ubcsat.triggers.VarScore;
 9   
 10    /**
 11    * @author bourgeois
 12    */
 13    public class PickGSatSimple implements IAlgorithm {
 14   
 15    private int iNumCandidates;
 16   
 17    private int[] aCandidateList;
 18   
 19    private int iInitVarFlip = 0;
 20   
 21  0 public void init(int nVars) {
 22  0 if (iInitVarFlip > 0) {
 23  0 for (int j = 0; j < iInitVarFlip; j++) {
 24  0 int iVar;
 25  0 boolean bAdded = true;
 26  0 do {
 27  0 iVar = (int) Random.randomInt(nVars) + 1;
 28  0 if (j > 0) {
 29  0 for (int k = 0; k < j; k++) {
 30  0 if (aCandidateList[k] == iVar) {
 31  0 bAdded = false;
 32  0 break;
 33    }
 34    }
 35    }
 36  0 } while (!bAdded);
 37  0 aCandidateList[j] = iVar;
 38  0 Lits.aVarValue[iVar] = 1 - Lits.aVarValue[iVar];
 39    }
 40    }
 41    }
 42   
 43  0 public void selectVariableToFlip(int nClauses, int nVars, VarScore score) {
 44  0 long iScore;
 45   
 46  0 iNumCandidates = 0;
 47  0 if (aCandidateList == null) {
 48  0 aCandidateList = new int[nVars];
 49    }
 50  0 long iBestScore = nClauses;
 51   
 52    /* check score of all variables */
 53  0 for (int j = 1; j <= nVars; j++) {
 54    /* use cached value of score */
 55  0 iScore = score.aVarScore[j];
 56    /* build candidate list of best vars */
 57  0 if (iScore <= iBestScore) {
 58  0 if (iScore < iBestScore) {
 59  0 iNumCandidates = 0;
 60  0 iBestScore = iScore;
 61    }
 62  0 aCandidateList[iNumCandidates++] = j;
 63    }
 64    }
 65    // for(int j=0;j<nClauses;j++)
 66    // System.err.println("aCandidateList["+j+"]="+TriggerAdapter.aCandidateList[j]);
 67   
 68    // System.err.println("iNumCandidates="+iNumCandidates);
 69    /* select flip candidate uniformly from candidate list */
 70  0 if (iNumCandidates > 1) {
 71  0 score.iFlipCandidate = aCandidateList[(int) Random
 72    .randomInt(iNumCandidates)];
 73    } else {
 74  0 score.iFlipCandidate = aCandidateList[0];
 75    }
 76   
 77    // System.err.println("iFlipCandidate="+TriggerAdapter.iFlipCandidate);
 78    }
 79    }