Commit ecc0e58f authored by René Schöne's avatar René Schöne
Browse files

Describe, how to check a solution.

parent add4858f
......@@ -73,6 +73,24 @@ To test your solver with the name `fancy-solver` along with the reference implem
The value `total` is used to constrain the total number of models to be generated. Set this to `null` (the default) to generate all value for the defined parameter ranges.
Refer to [``]( for a description of the possible parameters.
## Checking a solution using Java methods
The check, if a `Solution` object is valid, either call [`solution.valid()`]( returning a boolean, if the solution is valid, or call [`solution.explain`]( to print out if the solution is valid and violations, if there are any.
You may also look into the [code used for external tools]( to see a minimal working example.
### Checking a solution for external tools
If you can not use Java method, we provided a Gradle task `checkSolution` expecting two paths to files: the problem description and the solution.
Alternatively, you can use the wrapper shell-script `` with the same parameters (problem description and its solution).
In both cases, the output will be the following:
- The read solution pretty-printed (to verify correct parsing)
- Whether the solution is valid, and the violations in the solution, if any.
- The objective value of the solution.
Thus, the check will only check for validity and not for optimality as this would require solving the problem again.
## Notes and Troubleshooting
- Please use the gradle wrapper script, as different version of Gradle might not work with the setup
......@@ -2,7 +2,7 @@ aspect Checking {
public void Solution.explain() {
Set<Request> requestSet = new HashSet<>();
Map<Resource, Assignment> resourceSet = new HashMap<>();;
// check assignments
for (Assignment assignment : allAssignments()) {
if (!assignment.isValid()) {
......@@ -4,6 +4,7 @@ import beaver.Parser;
import org.apache.logging.log4j.LogManager;
......@@ -38,8 +39,8 @@ public class MainCheck {
boolean isValid = solution.isValid();
double objectiveValue = solution.computeObjective();
System.out.println("Solution valid: " + Boolean.toString(isValid));
System.out.println("Objective value: " + objectiveValue);
LogManager.getLogger(MainCheck.class).info("Objective value: " + objectiveValue);
private static void printUsage() {
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