package hu.webarticum.jsatbuilder.builder.common;

import java.util.Collection;
import java.util.List;

import hu.webarticum.jsatbuilder.builder.core.Definition;
import hu.webarticum.jsatbuilder.solver.core.Solver;

public class EqualConstraint extends AbstractLiteralListConstraint {
    
    public EqualConstraint(Definition... definitions) {
        super(false, definitions);
    }
    
    public EqualConstraint(DefinitionLiteral... literals) {
        super(false, literals);
    }
    
    public EqualConstraint(Collection<?> literalsOrDefinitions) {
        super(false, literalsOrDefinitions);
    }

    @Override
    public void fillSolver(Solver solver) {
        List<Solver.Literal> solverLiterals = getLiteralListManager().getSolverLiterals();
        int literalCount = solverLiterals.size();
        if (literalCount > 1) {
            for (int i = 0; i < literalCount; i++) {
                int previousIndex = i == 0 ? literalCount - 1 : i - 1;
                Solver.Literal previousLiteral = solverLiterals.get(previousIndex);
                Solver.Literal currentLiteral = solverLiterals.get(i);
                solver.add(new Solver.Clause(previousLiteral, currentLiteral.getNegated()));
                solver.add(new Solver.Clause(previousLiteral.getNegated(), currentLiteral));
            }
        }
    }

}

@@ -151,24 +151,81 @@
 Definition;%0A
+import hu.webarticum.jsatbuilder.builder.core.Viability;%0A
 import hu.we
@@ -663,16 +663,162 @@
 %0A    %7D%0A%0A
+    @Override%0A    protected Viability createViability(List%3CDefinition%3E definitions) %7B%0A        return new AtLeastViability(1, definitions);%0A    %7D%0A%0A
     @Ove

Define proper viability for EqualConstraint