Clover Coverage Report
Coverage timestamp: mer. juin 27 2007 07:27:16 CEST
27   114   4   5,4
8   54   0,3   5
5     1,6  
1    
 
  JWOrder       Line # 42 27 4 92,5% 0.925
 
  (101)
 
1    /*
2    * SAT4J: a SATisfiability library for Java Copyright (C) 2004-2006 Daniel Le Berre
3    *
4    * Based on the original minisat specification from:
5    *
6    * An extensible SAT solver. Niklas E?n and Niklas S?rensson. Proceedings of the
7    * Sixth International Conference on Theory and Applications of Satisfiability
8    * Testing, LNCS 2919, pp 502-518, 2003.
9    *
10    * This library is free software; you can redistribute it and/or modify it under
11    * the terms of the GNU Lesser General Public License as published by the Free
12    * Software Foundation; either version 2.1 of the License, or (at your option)
13    * any later version.
14    *
15    * This library is distributed in the hope that it will be useful, but WITHOUT
16    * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17    * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
18    * details.
19    *
20    * You should have received a copy of the GNU Lesser General Public License
21    * along with this library; if not, write to the Free Software Foundation, Inc.,
22    * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23    *
24    */
25   
26    package org.sat4j.minisat.orders;
27   
28    import java.util.ArrayList;
29    import java.util.Collections;
30    import java.util.List;
31   
32    import org.sat4j.minisat.core.ILits23;
33   
34    /*
35    * Created on 16 oct. 2003
36    */
37   
38    /**
39    * @author leberre Heuristique du prouveur. Changement par rapport au MiniSAT
40    * original : la gestion activity est faite ici et non plus dans Solver.
41    */
 
42    public class JWOrder extends VarOrder<ILits23> {
43   
44    private static final long serialVersionUID = 1L;
45   
 
46  156150537 toggle private int computeWeight(int var) {
47  156150537 final int p = (var << 1);
48  156150537 int pos2 = lits.nBinaryClauses(p);
49  156150537 int neg2 = lits.nBinaryClauses(p ^ 1);
50  156150537 int pos3 = lits.nTernaryClauses(p);
51  156150537 int neg3 = lits.nTernaryClauses(p ^ 1);
52  156150537 long weight = (pos2 * neg2 * 100 + pos2 + neg2) * 5 + pos3 * neg3 * 10
53    + pos3 + neg3;
54  156150537 assert weight <= Integer.MAX_VALUE;
55  156150537 if (weight == 0) {
56  10 int pos = lits.watches(p).size();
57  10 int neg = lits.watches(p ^ 1).size();
58  10 weight = pos + neg;
59    }
60  156150537 return (int) weight;
61    }
62   
63    /*
64    * (non-Javadoc)
65    *
66    * @see org.sat4j.minisat.VarOrder#setLits(org.sat4j.minisat.Lits)
67    */
 
68  104 toggle @Override
69    public void setLits(ILits23 lits) {
70  104 super.setLits(lits);
71    }
72   
73    /*
74    * (non-Javadoc)
75    *
76    * @see org.sat4j.minisat.IHeuristics#init()
77    */
 
78  104 toggle @Override
79    public void init() {
80  104 super.init();
81  104 List<ValuedLit> v = new ArrayList<ValuedLit>(order.length);
82   
83  25669 for (int i = 1; i < order.length; i++) {
84  25565 ValuedLit t = new ValuedLit(order[i],computeWeight(order[i]>> 1));
85  25565 v.add(t);
86    }
87  104 Collections.sort(v);
88    // System.out.println(v);
89  25669 for (int i = 0; i < v.size(); i++) {
90  25565 ValuedLit t = v.get(i);
91  25565 order[i + 1] = t.id;
92  25565 int index = t.id >> 1;
93  25565 varpos[index] = i + 1;
94  25565 activity[t.id >> 1] = t.count;
95    }
96  104 lastVar = 1;
97   
98    }
99   
100    /*
101    * (non-Javadoc)
102    *
103    * @see org.sat4j.minisat.core.VarOrder#updateActivity(int)
104    */
 
105  156124972 toggle @Override
106    protected void updateActivity(int var) {
107  156124972 activity[var] = computeWeight(var);
108    }
109   
 
110  0 toggle @Override
111    public String toString() {
112  0 return "Jeroslow-Wang static like heuristics updated when new clauses are learnt"; //$NON-NLS-1$
113    }
114    }