Description: Upstream changes introduced in version 2.3.0-2
 This patch has been created by dpkg-source during the package build.
 Here's the last changelog entry, hopefully it gives details on why
 those changes were made:
 .
 sat4j (2.3.0-2) unstable; urgency=low
 .
   * Include maxsat solver (closes: #636784)
 .
 The person named in the Author field signed this changelog entry.
Author: Michael Tautschnig <mt@debian.org>
Bug-Debian: http://bugs.debian.org/636784

---
The information above should follow the Patch Tagging Guidelines, please
checkout http://dep.debian.net/deps/dep3/ to learn about the format. Here
are templates for supplementary fields that you might want to add:

Origin: <vendor|upstream|other>, <url of original patch>
Bug: <url in upstream bugtracker>
Bug-Debian: http://bugs.debian.org/<bugnumber>
Bug-Ubuntu: https://launchpad.net/bugs/<bugnumber>
Forwarded: <no|not-needed|url proving that it has been forwarded>
Reviewed-By: <name and email of someone who approved the patch>
Last-Update: <YYYY-MM-DD>

--- /dev/null
+++ sat4j-2.3.0/org.sat4j.maxsat/pom.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <groupId>org.sat4j</groupId>
+    <artifactId>org.sat4j.pom</artifactId>
+    <version>2.3.0</version>
+  </parent>
+  <artifactId>org.sat4j.maxsat</artifactId>
+  <name>SAT4J maxsat</name>
+  <dependencies>
+    <dependency>
+      <groupId>org.sat4j</groupId>
+      <artifactId>org.sat4j.core</artifactId>
+      <version>${project.version}</version>
+      <scope>compile</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.sat4j</groupId>
+      <artifactId>org.sat4j.pb</artifactId>
+      <version>${project.version}</version>
+      <scope>compile</scope>
+    </dependency>
+    <dependency>
+      <groupId>commons-cli</groupId>
+      <artifactId>commons-cli</artifactId>
+      <version>1.1</version>
+    </dependency>
+  </dependencies>
+</project>
--- /dev/null
+++ sat4j-2.3.0/org.sat4j.maxsat/build.properties
@@ -0,0 +1,5 @@
+bin.includes = plugin.properties,\
+               META-INF/,\
+               .
+source.. = src/main/java/,\
+           src/test/java/
--- /dev/null
+++ sat4j-2.3.0/org.sat4j.maxsat/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>org.sat4j.maxsat</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.pde.ManifestBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.pde.SchemaBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+		<nature>org.eclipse.pde.PluginNature</nature>
+	</natures>
+</projectDescription>
--- /dev/null
+++ sat4j-2.3.0/org.sat4j.maxsat/plugin.properties
@@ -0,0 +1,3 @@
+bundleName = SAT4J Pseudo
+providerName = CRIL CNRS UMR 8188 - Universite d'Artois
+
--- /dev/null
+++ sat4j-2.3.0/org.sat4j.maxsat/.classpath
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" path="src/main/java"/>
+	<classpathentry kind="src" path="src/test/java"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
+	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+	<classpathentry kind="output" path="bin"/>
+</classpath>
--- /dev/null
+++ sat4j-2.3.0/org.sat4j.maxsat/src/test/java/org/sat4j/maxsat/Inconsistent_Example.wcnf
@@ -0,0 +1,5 @@
+c ------------------------------------------------------
+p wcnf 1 2
+1      1  0
+2     -1  0
+c ------------------------------------------------------
--- /dev/null
+++ sat4j-2.3.0/org.sat4j.maxsat/src/test/java/org/sat4j/maxsat/MichalBug.java
@@ -0,0 +1,96 @@
+package org.sat4j.maxsat;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+import org.sat4j.core.VecInt;
+import org.sat4j.specs.ContradictionException;
+import org.sat4j.specs.IOptimizationProblem;
+import org.sat4j.specs.IProblem;
+import org.sat4j.specs.TimeoutException;
+import org.sat4j.tools.OptToSatAdapter;
+
+public class MichalBug {
+
+	@Test
+	public void testMichalReportedProblem() throws ContradictionException,
+			TimeoutException {
+		WeightedMaxSatDecorator maxSATSolver = new WeightedMaxSatDecorator(
+				SolverFactory.newLight());
+
+		final int OPTIMUM_FOUND = 0;
+		final int UNSATISFIABLE = 1;
+
+		maxSATSolver.newVar(2);
+		maxSATSolver.setExpectedNumberOfClauses(4);
+
+		int[] clause_1 = { 1, 1, 2 };
+		maxSATSolver.addClause(new VecInt(clause_1));
+
+		int[] clause_2 = { 100, -1, -2 };
+		maxSATSolver.addClause(new VecInt(clause_2));
+
+		int[] clause_3 = { 1000, 1, -2 };
+		maxSATSolver.addClause(new VecInt(clause_3));
+
+		int[] clause_4 = { 100000, -1, 2 };
+		maxSATSolver.addClause(new VecInt(clause_4));
+
+		IOptimizationProblem problem = maxSATSolver;
+
+		int exitCode = UNSATISFIABLE;
+		boolean isSatisfiable = false;
+		try {
+			while (problem.admitABetterSolution()) {
+				isSatisfiable = true;
+				problem.discardCurrentSolution();
+			}
+			if (isSatisfiable) {
+				exitCode = OPTIMUM_FOUND;
+			} else {
+				exitCode = UNSATISFIABLE;
+			}
+		} catch (ContradictionException ex) {
+			assert (isSatisfiable);
+			exitCode = OPTIMUM_FOUND;
+		}
+
+		assertEquals(OPTIMUM_FOUND,exitCode);
+		int[] model = problem.model();
+		assertEquals(2,model.length);
+		assertEquals(-1,model[0]);
+		assertEquals(-2,model[1]);
+	}
+	
+	@Test
+	public void testMichalWithOptAdapter() throws ContradictionException,
+			TimeoutException {
+		WeightedMaxSatDecorator maxSATSolver = new WeightedMaxSatDecorator(
+				SolverFactory.newLight());
+
+		maxSATSolver.newVar(2);
+		maxSATSolver.setExpectedNumberOfClauses(4);
+
+		int[] clause_1 = { 1, 1, 2 };
+		maxSATSolver.addClause(new VecInt(clause_1));
+
+		int[] clause_2 = { 100, -1, -2 };
+		maxSATSolver.addClause(new VecInt(clause_2));
+
+		int[] clause_3 = { 1000, 1, -2 };
+		maxSATSolver.addClause(new VecInt(clause_3));
+
+		int[] clause_4 = { 100000, -1, 2 };
+		maxSATSolver.addClause(new VecInt(clause_4));
+
+		IProblem problem = new OptToSatAdapter(maxSATSolver);
+
+		boolean isSatisfiable = problem.isSatisfiable();
+
+		assertEquals(true, isSatisfiable);
+		int[] model = problem.model();
+		assertEquals(2,model.length);
+		assertEquals(-1,model[0]);
+		assertEquals(-2,model[1]);
+	}
+}
--- /dev/null
+++ sat4j-2.3.0/org.sat4j.maxsat/src/test/java/org/sat4j/maxsat/Inconsistent1.wcnf
@@ -0,0 +1,8 @@
+c ------------------------------------------------------
+p wcnf 3 5
+1      1  0
+1      2  0
+1      3  0
+4      1  0
+4     -1  0
+c ------------------------------------------------------
--- /dev/null
+++ sat4j-2.3.0/org.sat4j.maxsat/src/test/java/org/sat4j/maxsat/Inconsistent2.wcnf
@@ -0,0 +1,9 @@
+c ------------------------------------------------------
+p wcnf 3 6
+1      1  0
+1      2  0
+1      3  0
+4      1  0
+4     -1  0
+4     -1  0
+c ------------------------------------------------------
--- /dev/null
+++ sat4j-2.3.0/org.sat4j.maxsat/src/test/java/org/sat4j/maxsat/Example.wcnf
@@ -0,0 +1,7 @@
+c ------------------------------------------------------
+p wcnf 4 4
+1      1  0
+1      2  0
+1     -3  0
+1      4  0
+c ------------------------------------------------------
--- /dev/null
+++ sat4j-2.3.0/org.sat4j.maxsat/src/test/java/org/sat4j/maxsat/MarcelBugsTests.java
@@ -0,0 +1,70 @@
+package org.sat4j.maxsat;
+
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.net.URL;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.sat4j.maxsat.reader.WDimacsReader;
+import org.sat4j.specs.IOptimizationProblem;
+import org.sat4j.specs.IProblem;
+import org.sat4j.tools.OptToSatAdapter;
+
+public class MarcelBugsTests {
+
+	private WeightedMaxSatDecorator maxsat;
+	private WDimacsReader reader;
+	
+	@Before
+	public void init() {
+		maxsat = new WeightedMaxSatDecorator(SolverFactory.newLight());
+		reader = new WDimacsReader(maxsat);
+	}
+	
+	@Test
+	public void testProblemWithDuplicatedOppositeLiterals2() {
+		testProblemWithExpectedAnswer("Inconsistent2.wcnf", new int[] {-1,2,3},5);
+	}
+	
+	@Test
+	public void testProblemWithDuplicatedOppositeLiterals1() {
+		testProblemWithExpectedAnswer("Inconsistent1.wcnf", new int[] {1,2,3},4);
+	}
+	
+	@Test
+	public void testSimpleProblemWithTwoOppositeLiterals() {
+		testProblemWithExpectedAnswer("Inconsistent_Example.wcnf", new int[] {-1},1);
+	}
+
+	@Test
+	public void testProblemWithNegatedLiterals() {
+		testProblemWithExpectedAnswer("Example.wcnf", new int[] {1,2,-3,4},0);
+	}
+	
+	@Test
+	public void testProblemWithDuplicatedLiterals() {
+		testProblemWithExpectedAnswer("AnotherExample.wcnf", new int[] {1},2);
+	}
+	
+	private void testProblemWithExpectedAnswer(String filename, int [] expectation, int expectedValue) {
+		URL url = MarcelBugsTests.class.getResource(filename);
+		try {
+			IOptimizationProblem problem = (IOptimizationProblem)reader.parseInstance(url.getFile());
+			assertNotNull(problem);
+			IProblem satproblem = new OptToSatAdapter(problem);
+			assertTrue(satproblem.isSatisfiable());
+			int [] model = satproblem.model();
+			assertNotNull(model);
+			assertArrayEquals(expectation, model);
+			assertEquals(expectedValue,problem.getObjectiveValue());
+			
+		} catch (Exception e) {
+			fail(" Problem when reading instance : "+e);
+		}		
+	}
+}
--- /dev/null
+++ sat4j-2.3.0/org.sat4j.maxsat/src/test/java/org/sat4j/maxsat/TestSoftCard.java
@@ -0,0 +1,81 @@
+package org.sat4j.maxsat;
+
+import static org.junit.Assert.*;
+import static org.junit.Assert.assertFalse;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.sat4j.core.VecInt;
+import org.sat4j.specs.ContradictionException;
+import org.sat4j.specs.IVecInt;
+import org.sat4j.specs.TimeoutException;
+
+public class TestSoftCard {
+
+	private WeightedMaxSatDecorator wms;
+	
+	@Before
+	public void setUp() {
+		wms = new WeightedMaxSatDecorator(SolverFactory.newDefault());
+	}
+	@Test
+	public void test() throws ContradictionException, TimeoutException {
+		wms.newVar(5);
+		IVecInt clause = new VecInt();
+		clause.push(1).push(2).push(3);
+		wms.addHardClause(clause);
+		clause.clear();
+		clause.push(1).push(-2);
+		wms.addHardClause(clause);
+		clause.clear();
+		clause.push(1).push(2);
+		wms.addHardClause(clause);
+		clause.clear();
+		clause.push(-1).push(3);
+		wms.addHardClause(clause);
+		clause.clear();
+		clause.push(1).push(2).push(3);
+		wms.addAtMost(clause,1);
+		clause.clear();
+		assertFalse(wms.isSatisfiable());
+	}
+	
+	@Test
+	public void test2() throws ContradictionException, TimeoutException {
+		wms.newVar(5);
+		IVecInt clause = new VecInt();
+		clause.push(1).push(2).push(3);
+		wms.addHardClause(clause);
+		clause.clear();
+		clause.push(1).push(-2);
+		wms.addHardClause(clause);
+		clause.clear();
+		clause.push(1).push(2);
+		wms.addHardClause(clause);
+		clause.clear();
+		clause.push(-1).push(3);
+		wms.addHardClause(clause);
+		clause.clear();
+		clause.push(1).push(2).push(3);
+		wms.addSoftAtMost(clause,1);
+		clause.clear();
+		assertTrue(wms.isSatisfiable());
+	}
+
+	@Test
+	public void test3() throws ContradictionException, TimeoutException {
+		wms.newVar(6);
+		IVecInt clause = new VecInt();
+		clause.push(1).push(2).push(3);
+		wms.addHardClause(clause);
+		clause.clear();
+		clause.push(4).push(5).push(6);
+		wms.addHardClause(clause);
+		clause.clear();
+		clause.push(1).push(2).push(3).push(4).push(5).push(6);
+		wms.addSoftAtMost(clause,1);
+		clause.clear();
+		assertTrue(wms.isSatisfiable());
+	}
+
+}
--- /dev/null
+++ sat4j-2.3.0/org.sat4j.maxsat/src/test/java/org/sat4j/maxsat/AnotherExample.wcnf
@@ -0,0 +1,6 @@
+c ------------------------------------------------------
+p wcnf 1 3
+1      1  0
+2      1  0
+2     -1  0
+c ------------------------------------------------------
--- /dev/null
+++ sat4j-2.3.0/org.sat4j.maxsat/src/test/java/org/sat4j/maxsat/TestDavid.java
@@ -0,0 +1,122 @@
+package org.sat4j.maxsat;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+import org.sat4j.core.VecInt;
+import org.sat4j.opt.MaxSatDecorator;
+import org.sat4j.pb.OptToPBSATAdapter;
+import org.sat4j.specs.ContradictionException;
+import org.sat4j.specs.IVecInt;
+import org.sat4j.specs.TimeoutException;
+import org.sat4j.tools.OptToSatAdapter;
+
+public class TestDavid {
+
+	@Test
+	public void testMaxsat() throws ContradictionException, TimeoutException {
+		MaxSatDecorator maxsat = new MaxSatDecorator(SolverFactory.newLight());
+		maxsat.newVar(3);
+		IVecInt literals = new VecInt();
+		literals.push(1).push(-2).push(3);
+		maxsat.addClause(literals);
+		literals.clear();
+		literals.push(-1).push(-2);
+		maxsat.addClause(literals);
+		literals.clear();
+		literals.push(2);
+		maxsat.addClause(literals);
+		literals.clear();
+		literals.push(-3);
+		maxsat.addClause(literals);
+		OptToSatAdapter opt = new OptToSatAdapter(maxsat);
+		assertTrue(opt.isSatisfiable());
+		assertEquals(1,maxsat.calculateObjective());
+	}
+	
+	@Test
+	public void testMaxsatBis() throws ContradictionException, TimeoutException {
+		MaxSatDecorator maxsat = new MaxSatDecorator(SolverFactory.newLight());
+		maxsat.newVar(3);
+		IVecInt literals = new VecInt();
+		literals.push(1).push(-2);
+		maxsat.addClause(literals);
+		literals.clear();
+		literals.push(-1).push(-2);
+		maxsat.addClause(literals);
+		literals.clear();
+		literals.push(2);
+		maxsat.addClause(literals);
+		literals.clear();
+		literals.push(-3);
+		maxsat.addClause(literals);
+		OptToSatAdapter opt = new OptToSatAdapter(maxsat);
+		assertTrue(opt.isSatisfiable());
+		assertTrue(maxsat.calculateObjective().equals(1));
+		assertFalse(opt.model(3));
+	}
+	
+	@Test
+	public void testPartialWeightedMaxsat() throws ContradictionException, TimeoutException {
+		WeightedMaxSatDecorator maxsat = new WeightedMaxSatDecorator(SolverFactory.newLight());
+		maxsat.newVar(3);
+		IVecInt literals = new VecInt();
+		literals.push(1).push(-2).push(3);
+		maxsat.addHardClause(literals);
+		literals.clear();
+		literals.push(-1).push(-2);
+		maxsat.addHardClause(literals);
+		literals.clear();
+		literals.push(2);
+		maxsat.addSoftClause(10, literals);
+		literals.clear();
+		literals.push(-3);
+		maxsat.addSoftClause(5, literals);
+		OptToPBSATAdapter opt = new OptToPBSATAdapter(maxsat);
+		assertTrue(opt.isSatisfiable());
+		assertTrue(opt.model(2));
+		assertTrue(opt.model(3));
+	}
+	
+	@Test
+	public void testWeightedMinimization() throws ContradictionException, TimeoutException {
+		WeightedMaxSatDecorator maxsat = new WeightedMaxSatDecorator(SolverFactory.newLight());
+		maxsat.newVar(3);
+		IVecInt literals = new VecInt();
+		literals.push(1).push(-2).push(3);
+		maxsat.addHardClause(literals);
+		literals.clear();
+		literals.push(-1).push(-2);
+		maxsat.addHardClause(literals);
+		literals.clear();
+		literals.push(-2).push(3);
+		IVecInt coefs = new VecInt().push(10).push(5);
+		maxsat.addWeightedLiteralsToMinimize(literals, coefs);
+		OptToPBSATAdapter opt = new OptToPBSATAdapter(maxsat);
+		assertTrue(opt.isSatisfiable());
+		assertTrue(opt.model(2));
+		assertTrue(opt.model(3));
+	}
+	
+	@Test
+	public void testExampleDavid() throws ContradictionException, TimeoutException {
+		WeightedMaxSatDecorator maxsat = new WeightedMaxSatDecorator(SolverFactory.newLight());
+		maxsat.newVar(3);
+		IVecInt literals = new VecInt();
+		literals.push(1).push(-2).push(3);
+		maxsat.addHardClause(literals);
+		literals.clear();
+		literals.push(-1).push(-2);
+		maxsat.addHardClause(literals);
+		literals.clear();
+		literals.push(1).push(2).push(3);
+		maxsat.addLiteralsToMinimize(literals);
+		OptToPBSATAdapter opt = new OptToPBSATAdapter(maxsat);
+		assertTrue(opt.isSatisfiable());
+		assertFalse(opt.model(1));
+		assertFalse(opt.model(2));
+		assertFalse(opt.model(3));
+	}
+}
--- /dev/null
+++ sat4j-2.3.0/org.sat4j.maxsat/src/main/java/overview.html
@@ -0,0 +1,32 @@
+<body>
+SAT4J: a SATisfiability library for Java.
+
+<pre>
+/*
+ * SAT4J: a SATisfiability library for Java   
+ * Copyright (C) 2004-2006 Daniel Le Berre
+ * 
+ * Based on the original minisat specification from:
+ * 
+ * An extensible SAT solver. Niklas En and Niklas Srensson.
+ * Proceedings of the Sixth International Conference on Theory 
+ * and Applications of Satisfiability Testing, LNCS 2919, 
+ * pp 502-518, 2003.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *  
+ */
+</pre>
+</body>
\ No newline at end of file
--- /dev/null
+++ sat4j-2.3.0/org.sat4j.maxsat/src/main/java/org/sat4j/maxsat/package.html
@@ -0,0 +1,10 @@
+<body>
+MAXSAT and Weighted Max SAT framework.
+<p>
+That package contains various optimization decorators for solving optimization 
+problems such as MAX-SAT, Weighted MAX-SAT, etc.
+</p>
+<p>
+Those decorators are supposed to be used with the Abstract Optimization Launcher.
+</p>
+</body>
\ No newline at end of file
--- /dev/null
+++ sat4j-2.3.0/org.sat4j.maxsat/src/main/java/org/sat4j/maxsat/WeightedMaxSatDecorator.java
@@ -0,0 +1,475 @@
+/*******************************************************************************
+ * SAT4J: a SATisfiability library for Java Copyright (C) 2004-2008 Daniel Le
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU Lesser General Public License Version 2.1 or later (the
+ * "LGPL"), in which case the provisions of the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of the LGPL, and not to allow others to use your version of
+ * this file under the terms of the EPL, indicate your decision by deleting
+ * the provisions above and replace them with the notice and other provisions
+ * required by the LGPL. If you do not delete the provisions above, a recipient
+ * may use your version of this file under the terms of the EPL or the LGPL.
+ *******************************************************************************/
+package org.sat4j.maxsat;
+
+import java.math.BigInteger;
+
+import org.sat4j.core.Vec;
+import org.sat4j.core.VecInt;
+import org.sat4j.pb.IPBSolver;
+import org.sat4j.pb.ObjectiveFunction;
+import org.sat4j.pb.PBSolverDecorator;
+import org.sat4j.specs.ContradictionException;
+import org.sat4j.specs.IConstr;
+import org.sat4j.specs.IOptimizationProblem;
+import org.sat4j.specs.IVec;
+import org.sat4j.specs.IVecInt;
+import org.sat4j.specs.IteratorInt;
+import org.sat4j.specs.TimeoutException;
+
+/**
+ * A decorator for solving weighted MAX SAT problems.
+ * 
+ * The first value of the list of literals in the addClause() method contains
+ * the weight of the clause.
+ * 
+ * @author daniel
+ * 
+ */
+public class WeightedMaxSatDecorator extends PBSolverDecorator implements
+        IOptimizationProblem {
+
+    public static final BigInteger SAT4J_MAX_BIG_INTEGER = new BigInteger("100000000000000000000000000000000000000000");
+
+	/**
+     * 
+     */
+    private static final long serialVersionUID = 1L;
+
+    protected int nborigvars;
+
+    private int nbexpectedclauses;
+
+    private BigInteger falsifiedWeight = BigInteger.ZERO;
+
+    protected int nbnewvar;
+
+	protected int[] prevmodel;
+	protected boolean[] prevboolmodel;
+
+    protected int[] prevfullmodel;
+    
+    private IConstr previousPBConstr;
+
+    private boolean isSolutionOptimal;
+    
+    public WeightedMaxSatDecorator(IPBSolver solver) {
+        super(solver);
+        solver.setObjectiveFunction(obj);
+    }
+
+    @Override
+    public int newVar(int howmany) {
+        nborigvars = super.newVar(howmany);
+        return nborigvars;
+    }
+
+    @Override
+    public void setExpectedNumberOfClauses(int nb) {
+        nbexpectedclauses = nb;
+        lits.ensure(nb);
+        falsifiedWeight = BigInteger.ZERO;
+        super.setExpectedNumberOfClauses(nb);
+        super.newVar(nborigvars + nbexpectedclauses);
+    }
+
+    @Override
+    public int[] model() {
+		return prevmodel;
+    }
+
+	@Override
+	public boolean model(int var) {
+		return prevboolmodel[var - 1];
+    }
+
+    protected BigInteger top = SAT4J_MAX_BIG_INTEGER;
+
+    public void setTopWeight(BigInteger top) {
+        this.top = top;
+    }
+
+	/**
+	 * Add a set of literals to the solver.
+	 * 
+	 * Here the assumption is that the first literal (literals[0]) is the weight
+	 * of the constraint as found in the MAXSAT evaluation. if the weight is
+	 * greater or equal to the top weight, then the clause is hard, else it is
+	 * soft.
+	 * 
+	 * @param literals
+	 *            a weighted clause, the weight being the first element of the
+	 *            vector.
+	 * @see #setTopWeight(int)
+	 */
+    @Override
+    public IConstr addClause(IVecInt literals) throws ContradictionException {
+        int weight = literals.get(0);
+		literals.delete(0);
+		return addSoftClause(weight, literals);
+	}
+
+	/**
+	 * Add a hard clause in the solver, i.e. a clause that must be satisfied.
+	 * 
+	 * @param literals
+	 *            the clause
+	 * @return the constraint is it is not trivially satisfied.
+	 * @throws ContradictionException
+	 */
+	public IConstr addHardClause(IVecInt literals)
+			throws ContradictionException {
+		return super.addClause(literals);
+	}
+
+	/**
+	 * Add a soft clause in the solver, i.e. a clause with a weight of 1.
+	 * 
+	 * @param literals
+	 *            the clause.
+	 * @return the constraint is it is not trivially satisfied.
+	 * @throws ContradictionException
+	 */
+	public IConstr addSoftClause(IVecInt literals)
+			throws ContradictionException {
+		return addSoftClause(1, literals);
+	}
+
+	/**
+	 * Add a soft clause to the solver.
+	 * 
+	 * if the weight of the clause is greater of equal to the top weight, the
+	 * clause will be considered as a hard clause.
+	 * 
+	 * @param weight
+	 *            the weight of the clause
+	 * @param literals
+	 *            the clause
+	 * @return the constraint is it is not trivially satisfied.
+	 * @throws ContradictionException
+	 */
+	public IConstr addSoftClause(int weight, IVecInt literals)
+			throws ContradictionException {
+		return addSoftClause(BigInteger.valueOf(weight),literals);
+	}
+
+	public IConstr addSoftClause(BigInteger weight, IVecInt literals)
+		throws ContradictionException {
+        if (weight.compareTo(top)<0) {
+
+            if (literals.size() == 1) {
+                // if there is only a coefficient and a literal, no need to
+                // create
+                // a new variable
+                // check first if the literal is already in the list:
+                int lit = -literals.get(0);
+                int index = lits.containsAt(lit);
+                if (index != -1) {
+                    coefs.set(index, coefs.get(index).add(weight));
+                } else {
+                    // check if the opposite literal is already there
+                    index = lits.containsAt(-lit);
+                    if (index != -1) {
+                    	falsifiedWeight = falsifiedWeight.add(weight);
+                        BigInteger oldw = coefs.get(index);
+                        BigInteger diff = oldw.subtract(weight);
+                        if (diff.signum() > 0) {
+                            coefs.set(index, diff);
+                        } else if (diff.signum() < 0) {
+                            lits.set(index, lit);
+                            coefs.set(index, diff.abs());
+                            // remove from falsifiedWeight the
+                            // part of the weight that will remain 
+                            // in the objective function
+                            falsifiedWeight = falsifiedWeight.add(diff);
+                        } else {
+                            assert diff.signum() == 0;                            
+                            lits.delete(index);
+                            coefs.delete(index);
+                        }
+                    } else {
+                        lits.push(lit);
+                        coefs.push(weight);
+                    }
+                }
+                return new UnitWeightedClause();
+            }
+            coefs.push(weight);
+            int newvar = nborigvars + ++nbnewvar;
+			literals.push(newvar);
+            lits.push(newvar);
+        }
+        return super.addClause(literals);
+    }
+
+	/**
+	 * Allow adding a new soft cardinality constraint in the solver.
+	 * 
+	 * @param literals the literals of the cardinality constraint.
+	 * @param degree the degree of the cardinality constraint.
+	 * @return a pseudo boolean constraint encoding that soft constraint.
+	 * @throws ContradictionException if a trivial contradiction is found.
+	 * @since 2.3
+	 */
+	public IConstr addSoftAtLeast(IVecInt literals,int degree) throws ContradictionException {
+		return addSoftAtLeast(BigInteger.ONE,literals,degree);
+	}
+	
+	/**
+	 * Allow adding a new soft cardinality constraint in the solver.
+	 * 
+	 * @param weight the weight of the constraint.
+	 * @param literals the literals of the cardinality constraint.
+	 * @param degree the degree of the cardinality constraint.
+	 * @return a pseudo boolean constraint encoding that soft constraint.
+	 * @throws ContradictionException if a trivial contradiction is found.
+	 * @since 2.3
+	 */
+	public IConstr addSoftAtLeast(int weight,IVecInt literals,int degree) throws ContradictionException {
+		return addSoftAtLeast(BigInteger.valueOf(weight),literals,degree);
+	}
+	
+	/**
+	 * Allow adding a new soft cardinality constraint in the solver.
+	 * 
+	 * @param weight the weight of the constraint.
+	 * @param literals the literals of the cardinality constraint.
+	 * @param degree the degree of the cardinality constraint.
+	 * @return a pseudo boolean constraint encoding that soft constraint.
+	 * @throws ContradictionException if a trivial contradiction is found.
+	 * @since 2.3
+	 */
+	public IConstr addSoftAtLeast(BigInteger weight,IVecInt literals,int degree) throws ContradictionException {
+		if (weight.compareTo(top)<0) {
+			coefs.push(weight);
+            int newvar = nborigvars + ++nbnewvar;
+            lits.push(newvar);
+            IVec<BigInteger> cardcoeffs = new Vec<BigInteger>(literals.size()+1);
+            cardcoeffs.growTo(literals.size(), BigInteger.ONE);
+			literals.push(newvar);			
+			BigInteger bigDegree = BigInteger.valueOf(degree);
+			cardcoeffs.push(bigDegree);
+			return addPseudoBoolean(literals,cardcoeffs,true,bigDegree);
+		} else {
+			return addAtLeast(literals, degree);
+		}
+	}
+	
+	/**
+	 * Allow adding a new soft cardinality constraint in the solver.
+	 * 
+	 * @param literals the literals of the cardinality constraint.
+	 * @param degree the degree of the cardinality constraint.
+	 * @return a pseudo boolean constraint encoding that soft constraint.
+	 * @throws ContradictionException if a trivial contradiction is found.
+	 * @since 2.3
+	 */
+	public IConstr addSoftAtMost(IVecInt literals,int degree) throws ContradictionException {
+		return addSoftAtMost(BigInteger.ONE,literals,degree);
+	}
+	
+	/**
+	 * Allow adding a new soft cardinality constraint in the solver.
+	 * 
+	 * @param weight the weight of the constraint.
+	 * @param literals the literals of the cardinality constraint.
+	 * @param degree the degree of the cardinality constraint.
+	 * @return a pseudo boolean constraint encoding that soft constraint.
+	 * @throws ContradictionException if a trivial contradiction is found.
+	 * @since 2.3
+	 */
+	public IConstr addSoftAtMost(int weight,IVecInt literals,int degree) throws ContradictionException {
+		return addSoftAtMost(BigInteger.valueOf(weight),literals,degree);
+	}
+	
+	/**
+	 * Allow adding a new soft cardinality constraint in the solver.
+	 * 
+	 * @param weight the weight of the constraint.
+	 * @param literals the literals of the cardinality constraint.
+	 * @param degree the degree of the cardinality constraint.
+	 * @return a pseudo boolean constraint encoding that soft constraint.
+	 * @throws ContradictionException if a trivial contradiction is found.
+	 * @since 2.3
+	 */
+	public IConstr addSoftAtMost(BigInteger weight,IVecInt literals,int degree) throws ContradictionException {
+		if (weight.compareTo(top)<0) {
+			coefs.push(weight);
+            int newvar = nborigvars + ++nbnewvar;
+            lits.push(newvar);
+            IVec<BigInteger> cardcoeffs = new Vec<BigInteger>(literals.size()+1);
+            cardcoeffs.growTo(literals.size(), BigInteger.ONE);
+			literals.push(newvar);
+			BigInteger bigDegree = BigInteger.valueOf(degree);
+			cardcoeffs.push(bigDegree.negate());
+			return addPseudoBoolean(literals,cardcoeffs,true,bigDegree);
+		} else {
+			return addAtMost(literals, degree);
+		}
+	}
+	
+	/**
+	 * Set some literals whose sum must be minimized.
+	 * 
+	 * @param literals
+	 *            the sum of those literals must be minimized.
+	 */
+	public void addLiteralsToMinimize(IVecInt literals) {
+		for (IteratorInt it = literals.iterator(); it.hasNext();) {
+			lits.push(it.next());
+			coefs.push(BigInteger.ONE);
+		}
+	}
+
+	/**
+	 * Set some literals whose sum must be minimized.
+	 * 
+	 * @param literals
+	 *            the sum of those literals must be minimized.
+	 * @param coefficients
+	 *            the weight of the literals.
+	 */
+	public void addWeightedLiteralsToMinimize(IVecInt literals,
+			IVec<BigInteger> coefficients) {
+		if (literals.size() != coefs.size())
+			throw new IllegalArgumentException();
+		for (int i = 0; i < literals.size(); i++) {
+			lits.push(literals.get(i));
+			coefs.push(coefficients.get(i));
+		}
+	}
+
+	/**
+	 * Set some literals whose sum must be minimized.
+	 * 
+	 * @param literals
+	 *            the sum of those literals must be minimized.
+	 * @param coefficients
+	 *            the weight of the literals.
+	 */
+	public void addWeightedLiteralsToMinimize(IVecInt literals,
+			IVecInt coefficients) {
+		if (literals.size() != coefficients.size())
+			throw new IllegalArgumentException();
+		for (int i = 0; i < literals.size(); i++) {
+			lits.push(literals.get(i));
+			coefs.push(BigInteger.valueOf(coefficients.get(i)));
+		}
+    }
+    
+    public boolean admitABetterSolution() throws TimeoutException {
+    	return admitABetterSolution(VecInt.EMPTY);
+    }
+    
+    public boolean admitABetterSolution(IVecInt assumps)
+		throws TimeoutException {
+    	isSolutionOptimal = false;
+        boolean result = super.isSatisfiable(assumps,true);
+        if (result) {
+			prevboolmodel = new boolean[nVars()];
+			for (int i = 0; i < nVars(); i++) {
+				prevboolmodel[i] = decorated().model(i + 1);
+			}
+            int nbtotalvars = nborigvars + nbnewvar;
+            if (prevfullmodel == null)
+                prevfullmodel = new int[nbtotalvars];
+            for (int i = 1; i <= nbtotalvars; i++) {
+                prevfullmodel[i - 1] = super.model(i) ? i : -i;
+            }
+            prevmodel = new int[nborigvars];
+			for (int i = 0; i < nborigvars; i++) {
+				prevmodel[i] = prevfullmodel[i];
+			}
+			calculateObjective();
+        } else {
+        	isSolutionOptimal = true;
+			if (previousPBConstr != null) {
+				decorated().removeConstr(previousPBConstr);
+				previousPBConstr = null;
+			}
+		}
+        return result;
+    }
+
+    @Override
+    public void reset() {
+        coefs.clear();
+        lits.clear();
+        nbnewvar = 0;
+        previousPBConstr = null;
+        super.reset();
+    }
+
+    public boolean hasNoObjectiveFunction() {
+        return false;
+    }
+
+    public boolean nonOptimalMeansSatisfiable() {
+        return false;
+    }
+
+    private BigInteger counter;
+
+    public Number calculateObjective() {
+        counter = BigInteger.ZERO;
+        for (int q : prevfullmodel) {
+            int index = lits.containsAt(q);
+            if (index != -1) {
+                counter = counter.add(coefs.get(index));
+            }
+        }
+        return falsifiedWeight.add(counter);
+    }
+
+    private final IVecInt lits = new VecInt();
+
+    private final IVec<BigInteger> coefs = new Vec<BigInteger>();
+
+    private final ObjectiveFunction obj = new ObjectiveFunction(lits, coefs);
+
+    public void discardCurrentSolution() throws ContradictionException {
+        assert lits.size() == coefs.size();
+        if (previousPBConstr!=null) {
+        	removeSubsumedConstr(previousPBConstr);
+        }
+        try {
+			previousPBConstr = super.addPseudoBoolean(lits, coefs, false, counter.add(BigInteger.ONE.negate()));
+		} catch (ContradictionException e) {
+			isSolutionOptimal = true;
+			throw e;
+		}
+    }
+
+	public Number getObjectiveValue() {
+		return falsifiedWeight.add(counter);
+	}
+
+	public void discard() throws ContradictionException {
+		discardCurrentSolution();
+	}
+
+	public void forceObjectiveValueTo(Number forcedValue)
+			throws ContradictionException {
+		super.addPseudoBoolean(lits, coefs, false, (BigInteger)forcedValue);
+	}
+
+	public boolean isOptimal() {
+		return isSolutionOptimal;
+	}
+}
--- /dev/null
+++ sat4j-2.3.0/org.sat4j.maxsat/src/main/java/org/sat4j/maxsat/GenericOptLauncher.java
@@ -0,0 +1,161 @@
+/*******************************************************************************
+ * SAT4J: a SATisfiability library for Java Copyright (C) 2004-2008 Daniel Le Berre
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU Lesser General Public License Version 2.1 or later (the
+ * "LGPL"), in which case the provisions of the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of the LGPL, and not to allow others to use your version of
+ * this file under the terms of the EPL, indicate your decision by deleting
+ * the provisions above and replace them with the notice and other provisions
+ * required by the LGPL. If you do not delete the provisions above, a recipient
+ * may use your version of this file under the terms of the EPL or the LGPL.
+ *******************************************************************************/
+package org.sat4j.maxsat;
+
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.HelpFormatter;
+import org.apache.commons.cli.Options;
+import org.apache.commons.cli.ParseException;
+import org.apache.commons.cli.PosixParser;
+import org.sat4j.AbstractLauncher;
+import org.sat4j.AbstractOptimizationLauncher;
+import org.sat4j.maxsat.reader.WDimacsReader;
+import org.sat4j.opt.MaxSatDecorator;
+import org.sat4j.opt.MinOneDecorator;
+import org.sat4j.reader.DimacsReader;
+import org.sat4j.reader.Reader;
+import org.sat4j.specs.ISolver;
+
+/**
+ * Generic launcher to be used for solving optimization problems.
+ * 
+ * @author daniel
+ * @since 2.0
+ * 
+ */
+public class GenericOptLauncher extends AbstractOptimizationLauncher {
+
+	
+	/**
+     * 
+     */
+	private static final long serialVersionUID = 1L;
+
+	@SuppressWarnings("nls")
+	private Options createCLIOptions() {
+		Options options = new Options();
+		options.addOption("t", "timeout", true,
+				"specifies the timeout (in seconds)");
+		options.addOption("p", "parallel", false,
+				"uses CP and RES pseudo-boolean solver in parallel");
+		options.addOption("T", "timeoutms", true,
+				"specifies the timeout (in milliseconds)");
+		options.addOption("k", "kind", true,
+				"kind of problem: minone, maxsat, etc.");
+		options.addOption("i", "incomplete", false,
+				"incomplete mode for maxsat");
+		return options;
+	}
+
+	@Override
+	public void displayLicense() {
+		super.displayLicense();
+		log("This software uses some libraries from the Jakarta Commons project. See jakarta.apache.org for details."); //$NON-NLS-1$
+	}
+
+	@Override
+	public void usage() {
+		out.println("java -jar sat4j-maxsat.jar instance-name"); //$NON-NLS-1$
+	}
+
+	@Override
+	protected Reader createReader(ISolver aSolver, String problemname) {
+		Reader reader;
+		if (problemname.endsWith(".wcnf")) { //$NON-NLS-1$
+			reader = new WDimacsReader((WeightedMaxSatDecorator) aSolver); //$NON-NLS-1$
+		} else {
+		reader = new DimacsReader(aSolver);
+		}
+		reader.setVerbosity(true);
+		return reader;
+	}
+
+	@Override
+	protected String getInstanceName(String[] args) {
+		return args[args.length - 1];
+	}
+
+	@Override
+	protected ISolver configureSolver(String[] args) {
+		ISolver asolver = null;
+		Options options = createCLIOptions();
+		if (args.length == 0) {
+			HelpFormatter helpf = new HelpFormatter();
+			helpf.printHelp("java -jar sat4j-maxsat.jar", options, true);
+		} else {
+			try {
+				CommandLine cmd = new PosixParser().parse(options, args);
+				int problemindex = args.length - 1;
+				String kind = cmd.getOptionValue("k"); //$NON-NLS-1$
+				if (kind == null) { //$NON-NLS-1$
+					kind = "maxsat";
+				}
+				if ("minone".equalsIgnoreCase(kind)) {
+					asolver = new MinOneDecorator(SolverFactory.newDefault());
+				} else if ("mincost".equalsIgnoreCase(kind)
+						|| args[problemindex].endsWith(".p2cnf")) {
+					asolver = new MinCostDecorator(SolverFactory.newDefault());
+				} else {
+					assert "maxsat".equalsIgnoreCase(kind);
+
+					if (args[problemindex].endsWith(".wcnf")) { //$NON-NLS-1$
+						if (cmd.hasOption("p")) {
+							asolver = new WeightedMaxSatDecorator(
+									org.sat4j.pb.SolverFactory.newBoth());
+						} else {
+							asolver = new WeightedMaxSatDecorator(SolverFactory
+									.newDefault());
+						}
+					} else {
+						if (cmd.hasOption("p")) {
+							asolver = new MaxSatDecorator(
+									org.sat4j.pb.SolverFactory.newBoth());
+						} else {
+							asolver = new MaxSatDecorator(
+									org.sat4j.minisat.SolverFactory
+											.newDefault());
+						}
+					}
+				}
+				if (cmd.hasOption("i")) {
+					setIncomplete(true);
+				}
+				String timeout = cmd.getOptionValue("t");
+				if (timeout == null) {
+					timeout = cmd.getOptionValue("T");
+					if (timeout != null) {
+						asolver.setTimeoutMs(Long.parseLong(timeout));
+					}
+				} else {
+					asolver.setTimeout(Integer.parseInt(timeout));
+				}
+				getLogWriter().println(asolver.toString(COMMENT_PREFIX));
+			} catch (ParseException e1) {
+				HelpFormatter helpf = new HelpFormatter();
+				helpf.printHelp("java -jar sat4jopt.jar", options, true);
+			}
+		}
+		return asolver;
+	}
+
+	public static void main(String[] args) {
+		AbstractLauncher lanceur = new GenericOptLauncher();
+		lanceur.run(args);
+	}
+}
--- /dev/null
+++ sat4j-2.3.0/org.sat4j.maxsat/src/main/java/org/sat4j/maxsat/SolverFactory.java
@@ -0,0 +1,69 @@
+/*******************************************************************************
+* SAT4J: a SATisfiability library for Java Copyright (C) 2004-2008 Daniel Le Berre
+*
+* All rights reserved. This program and the accompanying materials
+* are made available under the terms of the Eclipse Public License v1.0
+* which accompanies this distribution, and is available at
+* http://www.eclipse.org/legal/epl-v10.html
+*
+* Alternatively, the contents of this file may be used under the terms of
+* either the GNU Lesser General Public License Version 2.1 or later (the
+* "LGPL"), in which case the provisions of the LGPL are applicable instead
+* of those above. If you wish to allow use of your version of this file only
+* under the terms of the LGPL, and not to allow others to use your version of
+* this file under the terms of the EPL, indicate your decision by deleting
+* the provisions above and replace them with the notice and other provisions
+* required by the LGPL. If you do not delete the provisions above, a recipient
+* may use your version of this file under the terms of the EPL or the LGPL.
+*******************************************************************************/
+package org.sat4j.maxsat;
+
+import org.sat4j.core.ASolverFactory;
+import org.sat4j.minisat.constraints.MixedDataStructureDanielWL;
+import org.sat4j.minisat.core.DataStructureFactory;
+import org.sat4j.minisat.core.SearchParams;
+import org.sat4j.minisat.core.Solver;
+import org.sat4j.minisat.learning.MiniSATLearning;
+import org.sat4j.minisat.orders.VarOrderHeap;
+import org.sat4j.minisat.restarts.MiniSATRestarts;
+import org.sat4j.pb.IPBSolver;
+
+public class SolverFactory extends ASolverFactory<IPBSolver> {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * Builds a SAT solver for the MAX sat evaluation. Full clause learning, no
+     * restarts,
+     * 
+     * @return a
+     */
+    public static Solver<DataStructureFactory> newMiniMaxSAT() {
+        MiniSATLearning<DataStructureFactory> learning = new MiniSATLearning<DataStructureFactory>();
+        Solver<DataStructureFactory> solver = new Solver<DataStructureFactory>(learning,
+                new MixedDataStructureDanielWL(), new SearchParams(1.2,
+                        100000), new VarOrderHeap(),
+                new MiniSATRestarts());
+        learning.setDataStructureFactory(solver.getDSFactory());
+        learning.setVarActivityListener(solver);
+        return solver;
+    }
+    
+    @Override
+    public IPBSolver defaultSolver() {
+        return newDefault();
+    }
+
+    @Override
+    public IPBSolver lightSolver() {
+        return newLight();
+    }
+
+    public static IPBSolver newDefault() {
+        return org.sat4j.pb.SolverFactory.newDefault();
+    }
+ 
+    public static IPBSolver newLight() {
+        return org.sat4j.pb.SolverFactory.newLight();
+    }
+}
--- /dev/null
+++ sat4j-2.3.0/org.sat4j.maxsat/src/main/java/org/sat4j/maxsat/MinCostDecorator.java
@@ -0,0 +1,209 @@
+/*******************************************************************************
+ * SAT4J: a SATisfiability library for Java Copyright (C) 2004-2008 Daniel Le Berre
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU Lesser General Public License Version 2.1 or later (the
+ * "LGPL"), in which case the provisions of the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of the LGPL, and not to allow others to use your version of
+ * this file under the terms of the EPL, indicate your decision by deleting
+ * the provisions above and replace them with the notice and other provisions
+ * required by the LGPL. If you do not delete the provisions above, a recipient
+ * may use your version of this file under the terms of the EPL or the LGPL.
+ *******************************************************************************/
+package org.sat4j.maxsat;
+
+import java.math.BigInteger;
+
+import org.sat4j.core.Vec;
+import org.sat4j.core.VecInt;
+import org.sat4j.pb.IPBSolver;
+import org.sat4j.pb.PBSolverDecorator;
+import org.sat4j.specs.ContradictionException;
+import org.sat4j.specs.IConstr;
+import org.sat4j.specs.IOptimizationProblem;
+import org.sat4j.specs.IVec;
+import org.sat4j.specs.IVecInt;
+import org.sat4j.specs.TimeoutException;
+
+/**
+ * A decorator that computes minimal cost models. That problem is also known as
+ * binate covering problem.
+ * 
+ * Please make sure that newVar(howmany) is called first to setup the decorator.
+ * 
+ * @author daniel
+ * 
+ */
+public class MinCostDecorator extends PBSolverDecorator implements
+		IOptimizationProblem {
+
+	/**
+     * 
+     */
+	private static final long serialVersionUID = 1L;
+
+	private int[] costs;
+
+	private int[] prevmodel;
+
+	private final IVecInt vars = new VecInt();
+
+	private final IVec<BigInteger> coeffs = new Vec<BigInteger>();
+
+	private int objectivevalue;
+
+	private IConstr prevConstr;
+
+	private boolean isSolutionOptimal;
+	
+	public MinCostDecorator(IPBSolver solver) {
+		super(solver);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.sat4j.tools.SolverDecorator#newVar()
+	 */
+	@Override
+	public int newVar() {
+		throw new UnsupportedOperationException();
+	}
+
+	/**
+	 * Setup the number of variables to use inside the solver.
+	 * 
+	 * It is mandatory to call that method before setting the cost of the
+	 * variables.
+	 * 
+	 * @param howmany
+	 *            the maximum number of variables in the solver.
+	 */
+	@Override
+	public int newVar(int howmany) {
+		costs = new int[howmany + 1];
+		// Arrays.fill(costs, 1);
+		vars.clear();
+		coeffs.clear();
+		for (int i = 1; i <= howmany; i++) {
+			vars.push(i);
+			coeffs.push(BigInteger.ZERO);
+		}
+		// should the default cost be 1????
+		// here it is 0
+		return super.newVar(howmany);
+	}
+
+	/**
+	 * to know the cost of a given var.
+	 * 
+	 * @param var
+	 *            a variable in dimacs format
+	 * @return the cost of that variable when assigned to true
+	 */
+	public int costOf(int var) {
+		return costs[var];
+	}
+
+	/**
+	 * to set the cost of a given var.
+	 * 
+	 * @param var
+	 *            a variable in dimacs format
+	 * @param cost
+	 *            the cost of var when assigned to true
+	 */
+	public void setCost(int var, int cost) {
+		costs[var] = cost;
+		coeffs.set(var - 1, BigInteger.valueOf(cost));
+	}
+
+	public boolean admitABetterSolution() throws TimeoutException {
+		return admitABetterSolution(VecInt.EMPTY);
+	}
+
+	public boolean admitABetterSolution(IVecInt assumps)
+			throws TimeoutException {
+		isSolutionOptimal = false;
+		boolean result = super.isSatisfiable(assumps, true);
+		if (result) {
+			prevmodel = super.model();
+			calculateObjective();
+		} else {
+			isSolutionOptimal = true;
+		}
+		return result;
+	}
+
+	public boolean hasNoObjectiveFunction() {
+		return false;
+	}
+
+	public boolean nonOptimalMeansSatisfiable() {
+		return true;
+	}
+
+	public Number calculateObjective() {
+		objectivevalue = calculateDegree(prevmodel);
+		return new Integer(objectivevalue);
+	}
+
+	private int calculateDegree(int[] prevmodel2) {
+		int tmpcost = 0;
+		for (int i = 1; i < costs.length; i++) {
+			if (prevmodel2[i - 1] > 0) {
+				tmpcost += costs[i];
+			}
+		}
+		return tmpcost;
+	}
+
+	public void discardCurrentSolution() throws ContradictionException {
+		if (prevConstr!=null) {
+			super.removeSubsumedConstr(prevConstr);
+		}
+		try {
+			prevConstr = super.addPseudoBoolean(vars, coeffs, false, BigInteger
+					.valueOf(objectivevalue - 1));
+		} catch (ContradictionException e) {
+			isSolutionOptimal = true;
+			throw e;
+		}
+	}
+
+	@Override
+	public void reset() {
+		prevConstr = null;
+		super.reset();
+	}
+
+	@Override
+	public int[] model() {
+		// DLB findbugs ok
+		return prevmodel;
+	}
+
+	public Number getObjectiveValue() {
+		return objectivevalue;
+	}
+
+	public void discard() throws ContradictionException {
+		discardCurrentSolution();
+	}
+
+	public void forceObjectiveValueTo(Number forcedValue)
+			throws ContradictionException {
+		super.addPseudoBoolean(vars, coeffs, false, (BigInteger)
+				forcedValue);
+	}
+
+	public boolean isOptimal() {
+		return isSolutionOptimal;
+	}
+}
--- /dev/null
+++ sat4j-2.3.0/org.sat4j.maxsat/src/main/java/org/sat4j/maxsat/UnitWeightedClause.java
@@ -0,0 +1,23 @@
+package org.sat4j.maxsat;
+
+import org.sat4j.specs.IConstr;
+
+public class UnitWeightedClause implements IConstr {
+
+	public boolean learnt() {
+		throw new UnsupportedOperationException();
+	}
+
+	public int size() {
+		throw new UnsupportedOperationException();
+	}
+
+	public int get(int i) {
+		throw new UnsupportedOperationException();
+	}
+
+	public double getActivity() {
+		throw new UnsupportedOperationException();
+	}
+
+}
--- /dev/null
+++ sat4j-2.3.0/org.sat4j.maxsat/src/main/java/org/sat4j/maxsat/reader/package.html
@@ -0,0 +1,3 @@
+<body>
+Some utility classes to read problems from plain text files.
+</body>
\ No newline at end of file
--- /dev/null
+++ sat4j-2.3.0/org.sat4j.maxsat/src/main/java/org/sat4j/maxsat/reader/WDimacsReader.java
@@ -0,0 +1,113 @@
+/*******************************************************************************
+* SAT4J: a SATisfiability library for Java Copyright (C) 2004-2008 Daniel Le Berre
+*
+* All rights reserved. This program and the accompanying materials
+* are made available under the terms of the Eclipse Public License v1.0
+* which accompanies this distribution, and is available at
+* http://www.eclipse.org/legal/epl-v10.html
+*
+* Alternatively, the contents of this file may be used under the terms of
+* either the GNU Lesser General Public License Version 2.1 or later (the
+* "LGPL"), in which case the provisions of the LGPL are applicable instead
+* of those above. If you wish to allow use of your version of this file only
+* under the terms of the LGPL, and not to allow others to use your version of
+* this file under the terms of the EPL, indicate your decision by deleting
+* the provisions above and replace them with the notice and other provisions
+* required by the LGPL. If you do not delete the provisions above, a recipient
+* may use your version of this file under the terms of the EPL or the LGPL.
+*******************************************************************************/
+package org.sat4j.maxsat.reader;
+
+import java.io.IOException;
+import java.math.BigInteger;
+
+import org.sat4j.maxsat.WeightedMaxSatDecorator;
+import org.sat4j.reader.DimacsReader;
+import org.sat4j.reader.ParseFormatException;
+import org.sat4j.specs.ContradictionException;
+
+/**
+ * Simple reader for the weighted maxsat problem.
+ * 
+ * @author daniel
+ *
+ */
+public class WDimacsReader extends DimacsReader {
+
+	protected BigInteger weight;
+	protected BigInteger top;
+	
+    @Override
+	protected void flushConstraint() throws ContradictionException {
+    	try {
+    		decorator.addSoftClause(weight, literals);
+		} catch (IllegalArgumentException ex) {
+			if (isVerbose()) {
+				System.err.println("c Skipping constraint " + literals);
+			}
+		}
+    	
+	}
+
+	@Override
+	protected boolean handleLine() throws ContradictionException, IOException, ParseFormatException {
+		weight = scanner.nextBigInteger();
+		return super.handleLine();
+	}
+
+	/**
+     * 
+     */
+    private static final long serialVersionUID = 1L;
+
+    private final WeightedMaxSatDecorator decorator;
+    
+    public WDimacsReader(WeightedMaxSatDecorator solver) {
+        super(solver,"wcnf");
+        decorator = solver;
+    }
+
+    public WDimacsReader(WeightedMaxSatDecorator solver, String format) {
+        super(solver, format);
+        decorator = solver;
+    }
+
+    @Override
+    protected void readProblemLine() throws IOException,
+            ParseFormatException {
+    	String line = scanner.nextLine().trim();
+
+		if (line == null) {
+			throw new ParseFormatException(
+					"premature end of file: <p cnf ...> expected");
+		}
+		String[] tokens = line.split("\\s+");
+		if (tokens.length < 4 || !"p".equals(tokens[0])
+				|| !formatString.equals(tokens[1])) {
+			throw new ParseFormatException("problem line expected (p cnf ...)");
+		}
+
+		int vars;
+
+		// reads the max var id
+		vars = Integer.parseInt(tokens[2]);
+		assert vars > 0;
+		solver.newVar(vars);
+		// reads the number of clauses
+		expectedNbOfConstr = Integer.parseInt(tokens[3]);
+		assert expectedNbOfConstr > 0;
+		solver.setExpectedNumberOfClauses(expectedNbOfConstr);
+		
+        if ("wcnf".equals(formatString)) {
+            // assume we are in weighted MAXSAT mode
+            if (tokens.length==5) {
+                top = new BigInteger(tokens[4]);
+            } else {
+                top = WeightedMaxSatDecorator.SAT4J_MAX_BIG_INTEGER;
+            }             
+            decorator.setTopWeight(top);
+        }
+    }
+
+    
+}
--- /dev/null
+++ sat4j-2.3.0/org.sat4j.maxsat/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,12 @@
+#Wed Aug 06 17:05:17 CEST 2008
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.5
--- /dev/null
+++ sat4j-2.3.0/org.sat4j.maxsat/META-INF/MANIFEST.MF
@@ -0,0 +1,21 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %bundleName
+Bundle-SymbolicName: org.sat4j.maxsat
+Bundle-Version: 9.9.9.token
+Export-Package: org.sat4j.maxsat;version="9.9.9.token",
+ org.sat4j.maxsat.reader;version="9.9.9.token"
+Bundle-Vendor: %providerName
+Bundle-Localization: plugin
+Require-Bundle: org.sat4j.core,
+ org.sat4j.pb,
+ org.apache.commons.cli;bundle-version="1.0.0"
+Built-By: Daniel Le Berre
+Main-Class: org.sat4j.maxsat.GenericOptLauncher
+Specification-Title: SAT4J
+Specification-Version: NA
+Specification-Vendor: Daniel Le Berre
+Implementation-Title: SAT4J
+Implementation-Version: 2.0 
+Implementation-Vendor: CRIL CNRS UMR 8188 - Universite d'Artois
+Class-Path: org.sat4j.pb.jar lib/commons-cli.jar
