Commit a778dd74 authored by Daniel Le Berre's avatar Daniel Le Berre

Making Vec parameterized by a Serializable type.

parent 79bddb6d
Pipeline #3359 failed with stages
in 1 minute and 20 seconds
package org.sat4j.core;
import java.io.Serializable;
/*******************************************************************************
* SAT4J: a SATisfiability library for Java Copyright (C) 2004, 2012 Artois University and CNRS
*
......@@ -42,7 +43,7 @@ import org.sat4j.specs.IVec;
* @param <T>
* the type of the container.
*/
public final class ReadOnlyVec<T> implements IVec<T> {
public final class ReadOnlyVec<T extends Serializable> implements IVec<T> {
/**
*
......
......@@ -29,6 +29,7 @@
*******************************************************************************/
package org.sat4j.core;
import java.io.Serializable;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Iterator;
......@@ -43,7 +44,7 @@ import org.sat4j.specs.IVec;
*
* @author leberre
*/
public final class Vec<T> implements IVec<T> {
public final class Vec<T extends Serializable> implements IVec<T> {
// MiniSat -- Copyright (c) 2003-2005, Niklas Een, Niklas Sorensson
//
// Permission is hereby granted, free of charge, to any person obtaining a
......
......@@ -29,12 +29,14 @@
*******************************************************************************/
package org.sat4j.minisat.core;
import java.io.Serializable;
/**
* Interface providing the undoable service.
*
* @author leberre
*/
public interface Undoable {
public interface Undoable extends Serializable {
/**
* Method called when backtracking
......
......@@ -29,6 +29,8 @@
*******************************************************************************/
package org.sat4j.specs;
import java.io.Serializable;
/**
* This interface is to be implemented by the classes wanted to be notified of
* the falsification of a literal.
......@@ -38,7 +40,7 @@ package org.sat4j.specs;
*
* @author leberre
*/
public interface Propagatable {
public interface Propagatable extends Serializable {
/**
* Propagate the truth value of a literal in constraints in which that
......
package org.sat4j.intervalorders;
public abstract class IRelation {
import java.io.Serializable;
public abstract class IRelation implements Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
private int numberOfVotes;
private int penalty;
......
......@@ -58,7 +58,7 @@ public class OrderedObjsOWAOptimizer extends AbstractLinMultiObjOptimizer {
private static final long serialVersionUID = 1L;
protected final List<IntegerVariable> objBoundVariables = new ArrayList<IntegerVariable>();
protected final transient List<IntegerVariable> objBoundVariables = new ArrayList<IntegerVariable>();
private final List<IVecInt> atLeastFlags = new ArrayList<IVecInt>();
......
......@@ -40,7 +40,7 @@ public class SumLeximinDecompositionOWAOptimizer
private final IIntegerPBSolver solver;
protected final List<IntegerVariable> objBoundVariables = new ArrayList<IntegerVariable>();
protected final transient List<IntegerVariable> objBoundVariables = new ArrayList<IntegerVariable>();
private final List<IVecInt> atLeastFlags = new ArrayList<IVecInt>();
......
......@@ -29,6 +29,7 @@
*******************************************************************************/
package org.sat4j.pb.tools;
import java.io.Serializable;
import java.math.BigInteger;
import java.util.Collection;
......@@ -40,8 +41,13 @@ import org.sat4j.specs.IVecInt;
import org.sat4j.specs.TimeoutException;
import org.sat4j.tools.SolutionFoundListener;
public abstract class AbstractLexicoHelper<T, C> extends DependencyHelper<T, C>
implements SolutionFoundListener {
public abstract class AbstractLexicoHelper<T extends Serializable, C>
extends DependencyHelper<T, C> implements SolutionFoundListener {
/**
*
*/
private static final long serialVersionUID = 1L;
private final LexicoDecoratorPB lexico;
......
......@@ -60,7 +60,7 @@ public class CardConstrFinder
private boolean shouldDisplayStatus = false;
private Set<Integer> authorizedExtLits = null;
private final Set<Integer> authorizedExtLits = new HashSet<Integer>();;
private boolean verbose = false;
......@@ -377,7 +377,7 @@ public class CardConstrFinder
}
public void setAuthorizedExtLits(IVecInt lits) {
this.authorizedExtLits = new HashSet<Integer>();
this.authorizedExtLits.clear();
for (IteratorInt it = lits.iterator(); it.hasNext();)
this.authorizedExtLits.add(it.next());
}
......
......@@ -64,7 +64,8 @@ import org.sat4j.tools.GateTranslator;
* @param <C>
* The class of the object to map to each constraint.
*/
public class DependencyHelper<T, C> implements Serializable {
public class DependencyHelper<T extends Serializable, C>
implements Serializable {
public static final INegator NO_NEGATION = new INegator() {
......
......@@ -29,6 +29,8 @@
*******************************************************************************/
package org.sat4j.pb.tools;
import java.io.Serializable;
import org.sat4j.core.Vec;
import org.sat4j.core.VecInt;
import org.sat4j.specs.ContradictionException;
......@@ -37,7 +39,7 @@ import org.sat4j.specs.IVec;
import org.sat4j.specs.IVecInt;
import org.sat4j.specs.IteratorInt;
public class DisjunctionRHS<T, C> {
public class DisjunctionRHS<T extends Serializable, C> {
private final IVecInt literals;
private final DependencyHelper<T, C> helper;
......
......@@ -30,6 +30,7 @@
package org.sat4j.pb.tools;
import java.io.Serializable;
import java.util.Iterator;
import org.sat4j.core.Vec;
......@@ -48,7 +49,7 @@ import org.sat4j.specs.IVecInt;
* @param <T>
* @param <C>
*/
public class ImplicationAnd<T, C> {
public class ImplicationAnd<T extends Serializable, C> {
private final DependencyHelper<T, C> helper;
private final IVecInt clause;
private final IVec<IConstr> toName = new Vec<IConstr>();
......
......@@ -30,6 +30,7 @@
package org.sat4j.pb.tools;
import java.io.Serializable;
import java.util.Iterator;
import org.sat4j.core.Vec;
......@@ -45,12 +46,13 @@ import org.sat4j.specs.IVec;
* @param <T>
* @param <C>
*/
public class ImplicationNamer<T, C> {
public class ImplicationNamer<T extends Serializable, C> {
private final DependencyHelper<T, C> helper;
private IVec<IConstr> toName = new Vec<IConstr>();
public ImplicationNamer(DependencyHelper<T, C> helper, IVec<IConstr> toName) {
public ImplicationNamer(DependencyHelper<T, C> helper,
IVec<IConstr> toName) {
this.toName = toName;
this.helper = helper;
}
......
......@@ -30,6 +30,8 @@
package org.sat4j.pb.tools;
import java.io.Serializable;
import org.sat4j.core.Vec;
import org.sat4j.specs.ContradictionException;
import org.sat4j.specs.IConstr;
......@@ -44,7 +46,7 @@ import org.sat4j.specs.IVecInt;
* @param <T>
* @param <C>
*/
public class ImplicationRHS<T, C> {
public class ImplicationRHS<T extends Serializable, C> {
private final IVecInt clause;
private final DependencyHelper<T, C> helper;
......
......@@ -29,9 +29,17 @@
*******************************************************************************/
package org.sat4j.pb.tools;
import java.io.Serializable;
import org.sat4j.pb.IPBSolver;
public class LexicoHelper<T, C> extends AbstractLexicoHelper<T, C> {
public class LexicoHelper<T extends Serializable, C>
extends AbstractLexicoHelper<T, C> {
/**
*
*/
private static final long serialVersionUID = 1L;
public LexicoHelper(IPBSolver solver) {
super(new LexicoDecoratorPB(solver));
......
......@@ -29,10 +29,18 @@
*******************************************************************************/
package org.sat4j.pb.tools;
import java.io.Serializable;
import org.sat4j.pb.IIntegerPBSolver;
import org.sat4j.pb.multiobjective.LeximinDecorator;
public class LeximinHelper<T, C> extends AbstractLexicoHelper<T, C> {
public class LeximinHelper<T extends Serializable, C>
extends AbstractLexicoHelper<T, C> {
/**
*
*/
private static final long serialVersionUID = 1L;
public LeximinHelper(IIntegerPBSolver solver) {
super(new LeximinDecorator(solver));
......
......@@ -29,6 +29,7 @@
*******************************************************************************/
package org.sat4j.pb.tools;
import java.io.Serializable;
import java.math.BigInteger;
import java.util.Collection;
......@@ -42,8 +43,13 @@ import org.sat4j.specs.IVecInt;
import org.sat4j.specs.TimeoutException;
import org.sat4j.tools.SolutionFoundListener;
public class LinMultiObjHelper<T, C> extends DependencyHelper<T, C> implements
SolutionFoundListener {
public class LinMultiObjHelper<T extends Serializable, C>
extends DependencyHelper<T, C> implements SolutionFoundListener {
/**
*
*/
private static final long serialVersionUID = 1L;
private IMultiObjOptimizationProblem solver;
private boolean hasASolution;
......
......@@ -29,10 +29,17 @@
*******************************************************************************/
package org.sat4j.pb.tools;
import java.io.Serializable;
import org.sat4j.pb.IPBSolver;
public class SteppedTimeoutLexicoHelper<T, C> extends
AbstractLexicoHelper<T, C> {
public class SteppedTimeoutLexicoHelper<T extends Serializable, C>
extends AbstractLexicoHelper<T, C> {
/**
*
*/
private static final long serialVersionUID = 1L;
public SteppedTimeoutLexicoHelper(IPBSolver solver) {
super(new SteppedTimeoutLexicoDecoratorPB(solver));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment