Skip to content

Commit

Permalink
Add access to underlying solver of MaxSatSolver
Browse files Browse the repository at this point in the history
  • Loading branch information
Apfelbeet committed Jan 7, 2025
1 parent 785ec33 commit b1092da
Showing 1 changed file with 27 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,9 @@ protected MaxSatSolver(final FormulaFactory f, final MaxSatConfig configuration)
this.configuration = configuration;
solver = initSolver(configuration);
pgTransformation = configuration.getCnfMethod() == FACTORY_CNF
? null
: new PlaistedGreenbaumTransformationMaxSatSolver(f, configuration.getCnfMethod() == PG_ON_SOLVER, solver);
? null
: new PlaistedGreenbaumTransformationMaxSatSolver(f,
configuration.getCnfMethod() == PG_ON_SOLVER, solver);
}

private MaxSat initSolver(final MaxSatConfig configuration) {
Expand Down Expand Up @@ -219,6 +220,19 @@ public LngResult<MaxSatResult> solve(final ComputationHandler handler) {
return result;
}

/**
* Erases the cached result.
* <p>
* The result of the last computation is cached and reused if the state of
* the solver does not change. However, it does not recognize manipulation
* of the underlying solver. It is necessary to reset the solver's result
* manually in those cases. It is not necessary to manually reset the
* solver's result in all other cases.
*/
public void resetResult() {
result = null;
}

/**
* Returns the stats of the underlying solver.
* @return the stats of the underlying solver
Expand All @@ -243,6 +257,17 @@ public FormulaFactory getFactory() {
return f;
}

/**
* Returns the underlying MaxSat solver.
* <p>
* ATTENTION: by influencing the underlying solver directly, you can mess
* things up completely! You should really know what you are doing.
* @return the underlying solver
*/
public MaxSat getUnderlyingSolver() {
return solver;
}

@Override
public String toString() {
return String.format("MaxSatSolver{result=%s}", result);
Expand Down

0 comments on commit b1092da

Please sign in to comment.