Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions parsers/src/main/java/org/chocosolver/parser/RegParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,14 @@ public abstract class RegParser extends SettingsBuilder implements IParser {
public String instance;

@SuppressWarnings({"unused", "FieldMayBeFinal"})
@Option(name = "-pa", aliases = {"--parser"}, usage = "Parser to use.\n" +
"0: automatic\n " +
"1: FlatZinc (.fzn)\n" +
"2: XCSP3 (.xml or .lzma)\n" +
"3: DIMACS (.cnf),\n" +
"4: MPS (.mps)")
@Option(name = "-pa", aliases = {"--parser"}, usage = """
Parser to use.
0: automatic
\
1: FlatZinc (.fzn)
2: XCSP3 (.xml or .lzma)
3: DIMACS (.cnf),
4: MPS (.mps)""")
private int pa = 0;

@Option(name = "-ansi", usage = "Enable ANSI colour codes (default: false).")
Expand Down Expand Up @@ -278,10 +280,8 @@ public void configureSearch() {
if (level.is(Level.VERBOSE)) {
solver.verboseSolving(1000);
}
if (nb_cores == 1) {
if (free) {
freesearch(solver);
}
if (nb_cores == 1 && free) {
freesearch(solver);
}
for (int i = 0; i < nb_cores; i++) {
if (limits.getTime() > -1) {
Expand Down
52 changes: 29 additions & 23 deletions parsers/src/main/java/org/chocosolver/parser/xcsp/XCSP.java
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,15 @@ public void buildModel() {
if (level.is(Level.JSON)) {
s.getMeasures().setReadingTimeCount(System.nanoTime() - s.getModel().getCreationTime());
s.log().printf(Locale.US,
"{\t\"name\":\"%s\",\n" +
"\t\"variables\": %d,\n" +
"\t\"constraints\": %d,\n" +
"\t\"policy\": \"%s\",\n" +
"\t\"parsing time\": %.3f,\n" +
"\t\"building time\": %.3f,\n" +
"\t\"memory\": %d,\n" +
"\t\"stats\":[",
"""
{\t"name":"%s",
\t"variables": %d,
\t"constraints": %d,
\t"policy": "%s",
\t"parsing time": %.3f,
\t"building time": %.3f,
\t"memory": %d,
\t"stats":[""",
instance,
m.getNbVars(),
m.getNbCstrs(),
Expand All @@ -133,18 +134,19 @@ public void buildModel() {

public void parse(Model target, XCSPParser parser) throws Exception {
parser.model(target, instance);
// and define a search strategy
BlackBoxConfigurator bb = BlackBoxConfigurator.init();
// variable selection
bb.setIntVarStrategy(Search::roundRobinSearch)
.setRestartPolicy(s -> new Restarter(new InnerOuterCutoff(50, 1.01, 1.01),
c -> s.getFailCount() >= c, 50_000, true))
.setNogoodOnRestart(!this.isLCG())
.setRestartOnSolution(this.isLCG())
.setRefinedPartialAssignmentGeneration(false)
.setExcludeObjective(true)
.setExcludeViews(false);
bb.make(target);
if (!(free && nb_cores == 1)) {
// define default search strategy (skipped in single-core free search mode, freesearch() handles it)
BlackBoxConfigurator bb = BlackBoxConfigurator.init();
bb.setIntVarStrategy(Search::roundRobinSearch)
.setRestartPolicy(s -> new Restarter(new InnerOuterCutoff(50, 1.01, 1.01),
c -> s.getFailCount() >= c, 50_000, true))
.setNogoodOnRestart(!this.isLCG())
.setRestartOnSolution(this.isLCG())
.setRefinedPartialAssignmentGeneration(false)
.setExcludeObjective(true)
.setExcludeViews(false);
bb.make(target);
}
}


Expand Down Expand Up @@ -189,7 +191,7 @@ public void freesearch(Solver solver) {
if (level.isLoggable(Level.INFO)) {
solver.log().println(bb.toString());
}
bb.complete(solver.getModel(), solver.getSearch());
bb.make(solver.getModel());
}

protected void singleThread() {
Expand Down Expand Up @@ -311,8 +313,12 @@ private void finalOutPut(Solver solver) {
solver.getTimeCount());
}
if (level.is(Level.JSON)) {
solver.log().printf(Locale.US, "\n\t],\n\t\"exit\":{\"time\":%.1f, " +
"\"bound\":%d, \"nodes\":%d, \"failures\":%d, \"restarts\":%d, \"status\":\"%s\"}\n}",
solver.log().printf(Locale.US, """

\t],
\t"exit":{"time":%.1f, \
"bound":%d, "nodes":%d, "failures":%d, "restarts":%d, "status":"%s"}
}""",
solver.getTimeCount(),
solver.getObjectiveManager().isOptimization() ?
solver.getObjectiveManager().getBestSolutionValue().intValue() :
Expand Down
Loading