Commit 8a723aa0 authored by Daniel Le Berre's avatar Daniel Le Berre

Replacing calls to soout and serr by utility logger method.

parent 2e621c29
Pipeline #3379 canceled with stages
in 13 minutes and 45 seconds
...@@ -49,7 +49,6 @@ import org.sat4j.tools.DotSearchTracing; ...@@ -49,7 +49,6 @@ import org.sat4j.tools.DotSearchTracing;
*/ */
public class KTHLauncher { public class KTHLauncher {
public static Options createCLIOptions() { public static Options createCLIOptions() {
Options options = new Options(); Options options = new Options();
options.addOption("cl", "coeflim", true, options.addOption("cl", "coeflim", true,
...@@ -76,7 +75,8 @@ public class KTHLauncher { ...@@ -76,7 +75,8 @@ public class KTHLauncher {
"Detect cardinality constraints from original constraints. Legal value are never, preproc, inproc, lazy."); "Detect cardinality constraints from original constraints. Legal value are never, preproc, inproc, lazy.");
options.addOption("natural", "natural-static-order", false, options.addOption("natural", "natural-static-order", false,
"Use a static order for decisions, using the natural order of the variables, from 1 to n."); "Use a static order for decisions, using the natural order of the variables, from 1 to n.");
options.addOption("autodiv", "auto-division", false, "Apply division automatically when a common factor is identified."); options.addOption("autodiv", "auto-division", false,
"Apply division automatically when a common factor is identified.");
Option op = options.getOption("coeflim"); Option op = options.getOption("coeflim");
op.setArgName("limit"); op.setArgName("limit");
op = options.getOption("coeflim-small"); op = options.getOption("coeflim-small");
...@@ -101,7 +101,11 @@ public class KTHLauncher { ...@@ -101,7 +101,11 @@ public class KTHLauncher {
} }
public static void log(String str) { public static void log(String str) {
System.out.println("c " + str); log(str, "c ");
}
public static void log(String str, String prefix) {
System.out.println(prefix + str);
} }
public static void main(String[] args) { public static void main(String[] args) {
...@@ -146,8 +150,7 @@ public class KTHLauncher { ...@@ -146,8 +150,7 @@ public class KTHLauncher {
// by default // by default
break; break;
case "preproc": case "preproc":
pbsolver = new PreprocCardConstrLearningSolver<>( pbsolver = new PreprocCardConstrLearningSolver<>(cpsolver);
cpsolver);
break; break;
case "inproc": case "inproc":
InprocCardConstrLearningSolver solver = new InprocCardConstrLearningSolver( InprocCardConstrLearningSolver solver = new InprocCardConstrLearningSolver(
...@@ -238,8 +241,7 @@ public class KTHLauncher { ...@@ -238,8 +241,7 @@ public class KTHLauncher {
ConflictMapReduceToCard.factory()); ConflictMapReduceToCard.factory());
break; break;
case "divide-v1": case "divide-v1":
cpsolver.setConflictFactory( cpsolver.setConflictFactory(ConflictMapRounding.factory());
ConflictMapRounding.factory());
break; break;
case "divide-unless-equal": case "divide-unless-equal":
case "divide-unless-divisor": case "divide-unless-divisor":
...@@ -302,13 +304,13 @@ public class KTHLauncher { ...@@ -302,13 +304,13 @@ public class KTHLauncher {
if (line.hasOption("natural")) { if (line.hasOption("natural")) {
cpsolver.setOrder(new NaturalStaticOrder()); cpsolver.setOrder(new NaturalStaticOrder());
} }
if (line.hasOption("autodiv") ) { if (line.hasOption("autodiv")) {
cpsolver.setAutoDivisionStrategy(AutoDivisionStrategy.ENABLED); cpsolver.setAutoDivisionStrategy(AutoDivisionStrategy.ENABLED);
} }
System.out.println(pbsolver.toString("c ")); System.out.println(pbsolver.toString("c "));
String[] leftArgs = line.getArgs(); String[] leftArgs = line.getArgs();
if (leftArgs.length == 0) { if (leftArgs.length == 0) {
System.err.println("Missing filename"); log("Missing filename");
return; return;
} }
String filename = leftArgs[leftArgs.length - 1]; String filename = leftArgs[leftArgs.length - 1];
...@@ -320,8 +322,8 @@ public class KTHLauncher { ...@@ -320,8 +322,8 @@ public class KTHLauncher {
@Override @Override
public void run() { public void run() {
// stop the solver before displaying solutions // stop the solver before displaying solutions
optimizer.expireTimeout(); optimizer.expireTimeout();
optimizer.printStat(System.out, "c "); optimizer.printStat(System.out, "c ");
} }
}; };
...@@ -339,14 +341,13 @@ public class KTHLauncher { ...@@ -339,14 +341,13 @@ public class KTHLauncher {
} }
if (optimizer.isSatisfiable()) { if (optimizer.isSatisfiable()) {
if (optimizer.isOptimal()) { if (optimizer.isOptimal()) {
System.out.println("s OPTIMUM FOUND"); log("OPTIMUM FOUND", "s ");
} else { } else {
System.out.println("s SATISFIABLE"); log("SATISFIABLE", "s ");
} }
System.out.println( log(reader.decode(optimizer.model()) + " 0", "v ");
"v " + reader.decode(optimizer.model()) + " 0");
} else { } else {
System.out.println("s UNSATISFIABLE"); log("UNSATISFIABLE","s ");
} }
} catch (TimeoutException e) { } catch (TimeoutException e) {
log("UNKNOWN","s "); log("UNKNOWN","s ");
...@@ -356,7 +357,7 @@ public class KTHLauncher { ...@@ -356,7 +357,7 @@ public class KTHLauncher {
log(e.getMessage()); log(e.getMessage());
} }
} catch (ParseException exp) { } catch (ParseException exp) {
System.out.println("Unexpected exception:" + exp.getMessage()); log("Unexpected exception:" + exp.getMessage());
} }
} }
} }
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