Commit 3bc22078 authored by Daniel Le Berre's avatar Daniel Le Berre

Removed ExitCode field in AbstractLauncher.

parent d1a49f59
......@@ -74,8 +74,6 @@ public abstract class AbstractLauncher implements Serializable, ILogAble {
protected long beginTime;
protected ExitCode exitCode = ExitCode.UNKNOWN;
protected Reader reader;
protected boolean feedWithDecorated = false;
......@@ -265,7 +263,6 @@ public abstract class AbstractLauncher implements Serializable, ILogAble {
} catch (IOException e) {
System.err.println("FATAL " + e.getLocalizedMessage());
} catch (ContradictionException e) {
this.exitCode = ExitCode.UNSATISFIABLE;
this.launcherMode.setExitCode(ExitCode.UNSATISFIABLE);
log("(trivial inconsistency)"); //$NON-NLS-1$
} catch (ParseFormatException e) {
......@@ -319,7 +316,6 @@ public abstract class AbstractLauncher implements Serializable, ILogAble {
protected void solve(IProblem problem) throws TimeoutException {
launcherMode.solve(problem, reader, this, out, beginTime);
this.setExitCode(launcherMode.getCurrentExitCode());
}
/**
......@@ -340,7 +336,7 @@ public abstract class AbstractLauncher implements Serializable, ILogAble {
* the new ExitCode
*/
public final void setExitCode(ExitCode exitCode) {
this.exitCode = exitCode;
this.launcherMode.setExitCode(exitCode);
}
/**
......@@ -349,7 +345,7 @@ public abstract class AbstractLauncher implements Serializable, ILogAble {
* @return the current value of the Exitcode
*/
public final ExitCode getExitCode() {
return this.exitCode;
return this.launcherMode.getCurrentExitCode();
}
/**
......
......@@ -47,8 +47,8 @@ import org.sat4j.tools.xplain.Xplain;
public class MUSLauncher extends AbstractLauncher {
/**
*
*/
*
*/
private static final long serialVersionUID = 1L;
private int[] mus;
......@@ -94,8 +94,8 @@ public class MUSLauncher extends AbstractLauncher {
this.xplain = hlxp;
solver = hlxp;
} else {
Xplain<ISolver> xp = new Xplain<ISolver>(
SolverFactory.newDefault(), false);
Xplain<ISolver> xp = new Xplain<ISolver>(SolverFactory.newDefault(),
false);
this.xplain = xp;
solver = xp;
}
......@@ -109,9 +109,9 @@ public class MUSLauncher extends AbstractLauncher {
String className = "org.sat4j.tools.xplain." + args[0]
+ "Strategy";
try {
this.xplain
.setMinimizationStrategy((MinimizationStrategy) Class
.forName(className).newInstance());
this.xplain.setMinimizationStrategy(
(MinimizationStrategy) Class.forName(className)
.newInstance());
} catch (Exception e) {
log(e.getMessage());
}
......@@ -125,16 +125,17 @@ public class MUSLauncher extends AbstractLauncher {
@Override
protected void displayResult() {
if (this.solver != null) {
double wallclocktime = (System.currentTimeMillis() - this.beginTime) / 1000.0;
double wallclocktime = (System.currentTimeMillis() - this.beginTime)
/ 1000.0;
this.solver.printStat(this.out);
this.solver.printInfos(this.out);
this.out.println(ILauncherMode.ANSWER_PREFIX + this.exitCode);
if (this.exitCode == ExitCode.SATISFIABLE) {
this.out.println(ILauncherMode.ANSWER_PREFIX + this.getExitCode());
if (this.getExitCode() == ExitCode.SATISFIABLE) {
int[] model = this.solver.model();
this.out.print(ILauncherMode.SOLUTION_PREFIX);
this.reader.decode(model, this.out);
this.out.println();
} else if (this.exitCode == ExitCode.UNSATISFIABLE
} else if (this.getExitCode() == ExitCode.UNSATISFIABLE
&& this.mus != null) {
this.out.print(ILauncherMode.SOLUTION_PREFIX);
this.reader.decode(this.mus, this.out);
......@@ -148,8 +149,9 @@ public class MUSLauncher extends AbstractLauncher {
public void run(String[] args) {
this.mus = null;
super.run(args);
double wallclocktime = (System.currentTimeMillis() - this.beginTime) / 1000.0;
if (this.exitCode == ExitCode.UNSATISFIABLE) {
double wallclocktime = (System.currentTimeMillis() - this.beginTime)
/ 1000.0;
if (this.getExitCode() == ExitCode.UNSATISFIABLE) {
try {
log("Unsat detection wall clock time (in seconds) : "
+ wallclocktime);
......
......@@ -345,8 +345,8 @@ public class Lanceur extends AbstractLauncher implements ILogAble {
setExitCode(ExitCode.OPTIMUM_FOUND);
}
} else {
this.exitCode = problem.isSatisfiable() ? ExitCode.SATISFIABLE
: ExitCode.UNSATISFIABLE;
this.setExitCode(problem.isSatisfiable() ? ExitCode.SATISFIABLE
: ExitCode.UNSATISFIABLE);
}
}
......@@ -429,7 +429,7 @@ public class Lanceur extends AbstractLauncher implements ILogAble {
} catch (IOException e) {
System.err.println("FATAL " + e.getLocalizedMessage());
} catch (ContradictionException e) {
this.exitCode = ExitCode.UNSATISFIABLE;
this.setExitCode(ExitCode.UNSATISFIABLE);
log("(trivial inconsistency)"); //$NON-NLS-1$
} catch (ParseFormatException e) {
System.err.println("FATAL " + e.getLocalizedMessage());
......
......@@ -344,7 +344,6 @@ public class Launcher extends AbstractLauncher implements ILogAble {
} catch (IOException e) {
System.err.println("FATAL " + e.getLocalizedMessage());
} catch (ContradictionException e) {
this.exitCode = ExitCode.UNSATISFIABLE;
getLauncherMode().setExitCode(ExitCode.UNSATISFIABLE);
log("(trivial inconsistency)"); //$NON-NLS-1$
} catch (ParseFormatException e) {
......
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