View Javadoc

1   /*******************************************************************************
2    * SAT4J: a SATisfiability library for Java Copyright (C) 2004, 2012 Artois University and CNRS
3    *
4    * All rights reserved. This program and the accompanying materials
5    * are made available under the terms of the Eclipse Public License v1.0
6    * which accompanies this distribution, and is available at
7    *  http://www.eclipse.org/legal/epl-v10.html
8    *
9    * Alternatively, the contents of this file may be used under the terms of
10   * either the GNU Lesser General Public License Version 2.1 or later (the
11   * "LGPL"), in which case the provisions of the LGPL are applicable instead
12   * of those above. If you wish to allow use of your version of this file only
13   * under the terms of the LGPL, and not to allow others to use your version of
14   * this file under the terms of the EPL, indicate your decision by deleting
15   * the provisions above and replace them with the notice and other provisions
16   * required by the LGPL. If you do not delete the provisions above, a recipient
17   * may use your version of this file under the terms of the EPL or the LGPL.
18   *
19   * Based on the original MiniSat specification from:
20   *
21   * An extensible SAT solver. Niklas Een and Niklas Sorensson. Proceedings of the
22   * Sixth International Conference on Theory and Applications of Satisfiability
23   * Testing, LNCS 2919, pp 502-518, 2003.
24   *
25   * See www.minisat.se for the original solver in C++.
26   *
27   * Contributors:
28   *   CRIL - initial API and implementation
29   *******************************************************************************/
30  
31  package org.sat4j.pb.constraints;
32  
33  import java.io.FileNotFoundException;
34  import java.io.IOException;
35  
36  import org.sat4j.minisat.AbstractAcceptanceTestCase;
37  import org.sat4j.reader.ParseFormatException;
38  import org.sat4j.specs.ISolver;
39  
40  /**
41   * @author leberre
42   * 
43   *         To change the template for this generated type comment go to
44   *         Window>Preferences>Java>Code Generation>Code and Comments
45   */
46  public abstract class AbstractPigeonHoleWithCardinalityTest<T extends ISolver>
47          extends AbstractAcceptanceTestCase<T> {
48  
49      protected static final String PREFIX = System.getProperty("test.pbprefix");
50  
51      /**
52       * Cr?ation d'un test
53       * 
54       * @param arg
55       *            argument ?ventuel
56       */
57      public AbstractPigeonHoleWithCardinalityTest(String arg) {
58          super(arg);
59      }
60  
61      public void testPN34() throws FileNotFoundException, IOException,
62              ParseFormatException {
63          assertTrue(solveInstance(PREFIX + "pigeons/PN-3-4.opb"));
64      }
65  
66      public void testPN4() throws FileNotFoundException, IOException,
67              ParseFormatException {
68          assertFalse(solveInstance(PREFIX + "pigeons/PN-4-3.opb"));
69      }
70  
71      public void testPN45() throws FileNotFoundException, IOException,
72              ParseFormatException {
73          assertTrue(solveInstance(PREFIX + "pigeons/PN-4-5.opb"));
74      }
75  
76      public void testPN5() throws FileNotFoundException, IOException,
77              ParseFormatException {
78          assertFalse(solveInstance(PREFIX + "pigeons/PN-5-4.opb"));
79      }
80  
81      public void testPN56() throws FileNotFoundException, IOException,
82              ParseFormatException {
83          assertTrue(solveInstance(PREFIX + "pigeons/PN-5-6.opb"));
84      }
85  
86      public void testPN6() throws FileNotFoundException, IOException,
87              ParseFormatException {
88          assertFalse(solveInstance(PREFIX + "pigeons/PN-6-5.opb"));
89      }
90  
91      public void testPN67() throws FileNotFoundException, IOException,
92              ParseFormatException {
93          assertTrue(solveInstance(PREFIX + "pigeons/PN-6-7.opb"));
94      }
95  
96      public void testPN7() throws FileNotFoundException, IOException,
97              ParseFormatException {
98          assertFalse(solveInstance(PREFIX + "pigeons/PN-7-6.opb"));
99      }
100 
101     public void testPN78() throws FileNotFoundException, IOException,
102             ParseFormatException {
103         assertTrue(solveInstance(PREFIX + "pigeons/PN-7-8.opb"));
104     }
105 
106     public void testPN8() throws FileNotFoundException, IOException,
107             ParseFormatException {
108         assertFalse(solveInstance(PREFIX + "pigeons/PN-8-7.opb"));
109     }
110 
111     public void testPN89() throws FileNotFoundException, IOException,
112             ParseFormatException {
113         assertTrue(solveInstance(PREFIX + "pigeons/PN-8-9.opb"));
114     }
115 
116     public void testPN9() throws FileNotFoundException, IOException,
117             ParseFormatException {
118         assertFalse(solveInstance(PREFIX + "pigeons/PN-9-8.opb"));
119     }
120 
121     public void testPN910() throws FileNotFoundException, IOException,
122             ParseFormatException {
123         assertTrue(solveInstance(PREFIX + "pigeons/PN-9-10.opb"));
124     }
125 }