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 [`de.tudresden.inf.st.mquat.generator.ScenarioDescription`](https://git-st.inf.tu-dresden.de/stgroup/ttc18/blob/master/jastadd-mquat-base/src/main/java/de/tudresden/inf/st/mquat/generator/ScenarioDescription.java) 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()`](https://git-st.inf.tu-dresden.de/stgroup/ttc18/blob/master/jastadd-mquat-base/src/main/jastadd/solution/Checking.jrag#L3) returning a boolean, if the solution is valid, or call [`solution.explain`](https://git-st.inf.tu-dresden.de/stgroup/ttc18/blob/master/jastadd-mquat-base/src/main/jastadd/solution/Checking.jadd#L2) 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](https://git-st.inf.tu-dresden.de/stgroup/ttc18/blob/master/jastadd-mquat-base/src/main/java/de/tudresden/inf/st/mquat/MainCheck.java) 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 `checkSolution.sh` 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<>();
logger.info(this.toString());
// logger.info(this.toString());
// check assignments
for (Assignment assignment : allAssignments()) {
if (!assignment.isValid()) {
......
......@@ -4,6 +4,7 @@ import beaver.Parser;
import de.tudresden.inf.st.mquat.jastadd.model.*;
import de.tudresden.inf.st.mquat.jastadd.scanner.MquatScanner;
import de.tudresden.inf.st.mquat.utils.ParserUtils;
import org.apache.logging.log4j.LogManager;
import java.io.BufferedReader;
import java.io.IOException;
......@@ -38,8 +39,8 @@ public class MainCheck {
System.out.println(out);
boolean isValid = solution.isValid();
double objectiveValue = solution.computeObjective();
System.out.println("Solution valid: " + Boolean.toString(isValid));
System.out.println("Objective value: " + objectiveValue);
solution.explain();
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