Commit 586edc12 authored by Daniel Le Berre's avatar Daniel Le Berre

First tools for BR4CP contributed by Emmanuel Lonca.


git-svn-id: svn+ssh://svn.forge.ow2.org/svnroot/sat4j/maven/trunk@1959 ba638df5-4473-46d1-82f8-c3ae2a17a6e1
parent 0638ed29
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Built-By: Daniel Le Berre
Main-Class: org.sat4j.br4cp.Br4cpBackbonesCLI
Specification-Title: SAT4J
Specification-Version: NA
Specification-Vendor: Daniel Le Berre
Implementation-Title: SAT4J
Implementation-Version: 9.9.9.token
Implementation-Vendor: CRIL CNRS UMR 8188 - Universite d'Artois
Class-Path: org.sat4j.core.jar
Bundle-RequiredExecutionEnvironment: J2SE-1.5
<?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.ow2.sat4j</groupId>
<artifactId>org.ow2.sat4j.pom</artifactId>
<version>2.3.4-SNAPSHOT</version>
</parent>
<description>
The br4cp library contains algorithms related to the BR4CP French ANR project.
</description>
<artifactId>org.sat4j.br4cp</artifactId>
<name>SAT4J pseudo</name>
<developers>
<developer>
<id>leberre</id>
<name>Daniel Le Berre</name>
<email>leberre@cril.univ-artois.fr</email>
<url>http://www.cril.univ-artois.fr/~leberre/</url>
<organization>CRIL</organization>
<organizationUrl>http://www.cril.univ-artois.fr/</organizationUrl>
<roles>
<role>architect</role>
<role>developer</role>
</roles>
</developer>
<developer>
<id>lonca</id>
<name>Emmanuel Lonca</name>
<email>lonca@cril.fr</email>
<url>http://www.cril.univ-artois.fr/~lonca/</url>
<organization>CRIL</organization>
<organizationUrl>http://www.cril.univ-artois.fr/</organizationUrl>
<roles>
<role>developer</role>
</roles>
</developer>
</developers>
<dependencies>
<dependency>
<groupId>org.ow2.sat4j</groupId>
<artifactId>org.ow2.sat4j.core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.ow2.sat4j</groupId>
<artifactId>org.ow2.sat4j.core</artifactId>
<version>${project.version}</version>
<type>test-jar</type>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.4</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
package org.sat4j.br4cp;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import org.sat4j.core.VecInt;
import org.sat4j.minisat.SolverFactory;
import org.sat4j.specs.ISolver;
import org.sat4j.specs.IVecInt;
import org.sat4j.specs.IteratorInt;
import org.sat4j.specs.TimeoutException;
import org.sat4j.tools.Backbone;
public class Br4cpBackbonesCLI {
/**
* @param args
*/
public static void main(String[] args) {
ISolver solver = SolverFactory.newDefault();
// solver.setVerbose(true);
Br4cpLPReader reader = new Br4cpLPReader(solver);
try {
reader.parseInstance(args[0]);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
BufferedReader inReader = new BufferedReader(new InputStreamReader(
System.in));
IVecInt assumps = new VecInt();
System.out.println("console commands :");
System.out.println("#clear : clear assumps");
System.out.println("#quit : quit program");
System.out.println("#assumps : show assumptions");
System.out.println("#backbones : compute the backbones");
System.out.println("optionName : assumps this option");
System.out.println();
for (;;) {
try {
System.out.print("$ ");
String line = inReader.readLine();
if ("#clear".equals(line)) {
assumps = new VecInt();
} else if ("#quit".equals(line)) {
break;
} else if ("#assumps".equals(line)) {
System.out.print("assumps:");
IteratorInt iterator = assumps.iterator();
while (iterator.hasNext())
System.out.print(" "
+ reader.getVarName(iterator.next()));
System.out.println();
} else if ("#backbones".equals(line)) {
try {
IVecInt backbones = Backbone.compute(solver, assumps);
System.out.print("assumps:");
IteratorInt iterator = backbones.iterator();
while (iterator.hasNext()) {
System.out.print(" ");
int next = iterator.next();
if (next < 0) {
System.out
.print("-" + reader.getVarName(-next));
} else {
System.out.print(" " + reader.getVarName(next));
}
}
System.out.println();
} catch (TimeoutException e) {
System.err.println("Timeout occured. Sorry :-/");
}
} else {
Integer id = reader.getVarId(line);
if (id == null) {
System.out.println("unknown option : " + line);
continue;
}
assumps.push(id);
}
} catch (IOException e) {
e.printStackTrace();
break;
}
}
}
}
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